Solution to avoid multiple logins by a user

Source: Internet
Author: User

Method 1: directly modify the startuppost method of the info class. Because the modification is complicated, I will directly reference the junevoful code as an example below.

Void startuppost ()

{

Int counter;

Int num = 0;

Int maxsessions = info: licenseduserstotal ();

Xsession session;

Userinfo;

Userid currentuserid;

;

 

Currentuserid = curuserid ();

For (counter = 1; counter <maxsessions; counter ++)

{

Session = new xsession (counter, true );

If (Session & session. userid ())

{

Select firstonly userinfo

Where userinfo. ID = session. userid ();

 

If (userinfo & (currentuserid = session. userid ()))

{

Num ++;

}

}

}

 

If (Num> 1)

{

Box: Info ("this user ID has been logged in. Please exit. ")

{

Infolog. Shutdown (true );

}

}

}

 

Method 2: Further improvement of method 1 is also in use.

Different departments may have different working hours. In this way, when licence is limited, many people may log on to the department that is working earlier, but cannot log on to the department at night. To avoid this unfair phenomenon, we first create a department field in the sysuserinfo table, and then create a table to indicate the number of people that can log on to each department at the same time. Then, code similar to method 1 is used to control the number of login users.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.