WindowsImpersonationContext.Undo Method

Definition

Reverts the user context to the Windows user represented by this object.

public void Undo ();

Exceptions

An attempt is made to use this method for any purpose other than to revert identity to self.

Examples

The following example shows how to impersonate a Windows identity using a specified user token.

WindowsImpersonationContext ImpersonationCtx = WindowsIdentity.Impersonate(userToken);
//Do something under the context of the impersonated user.
 ImpersonationCtx.Undo();

Applies to

Produs Versiuni
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1