Windows Login Behind SA account
-
lundi 26 mars 2012 13:35
Dear Friends,
How do i find the windows user name of an "SA" account, let me give you an example: windows login is "DOMAIN\USER" and this person is using "SA" account i want get "DOMAIN\USER" not "SA". all functions in my knowledge (suser_sname() , suser_name(),USER_NAME(),SYSTEM_USER) returns only sql login info...
Can someone please guide...
Regards,
Sami Ullah
- Modifié Sami Bhashani lundi 26 mars 2012 13:43 typing error..
Toutes les réponses
-
lundi 26 mars 2012 13:46
You cannot retrieve this information from SQL Server. In the general case there may not even be a Windows user. The user may have logged in over TCP/IP from a Unix box.
If you have information from which host the user logged in, you may be able to see who was logged in that machine at that time.
But if you want to know who did what then, you should disable as and create personal accounts for people who have legit reasons to be sysadmin on the server.
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se- Marqué comme réponse Sami Bhashani lundi 26 mars 2012 13:57
- Non marqué comme réponse Sami Bhashani jeudi 29 mars 2012 07:11
-
lundi 26 mars 2012 13:56Modérateur
"sa" is a login itself, that is how you login "sa", password. There is no association with domain\user. On the other hand, you can make a domain\user a member of the sysadmin fixed server role with same privileges as "sa".
BOL: "System administrator (sa) is a special login provided for backward
compatibility. By default, it is assigned to the sysadmin fixed server
role and cannot be changed. Although sa is a built-in administrator
login, do not use it routinely. Instead, make system administrators members of
the sysadmin fixed server role, and have them log on using their own
logins. Use sa only when there is no other way to log in to an instance
of Microsoft® SQL Server™ (for example, when other system administrators are
unavailable or have forgotten their passwords)."http://msdn.microsoft.com/en-us/library/aa905197(v=sql.80).aspx
Kalman Toth SQL SERVER 2012 & BI TRAINING
New Book: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2012- Proposé comme réponse Naomi NMicrosoft Community Contributor, Moderator lundi 26 mars 2012 14:45
- Modifié Kalman TothMicrosoft Community Contributor, Moderator mardi 2 octobre 2012 20:28
- Marqué comme réponse Kalman TothMicrosoft Community Contributor, Moderator mardi 2 octobre 2012 20:28
-
lundi 26 mars 2012 13:57
hi Sommarskog,
Thank you very much for you support, i was really now getting Mad to find the solution i have tried every thing according to my knowledge...
thanks,
Sami Bhashani...
-
lundi 26 mars 2012 14:13
i mean when ever we access a DB we have to login with sql authentication, windows authentication right or mixed? but if we use SA login its mean it is for sql server not for windows here we must have a windows login i am trying to find that name....i.g i have windows login "domain\user" after that i access the sql using "SA" account now, if someone want to find who is using "SA" account how can he/she find login name "domain\user" ?
-
lundi 26 mars 2012 20:54
-
jeudi 29 mars 2012 06:36
Friends,
i have found the salutation just try it....
exec xp_cmdshell 'ECHO %USERDOMAIN%\%USERNAME%'
- Modifié Sami Bhashani jeudi 29 mars 2012 07:10 typing mistake
- Marqué comme réponse Sami Bhashani jeudi 29 mars 2012 07:11
-
jeudi 29 mars 2012 07:27
i have found the salutation just try it....
exec xp_cmdshell 'ECHO %USERDOMAIN%\%USERNAME%'
I tried it on a server where I'm logged in as sa. It gives the service account for SQL Server and certainly not my Windows login.So I don't know what you found, but I believe it was a mirage.
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se -
mercredi 4 avril 2012 13:54
Respected Sommarskog,
i am logged in with SA, but in Result set there is my windows login (on Server)...
- Modifié Sami Bhashani mercredi 4 avril 2012 13:58

