예제 #1
0
        public void Undo()
        {
            int hr = 0;

            if (m_safeTokenHandle.IsInvalid)   // the thread was not initially impersonating
            {
                hr = Win32.RevertToSelf();
                if (hr < 0)
                {
                    Environment.FailFast(Win32Native.GetMessage(hr));
                }
            }
            else
            {
                hr = Win32.RevertToSelf();
                if (hr < 0)
                {
                    Environment.FailFast(Win32Native.GetMessage(hr));
                }
                hr = Win32.ImpersonateLoggedOnUser(m_safeTokenHandle);
                if (hr < 0)
                {
                    throw new SecurityException(Win32Native.GetMessage(hr));
                }
            }
            WindowsIdentity.UpdateThreadWI(m_wi);
            if (m_fsd != null)
            {
                m_fsd.SetTokenHandles(null, null);
            }
        }
        public void Undo()
        {
            int errorCode = 0;

            if (this.m_safeTokenHandle.IsInvalid)
            {
                errorCode = Win32.RevertToSelf();
                if (errorCode < 0)
                {
                    Environment.FailFast(Win32Native.GetMessage(errorCode));
                }
            }
            else
            {
                errorCode = Win32.RevertToSelf();
                if (errorCode < 0)
                {
                    Environment.FailFast(Win32Native.GetMessage(errorCode));
                }
                errorCode = Win32.ImpersonateLoggedOnUser(this.m_safeTokenHandle);
                if (errorCode < 0)
                {
                    throw new SecurityException(Win32Native.GetMessage(errorCode));
                }
            }
            WindowsIdentity.UpdateThreadWI(this.m_wi);
            if (this.m_fsd != null)
            {
                this.m_fsd.SetTokenHandles(null, null);
            }
        }
예제 #3
0
 public void Undo()
 {
     if (this.m_safeTokenHandle.IsInvalid)
     {
         int self = System.Security.Principal.Win32.RevertToSelf();
         if (self < 0)
         {
             Environment.FailFast(Win32Native.GetMessage(self));
         }
     }
     else
     {
         int self = System.Security.Principal.Win32.RevertToSelf();
         if (self < 0)
         {
             Environment.FailFast(Win32Native.GetMessage(self));
         }
         int errorCode = System.Security.Principal.Win32.ImpersonateLoggedOnUser(this.m_safeTokenHandle);
         if (errorCode < 0)
         {
             throw new SecurityException(Win32Native.GetMessage(errorCode));
         }
     }
     WindowsIdentity.UpdateThreadWI(this.m_wi);
     if (this.m_fsd == null)
     {
         return;
     }
     this.m_fsd.SetTokenHandles((SafeAccessTokenHandle)null, (SafeAccessTokenHandle)null);
 }