Hello,
In my c# website I have set the <identity impersonate="true" /> in the web.config.
I am trying to start a thread in my web service in the following manner:
if (!isThreadRunning)
{
ThreadStart startThread = new ThreadStart(InvokeKeepAliveThread);
Thread keepAliveThread = new Thread(startThread);
keepAliveThread.IsBackground = bool.Parse("true");
keepAliveThread.Priority = ThreadPriority.Lowest;
keepAliveThread.Start();
}
}
public void InvokeKeepAliveThread()
{
while (true)
{
CheckExpiredLicenses();
Thread.Sleep(300000); // Check once in 5 minutes
}
}
Somehow on my computer it is working fine, but on the computer of my collegue he gets the error:
System.ComponentModel.Win32Exception: Access is denied
When I set impersonation to false in the web.config this part works, but I need to use impersonation somewhere else.
Therefor I was looking for a solution to disable impersonation temporary, to start the thread and then enable it again to use it in another part of the project.
Is there a way to disable impersonation for a while, or is there another solution?
Thanks in advance!