April 17, 2013 at 5:42 pm
Hi all,
I'm having hard time to figure out a way to create a DDL trigger while capturing the original user name who initiated a connection. ASP.NET application is running on IIS server and AppPool is configured with a shared account to make a connection to SQL. So, from the SQL server side we only see this shared account.
My problem is, how to know who actually initiated the connection originally. ORIGINAL_LOGIN() won't work since IIS is using a shared account so wonder if there's a way from SQL side.
Anyone knows if this is even possible? I don't think it is but wonder if there's a way, hope...
Thanks~
April 17, 2013 at 6:16 pm
I could be wrong but I don't believe it's possible unless the app captures the login and somehow passes it along. SET CONTEXT_INFO may prove useful in this area because it's good for the scope of the session.
Do a search for "Using Session Context Information" in Books Online (ad, perhaps, on the Web) for more information. Here's a the first hit I got on Google for the phrase.
http://msdn.microsoft.com/en-us/library/ms189252(v=sql.105).aspx
--Jeff Moden
Change is inevitable... Change for the better is not.
April 17, 2013 at 9:19 pm
Thanks Jeff.
It seems like there's a way if we use CONTEXT_INFO() function, I'll do more research on it.
Thanks again~
April 17, 2013 at 9:27 pm
You can use SYSTEM_USER function in SQL Server. Please refer to the below link.
April 18, 2013 at 1:50 pm
Thanks jay81 but SYSTEM_USER won't work since it'll return current login info but we're using one shared account for all users.
As Jeff suggested, CONTEXT_INFO() might work that I'm playing around now.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply