Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Get Loged in user in windows in SQL

Author  Topic 

MehdiEnt
Starting Member

1 Post

Posted - 2007-04-12 : 20:33:04
Hi Guys,

How can I get the current loged in UserName in windows in MSSQL?

The problem is:

Users login into their PC (Windows Login)
Enter a URL of the intranet application
They would then be able to access the web base application (Intranet)
The web application has a string connection to make a connection to the database
I want to have a Trigger for my "products" table so if the table is modified (Insert/Update) all those changes be entered in "products_Audit" table
Now on "products_Audit" table I have a field "ChangedBy" where I want to store the windows loged in User Name (SYSTEM_USER just return the Username for the SQL connection that the web application use)
I would really appreciate all your help and suggestions.

Regards,
Mehdi

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2007-04-12 : 21:38:46
You can only get the Windows logged on user if your connetion string is using a trusted connection. A possible option is you can retrieve and send the windows logged in name to sql via your application, which is really the only option unless you change your connection string so it's not using sql autentication mode.
Go to Top of Page
   

- Advertisement -