Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,

I have Web and windows application build in asp.net C# and database SQL server.

I would like to stop a user(s) to login into the windows application with the same UserID/Password.

The users are simultaneously login into the windows application with the same UserID and password at the same time but different machines.

What I have tried:

I tried to update the status of logged in user as 'LoggedIn' but this is updating at the same time from two machines for the same user.

How can I prevent a user from multiple logins?

Can anyone please help me.


Thanks in advance
Posted
Updated 9-Apr-19 23:16pm
Comments
F-ES Sitecore 10-Apr-19 6:47am    
Trying to stop multiple logins is usually pointless and technically impossible. What problem are you trying to solve?
[no name] 10-Apr-19 11:48am    
1

I have found that the best way to prevent multiple logins for a user is to allow them to log in but warn them that they will be logged out of other machines, then log them out if they accept.

I have no idea how you would implement this as you have not given any code, but hopefully the approach will work for you.

FYI: this also takes care of not having to check the logout process if an instance crashes
 
Share this answer
 
Comments
[no name] 10-Apr-19 11:48am    
1
You should create one more table having name activeLogin with bellowed mentioned columns

RefID, Key, LoginTime, LogoutTime, IsActive

You can generate custom key while installing the application or while running the applicatio, you can save it with respect to login time.

That key can be anything like motherboard, custom key stored as .ini file or any other config file.

You can check it in the table while doing a login activity of an application. If the Logout column is NULL and IsActive = true and the ket is different then you can prompt "Are you sure want to login ?" then you should Set Logout = GetDate() and IsActive = false, This will leads new record in activelogin table with new key and time.

So You can to check that key with regular time interval like 1 or 2 min, If you can't find respective key which should be active then you can shutdown the app
 
Share this answer
 
Comments
[no name] 10-Apr-19 11:48am    
1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900