Retrieve User Network Name

  • Hello everyone.

    Is it possible to retrieve a Windows network name while logged into SQL Server using the sa account? I've tried every function in BOL related to security, but the ones I thought would work only returned "sa" instead of the network name of the current machine. Any ideas?

    Thanks.

  • Yes, its possible. Try suser_name() instead of user_name.

    Example:

    select

    user_name() [user_name]

    ,suser_name() [suser_name]

    Steve
    http://stevefibich.net
    http://utilitydb.codeplex.com/

  • however, if htey connected using a SQL login, the windows username is not available in any way, shape or form, unless you specifically code an application to get the information and pass it along.

    SQL logins do not contain any info from Windows.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I was afraid that would be the case.

    Thanks.

  • NO you can't get that info for SQL Server logins..

    Thank You,

    Best Regards,

    SQLBuddy

  • you should be able to get the IP address of the client this may help to narrow the user down

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Perry Whittle (9/18/2011)


    you should be able to get the IP address of the client this may help to narrow the user down

    Ya, I bust people for using an sql account by getting the host name which is assigned to a particular user where I work.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply