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

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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft