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 Sub Undo

Exception Condition
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.

Dim ImpersonationCtx As WindowsImpersonationContext = _
   WindowsIdentity.Impersonate(userToken)
'Do something under the context of the impersonated user. 
ImpersonationCtx.Undo()

.NET Framework
Available since 1.1
Return to top
Show: