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
}
}
>I have an ASP.NET web service whose Web.Config is set to use impersonation
>
[quoted text clipped - 9 lines]
> System.Threading.Thread(AddressOf reportManager.RunReport)
> worker.Start()
Patrick - 17 Feb 2006 10:24 GMT
my reportManager.RunReport is in a *different* class from the web method that
spawn it off. Hence, it won't be able to reference mThreadIdentity.
In addition, could you clarify the definition of [DllImport("advapi32")]
static extern bool RevertToSelf(); .e.g. what is the EntryPoint?
> you need to pass the creditials of the current thread to the new created
> thread.
[quoted text clipped - 46 lines]
> > System.Threading.Thread(AddressOf reportManager.RunReport)
> > worker.Start()