How do I get a .net web service call to stop impersonating to perform a task
I have a .net web service that runs with windows authentication and impersonation set to true. When the app goes to connect to the database however it needs to stop impersonating and run as the service account for the application pool.
My understanding has always been that the way to stop impersonation I would run the following code.
But for some reason when I run my code it never stops impersonating the calling user but continues as that user and fails to connect to the sql db which is using integrated security and only the service account has db access.
What am I missing here to get this to work properly?
It seems that the method I was using is fine. The error was a problem with the sql connection and the assumption that it was Impersonation that was failing. I was confirming my assumption by using the wrong check to verify the identity. The code in my original question does in fact work.
Asked in February 2016Viewed 1,050 timesVoted 12Answered 1 times