/// <summary>Reverts the user context to the Windows user represented by this object.</summary> /// <exception cref="T:System.Security.SecurityException">An attempt is made to use this method for any purpose other than to revert identity to self. </exception> public void Undo() { if (!WindowsImpersonationContext.RevertToSelf()) { WindowsImpersonationContext.CloseToken(this._token); throw new SecurityException("Couldn't switch back to original token."); } WindowsImpersonationContext.CloseToken(this._token); this.undo = true; GC.SuppressFinalize(this); }