Capture User''s Window Log on from T-Sql??

  •  I am working on a DB that will have a Default login account and will be accessed by 50 + users.  Around 10 users will be able to update the DB and will be managed on the front end.  I would like to be able to capture their Windows Login Name with an Insert/Update trigger and update an EditBy field.   The DBA doesn’t want to add all of the users, so that is why I am trying to make it work with the default account.

     

    Thanks

    fryere

  • Not real sure what you want to do, but check out these commands (from BOL). Perhaps they'll give you some of what you're looking for!

    SELECT SYSTEM_USER

    GO

    SELECT HOST_NAME()

    GO

    SELECT USER_NAME()

    GO

  • John,

    That gives me the database user, which all of the users will be using the same one.  I would like to capture their Windows Login Name so the DB can somewhat track who is editing the records.

    I can pass in the user name from the front end, but I was hoping SQL Server had an easy way to capture it.

     

    fryere

  • (Try running the samples again--I edited my last post)

  • John,  

    Host_Name() comes the closest, but it only gives me the PC name.

    Thanks for the responses.

    fryere

  •   >> The DBA doesn’t want to add all of the users <<

    If that is the reason you should think about using WINDOWS INTEGRATED SECURITY. Then just grant access to one windows group and make your users part of that group. Once you have that, suser_sname() will return exactly what you want.

    HTH


    * Noel

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

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