You must declare the RevertToSelf function and the token variable as the class members:
In the delegate function you must impersonate the identity:
WindowsIdentity wi =
new WindowsIdentity(token);WindowsImpersonationContext ctx = wi.Impersonate();
HtH,
Andrea
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Stan" <nos...@yahoo.com> wrote in message
news:5E8DDD8C-4C00-4AE4...@microsoft.com...
> Actually, it works even withoug RevertToSelf. Here is the snippet:
>
> Main class:
> =======
> DbReader dr = new DbReader (WindowsIdentity.GetCurrent().Token);
> //RevertToSelf();
> Thread DbThread = new Thread(new ThreadStart(dr.GetDataFromDb));
> DbThread.Start();
> Response.Redirect ("Wait.aspx");
> =======
>
> Delegate:
> ======
> class DbReader
> {
> protected IntPtr token;
>
> public DbReader (IntPtr token)
> {
> this.token = token;
> }
>
> public void GetDataFromDb()
> {
> WindowsIdentity wi = new WindowsIdentity (token);
> WindowsImpersonationContext ctx = wi.Impersonate();
>
> // Get data...
> }
> }
>
> ==========
>
> Do I need RevertToSelf()?
>
> Thanks a lot for your post, it really helped
>
> -Stan