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 ()
public void Undo ()
public function Undo ()
Not applicable.

Exception typeCondition

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


WindowsImpersonationContext impersonationCtx = 
    WindowsIdentity.Impersonate(userToken);

//Do something under the context of the impersonated user.
impersonationCtx.Undo();

Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft