Export (0) Print
Expand All

WindowsImpersonationContext.Undo Method

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

Namespace:  System.Security.Principal
Assembly:  mscorlib (in mscorlib.dll)

public void Undo()


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

Notes to Implementers

Because Microsoft Windows 98 and Windows Millennium Edition platforms do not have users or user tokens, impersonation cannot take place on those platforms.

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft