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)
 Windows username

Author  Topic 

sboyer
Starting Member

4 Posts

Posted - 2008-04-25 : 10:06:03
Hi all,
I want create a trigger that will log all modification to a table.
I need to identify the username that modified the data.
Here is my problem :
- they are connected to a Terminal Server so stationName il always TSName
- They are using an application I cannot modify that always use the same login information using SQL authenticationMode

So I need to be able to get their Windows session Username.

Is there any way I can do that in my trigger ?

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-25 : 10:07:20
Try SUSER_SNAME() etc...



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sboyer
Starting Member

4 Posts

Posted - 2008-04-25 : 10:13:22
doesnt work, SUSER_Sname() gives me the SQL login used, but this is always the same.

Let say I m connecting using SQL authentication and User "Heat" and I m updating one row of Table "Table1". My windows session is with user "seb\mydomain", in the trigger on "Table1" I want to retreive "seb\mydomain" to put it in my log table. How can I do that ?

thx
Seb.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-25 : 10:27:06
If you use SSPI and group security you will get your result.
If you connect to databas with fixed username in connection string, there is no way unleass client application provides network user name to database.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sboyer
Starting Member

4 Posts

Posted - 2008-04-25 : 10:32:06
quote:
Originally posted by Peso

If you use SSPI and group security you will get your result.
If you connect to databas with fixed username in connection string, there is no way unleass client application provides network user name to database.



E 12°55'05.25"
N 56°04'39.16"




This exactly it, but I have on control over the client application, so I cannot modify it. Maybe can I create a dll that will give me the windows session information and call it from the trigger using a stored procedure ?
Thx
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-25 : 10:41:41
No, it will not work.
The SQL Server would not know which context (user login) to search.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -