April 20, 2009 at 12:50 pm
Hi,
I would like to know if it's possible to retreive Windows user logged on to the PC (domain\userid) using Sql, if possible please provide code?
Regards
April 20, 2009 at 1:06 pm
check out suser_name() function.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 20, 2009 at 1:37 pm
I have googled it and suser_name() does not work in SQL2000 it returns null
and the code user_name() only returns dbo
Please Assist
April 20, 2009 at 1:42 pm
check out BOL for sql 2000. Look at the entry for suser_name 😀
http://msdn.microsoft.com/en-us/library/aa299742(SQL.80).aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 20, 2009 at 2:09 pm
Thank You for the functions, the function works: SELECT SUSER_SNAME()
but this returns the SQL user logged in, I'm trying to return the user logged on to the current PC.
search somewhere in the registry or like web applications that determine the the windows auth user
domain\userid
Regards
April 20, 2009 at 2:16 pm
Unless you are using windows authentication that is not possible. When you make a connection to sql you do not specify what machine and user is using it. It would be a HUGE security issue if SQL can just reach into a client machine and read things like who is logged in. :w00t: I know there are lots of other folks out here who know far more than I do but I do not think this is possible. Maybe someone else will chime in with a way to do this.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 20, 2009 at 2:23 pm
Thank You for the help 🙂
April 21, 2009 at 2:56 am
Thank You all - I used an aspx sever side page to get the windows user id and passed it as a parameter value to my SSRS report.
Regards
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply