May 14, 2010 at 5:52 am
Hi,
For a SQL server authenticated connection to SQL Server 2008, is it possible to get the OS username from the terminal where connection is made. thanks.
Regards,
MShenel
May 14, 2010 at 6:42 am
as far as i know, you can get it only if they used their windows credentials to login to the server; if they logged in with a SQL login, it's not available...even if you went to xp_cmdShell and ran "whoami", it will not return the windows user.
select
user_name() AS [user_name],
suser_name() AS [suser_name],
current_user AS [current_user],
system_user AS [system_user],
session_user AS [session_user],
user AS
/*
user_name suser_name current_user system_user session_user user
dbo sa dbo sa dbo dbo
dbo DISNEY\lizaguirre dbo DISNEY\lizaguirre dbo dbo
guest bob guest bob guest guest
*/
you can also get their IP and hostname, which can help:
select host_name(),app_name(),client_net_address from sys.dm_exec_connections where session_id = @@spid
/*
(No column name)(No column name)client_net_address
D223Microsoft SQL Server Management Studio - Query192.168.0.40
*/
Lowell
May 14, 2010 at 7:24 am
Thanks we already get hostname,appname for specific operations.We DBAs do administrative task on a terminal server with a SQL server generic user. If we cant get osuser somehow then you we must have seperate logins for each DBA for auditing.
Regards,
MShenel
May 14, 2010 at 9:27 am
What if you enabled auditing by machine? Then you could capture the machine and correlate it back.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply