Exemplo n.º 1
0
 internal ImpersonationSuspendContext SuspendIfClient()
 {
     if (_mode == ImpersonationMode.Client)
     {
         ImpersonationSuspendContext ictx = new  ImpersonationSuspendContext();
         ictx.Suspend();
         return(ictx);
     }
     else
     {
         return(ImpersonationSuspendContext.Empty);
     }
 }
Exemplo n.º 2
0
 internal void ReimpersonateIfSuspended()
 {
     if (_mode == ImpersonationMode.Client)
     {
         if (!ImpersonationSuspendContext.IsImpersonating())
         {
             int rc = UnsafeNativeMethods.SetThreadToken((IntPtr)0, _token);
             if (rc == 0)
             {
                 throw new HttpException(HttpRuntime.FormatResourceString(SR.Cannot_impersonate));
             }
             _reimpersonating = true;
         }
     }
 }