SQL server authentication using impersonation -
05-11-2009
, 04:02 AM
Hi,
I have a web server on a SBS 2003 box, and SQL server running on
seperate Windows Server 2003 box.
I want to impersonate the current user when executing SQL procedures.
The database filters rows depending on who the windows user is, so
it's important I forward the identity of the original user, and don't
use a generic one.
If i test the web application from my Visual Studio window (on a third
machine), then the authentication works fine, presumably because I'm
logged on as a user who has database admin permissions.
If I log on from another machine, the identity doesn't get forwarded.
The config file inludes:
<authentication mode="Windows"/>
<identity impersonate="true" />
The vb code includes:
Dim WinId As System.Security.Principal.IIdentity
Dim Wi As System.Security.Principal.WindowsIdentity
Dim Wic As
System.Security.Principal.WindowsImpersonationCont ext
WinId = HttpContext.Current.User.Identity
Wi = WinId
Wic = Wi.Impersonate()
But when I try opening the SQL connection
(Data.SqlClient.SqlConnection) then I get the error:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'
Any ideas please?
Thank you in advance |