Prevent Multiple Same User Logins On A Desktop Application C#
-
Hi All, I have a windows form application (C#) and the users can login to the application by user name and password, and I need to prevent the same user to login to the system from different machines or only one time login, and if the user is logged in I need to disallow a login with a notification the user is already logged in. C# Desktop Application Not Web With MS SQL Server Database Thank you
-
Hi All, I have a windows form application (C#) and the users can login to the application by user name and password, and I need to prevent the same user to login to the system from different machines or only one time login, and if the user is logged in I need to disallow a login with a notification the user is already logged in. C# Desktop Application Not Web With MS SQL Server Database Thank you
One way to do this is to query if there already is a session for that specific user in the system. You can get the information from sys.dm_exec_sessions[^] Since not every user is allowed to query that view, it's best if you do the check inside a stored procedure upon connecting to the database. If the connection is already found (or actually if there now is two connections) then raise an error from the procedure to inform client application that new connection isn't allowed. Another option is to use Logon Triggers[^] Depending on the requirements, you can check if the host is different if you need to allow multiple connections from the same host
-
One way to do this is to query if there already is a session for that specific user in the system. You can get the information from sys.dm_exec_sessions[^] Since not every user is allowed to query that view, it's best if you do the check inside a stored procedure upon connecting to the database. If the connection is already found (or actually if there now is two connections) then raise an error from the procedure to inform client application that new connection isn't allowed. Another option is to use Logon Triggers[^] Depending on the requirements, you can check if the host is different if you need to allow multiple connections from the same host
Hi, dm_exec_sessions is about sql user authentication, but I need for my application users In my application database I have a users table with login name and Password I need to check if the User is open the application and logged in I want prevent it login again from the same PC or from different PC's Thanks
-
Hi, dm_exec_sessions is about sql user authentication, but I need for my application users In my application database I have a users table with login name and Password I need to check if the User is open the application and logged in I want prevent it login again from the same PC or from different PC's Thanks
First of all,
dm_exec_sessions
contains rows for both SQL Server authenticated users and Windows authenticated users. So regardless of the authentication method, a row exists if a connection exists. What comes to user identification, do you have information about the actual OS user in your user table? If you do, you could use that info fromnt_user_name
column and check if that user matches. -
First of all,
dm_exec_sessions
contains rows for both SQL Server authenticated users and Windows authenticated users. So regardless of the authentication method, a row exists if a connection exists. What comes to user identification, do you have information about the actual OS user in your user table? If you do, you could use that info fromnt_user_name
column and check if that user matches. -
Hi, dm_exec_sessions is about sql user authentication, but I need for my application users In my application database I have a users table with login name and Password I need to check if the User is open the application and logged in I want prevent it login again from the same PC or from different PC's Thanks