"There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies and the other is to make it so complicated that there are no obvious deficiencies". C.A.R. Hoare
//show who we are running as - should be customuser
System.Security.Principal.WindowsIdentity ident = System.Security.Principal.WindowsIdentity.GetCurrent(); Debug.WriteLine("Page_Load: " + ident.Name); //retrieve the security token , and cache it in a static variable so it can be used by the other thread. _intsecuritytoken = System.Security.Principal.WindowsIdentity.GetCurrent().Token; //create the batch request object and submit a request
AsyncThreadRequest request = new AsyncThreadRequest(); request.Add(new SendReportRequestDelegate(this.FuncToRun)); request.SubmitRequest(true, 20);
//show who we are running as (should be ASPNet)%
System.Security.Principal.WindowsIdentity ident = System.Security.Principal.WindowsIdentity.GetCurrent(); Debug.WriteLine("FuncToRun() - Before Impersonation: " + ident.Name);
//create a new windows identity, with the cached security token from customuser System.Security.Principal.WindowsIdentity windid = new System.Security.Principal.WindowsIdentity(_intsecuritytoken); windid.Impersonate();
ident = System.Security.Principal.WindowsIdentity.GetCurrent(); Debug.WriteLine("FuncToRun() - Before Impersonation: " + ident.Name);
Posted in Code |Comments [0]
Sysknowlogy