you need to pass the creditials of the current thread to the new created
thread.
class foo()
{
private WindowsIdentity mThreadIdentity = null;
[DllImport("advapi32")] static extern bool RevertToSelf();
public void StartThread()
{
// setup thread
ThreadStart ts = new ThreadStart(RunReport);
Thread t = new Thread(ts);
mThreadIdentity = WindowsIdentity.GetCurrent();
// drop any impersonation
RevertToSelf();
// start thread
t.Start();
// restore thread identity
mThreadIdentity.Impersonate();
}
private void RunReport()
{
mThreadIdentity.Impersonate();
// do whatever
}
}
"Patrick" <pa**@reply.newsgroup.msn.com> wrote in message
news:B3**********************************@microsof t.com...
I have an ASP.NET web service whose Web.Config is set to use impersonation
<authentication mode="Windows" />
<identity impersonate="true" />
Within a Web Method, I want to use Multi-threading to spawn off an
asynchronous process, as it takes quite long to return. How could I get
the
worker thread to runas the same impersonated user on ASP.NET?
Dim worker As System.Threading.Thread = New
System.Threading.Thread(AddressOf reportManager.RunReport)
worker.Start()