internal ImpersonationSuspendContext SuspendIfClient() { if (_mode == ImpersonationMode.Client) { ImpersonationSuspendContext ictx = new ImpersonationSuspendContext(); ictx.Suspend(); return(ictx); } else { return(ImpersonationSuspendContext.Empty); } }
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; } } }