Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Undo Method
Collapse the table of content
Expand the table of content

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()

ExceptionCondition
SecurityException

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.

ImpersonationCtx->Undo();

.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
Show:
© 2015 Microsoft