Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get webuser login from session variable
Message
From
11/08/2012 13:40:34
 
 
To
11/08/2012 13:03:41
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01550318
Message ID:
01550340
Views:
47
>>>Hi all, please I need to know how to get the logged user for my audit procedure when changing data on tables.
>>>T.I.A.
>>
>>>http://msdn.microsoft.com/en-us/library/ms187934.aspx
>>
>>>http://msdn.microsoft.com/en-us/library/ms179930.aspx
>>
>>Thank you Viv Phillips, but I did the question wrong, I mean a logged user from asp web page, I created a session variable with that name, then I need anyplace in the program audit with that session variable, because I'm using a generic user to connect.
>
>>Hmm. If you just want the value from a session variable then something like :
>
>>string s = (string)(Session["UserName"]);
>
>>but I've a feeling I still have not understood what you are asking :-{
>
>Yes that way I can get the session in asp.net c# or Vb, but after logged used in asp.net web page, I save the username with session["usuario"]="xxxuser"; Then I want that everytime this user perform an insert, update, delete on my sqlserver database, In the trigger I could "read" that session["usuario"] is the "xxxuser" to put it in the trigger as user that is performing changes.
>I'm using an impersonate user, that xxxuser is conecting to database using a generic database user not sqlserver user, thats why I cannot use select SUSER_NAME()

If your insert/delete/update operations are done via an SP you may be able to use context info (http://msdn.microsoft.com/en-us/library/ms189252(v=sql.105).aspx).

But my knowledge of SQL is sketchy to say the least - someone else might be able to give a more definitive answer
Previous
Reply
Map
View

Click here to load this message in the networking platform