Web service thread doesn’t inherit security context
Posted on 2004-08-24
Using .NET 1.1 – Windows 2003.
I've created a web service that spawns a thread. The service needs access to other servers, so I've created a user (lets call it "ServiceUser") with privileges and assigned the "anonymous user" in IIS to that user. I then added <identity impersonate="true"/> to the web.config of my web service.
From inside any of the functions of the web service I make a call to WindowsIdentity.GetCurrent (which displays the current user), it returns "ServiceUser". Great! If I spawn a thread from that function and launch it, then I call WindowsIdentity.GetCurrent inside that spawned thread, it returns "ASPNET".
All I want is for the thread to have the same security context as it's calling function. I've read solutions that require "ServiceUser" or ASPNET to have "Act as part of operating system" checked. Anyone have a more elegant solution?