Daniel Wilson
asked on
Get Windows account name of user who's running query
There is a function in SQL Server 2005 that returns the WINDOWS login of the person running a query.
It's not System_user or Current_User or User_Name.
For Windows users connecting to SQL Server with a SQL account, those return the SQL login.
But this application always runs under the account ProgramUser (for example). But I need to audit whether 'JDoe', 'SSmith' or 'MBrown' is the windows login behind it.
I've used this before but I can't find it today ...
What's the function I'm looking for!
Thanks!
It's not System_user or Current_User or User_Name.
For Windows users connecting to SQL Server with a SQL account, those return the SQL login.
But this application always runs under the account ProgramUser (for example). But I need to audit whether 'JDoe', 'SSmith' or 'MBrown' is the windows login behind it.
I've used this before but I can't find it today ...
What's the function I'm looking for!
Thanks!
SUSER_SNAME()
ASKER
No, I'm getting the same thing.
Other ideas?
Other ideas?
what is your login? what are you wanting to see?
so, for a sql login, you want to see the MachineName that the connection is made, right?
suser_sname() was what I thought you were after as well but try original_login()
ASKER
Most of the users are connecting to Citrix_Server to run the application. They are logging into Windows as 'JDoe', 'SSmith', 'MBrown', etc.
But they are all running the application as 'ProgramUser'.
I am connecting to Remote Desktop on DB_Server as 'ApplicationAdmin' and logging into SQL Server via SSMS as 'ProgramManager'.
I want to see the Windows login -- 'JDoe', 'SSmith', 'MBrown', 'ApplicationAdmin' -- NOT 'ProgramUser' or 'ProgramManager'.
Thanks!
But they are all running the application as 'ProgramUser'.
I am connecting to Remote Desktop on DB_Server as 'ApplicationAdmin' and logging into SQL Server via SSMS as 'ProgramManager'.
I want to see the Windows login -- 'JDoe', 'SSmith', 'MBrown', 'ApplicationAdmin' -- NOT 'ProgramUser' or 'ProgramManager'.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
no, original_login() only matters where there are context switches, such as using EXECUTE AS
ASKER
Looks like you're right. It's when using Windows authentication that those data are available.
Thanks!
Thanks!