D
Dave Mullen
I'm trying to access a SQL server from a thread started from an asp.net
application and get a "Cannot log into database as user null..." error. How
can I make the thread inherit the same identity as the calling process?
When I spin off the thread I have seen that it typically runs as NT
ANONYMOUS\SYSTEM (via
System.Security.Principal.WindowsIdentity.GetCurrent().Name). I have had
intermittent success
passing the token of the calling process and impersonating it in the called
process but once in a while hit an exception when trying to impersonate.
Web Config of calling process:
<authentication mode="Forms" >
<forms name="adAuthCookie" loginUrl="_mem_bin/formslogin.aspx"
protection="All" path="/" timeout="60" ></forms>
</authentication>
<identity impersonate="true" />
Web Site Directory Security of calling process is set to Anonymous Access.
Account used for anonymous access is a user w/ permissions to our SQL Server
db. Windows Integrated Authentication is also checked.
calling asynchronous process:
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf lfd.SubmitRequest),
System.Security.Principal.WindowsIdentity.GetCurrent().Token)
Impersonation Logic:
Sub SubmitRequest(ByVal Token As Object)
System.Security.Principal.WindowsIdentity.Impersonate(CType(Token,
System.IntPtr))
Thanks,
Dave
application and get a "Cannot log into database as user null..." error. How
can I make the thread inherit the same identity as the calling process?
When I spin off the thread I have seen that it typically runs as NT
ANONYMOUS\SYSTEM (via
System.Security.Principal.WindowsIdentity.GetCurrent().Name). I have had
intermittent success
passing the token of the calling process and impersonating it in the called
process but once in a while hit an exception when trying to impersonate.
Web Config of calling process:
<authentication mode="Forms" >
<forms name="adAuthCookie" loginUrl="_mem_bin/formslogin.aspx"
protection="All" path="/" timeout="60" ></forms>
</authentication>
<identity impersonate="true" />
Web Site Directory Security of calling process is set to Anonymous Access.
Account used for anonymous access is a user w/ permissions to our SQL Server
db. Windows Integrated Authentication is also checked.
calling asynchronous process:
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf lfd.SubmitRequest),
System.Security.Principal.WindowsIdentity.GetCurrent().Token)
Impersonation Logic:
Sub SubmitRequest(ByVal Token As Object)
System.Security.Principal.WindowsIdentity.Impersonate(CType(Token,
System.IntPtr))
Thanks,
Dave