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.
| Author |
Topic |
|
Sprinjee
Starting Member
42 Posts |
Posted - 2006-02-04 : 07:22:53
|
| I don't think it is possible but anyway...I want to retrieve the NT Username in SQL being logged on to the database using SQL authentication. So f.i.exec master..xp_cmdshell 'echo %username%'which of course does no work...Anybody? |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2006-02-06 : 06:06:20
|
| SELECT SYSTEM_USER will return the current user in the form 'DOMAIN\user_login_name' for users logged in via Windows authentication.Mark |
 |
|
|
Sprinjee
Starting Member
42 Posts |
Posted - 2006-02-19 : 18:55:56
|
| I've tried this, as I log in using sql authentication (sa) and run SELECT SYSTEM_USER it returns SA not my Windows NT username |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-19 : 19:50:10
|
quote: Originally posted by Sprinjee I've tried this, as I log in using sql authentication (sa) and run SELECT SYSTEM_USER it returns SA not my Windows NT username
system_user will return the current login user. Regardless of if you login using SQL Authentication or Windows Authentication.If you login using SQL Authentication it will definately return the SQL Authentication's SQL Login Name. And there isn't any corresponding NT Username for SQL Authentication.----------------------------------'KH'Time is always against us |
 |
|
|
elwoos
Master Smack Fu Yak Hacker
2052 Posts |
Posted - 2006-02-20 : 03:51:25
|
quote: I've tried this, as I log in using sql authentication (sa) and run SELECT SYSTEM_USER it returns SA not my Windows NT username
Logging in using SA isn't good practice. I suggest you setup an account with the rights you need and use thatsteve-----------Oh, so they have internet on computers now! |
 |
|
|
Sprinjee
Starting Member
42 Posts |
Posted - 2006-02-20 : 11:29:27
|
| I have setup accounts and distributed rights among them, the SA mentioned above was just the clarify my problem and for test purposes only... |
 |
|
|
|
|
|