Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 SQL Server logins

Author  Topic 

tchya
Starting Member

2 Posts

Posted - 2004-08-17 : 10:27:48
Hi everybody,

I am constructing a dialog which prompts user for username and password to login to an SQL Server database. If another user on a different machine try to login with the same username, he will be ask if he wish to log out the old login first. If he choose yes, the old login will be logged out. My problem is that how can we know whether an SQL Server login is in use (has been logged by a different user)? And are there any ways to log out a logged SQL Server login?

Thanks.

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-08-17 : 11:21:28
Look at using sp_Who, or sp_Who2, to see the logins currently connected to the server. If you find a name you want to disconnect, take the spid and issue the KILL command. Not neat, but it will do the trick.


Raymond
Go to Top of Page

CanadaDBA

583 Posts

Posted - 2004-08-17 : 11:35:42
Raymond gave all the hints. You may execute this as well.
[CODE]
SELECT * FROM master.dbo.SysProcesses
[/CODE]

Canada DBA
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-08-17 : 22:53:12
Wouldn't you prefer to know if they "log out" of the application? This likely will not equate to a SQL Server login being maintained. For example, look at hotmail. I open hotmail and pull mail. Then I browse my favorite website, which is www.sqlteam.com of course. Shortly thereafter, I decide to look at all my new SPAM graciously sent to me by the local porn providers. I don't have to relog in. I didn't maintain a connection to the database though. WOW How does this magic happen??????

They have a kewl little table called login_history (or some such nefarious object) which identifies the IP Address and a session key or something which is probably stored on my computer in one of those horrible cookies that will destroy your computer and walk off with your children.

If I login from another computer, it says "Who are YOU?". If I destroy my cookie, the cookie monster eats it, or I log off my internet browser, I have to magically log back in.

Yep....application security is the way to do it. It's a marvelous thing really. Those tables will help you though. Ask them for the SSN, birthday, and there most commonly used PIN number also to store in there.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

tchya
Starting Member

2 Posts

Posted - 2004-08-18 : 08:03:50
Thank you for your helps!
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-08-18 : 13:45:06
How you've started something Derrick ... <g>

Kristen
Go to Top of Page
   

- Advertisement -