June 26, 2009 at 9:14 am
Hi, I am creating a record and want to put the name of the current user as a field in the record. How can I do this? The current user is the one who is logged in to the computer that is accessing sql server 2005
June 26, 2009 at 9:25 am
try using
select system_user
June 30, 2009 at 10:34 am
This only works if the user logs in using Integrated Security, if the use a SQL login then SYSTEM_USER will show that name.
You may not be able to get AD name but you could get HOST_NAME() which would show what machine they came in from, it isn't the same, but most organizations know what machine names are assigned to individuals..
CEWII
June 30, 2009 at 1:47 pm
Hi Elliott
Elliott (6/30/2009)
...but you could get HOST_NAME() ...
Be careful with HOST_NAME(). It can be manipulated by client connection-string. If you have any .NET environment you can try this connection string:
"Data Source=.;Integrated Security=True;Workstation ID=Blah"
In this case sys.dm_exec_sessions and HOST_NAME() will show "Blah" as host-name.
Flo
July 1, 2009 at 5:56 am
Host name is also useless if your users connect from a terminal server session. All of th eusers on the same TS will ahve the same host name.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply