Export (0) Print
Expand All

WindowsImpersonationContext.Undo Method

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

[Visual Basic]
Public Sub Undo()
public void Undo();
public: void Undo();
public function Undo();


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


[Visual Basic, C#, C++] The following example shows how to impersonate a Windows identity using a specified user token.

[Visual Basic] 
Dim ImpersonationCtx As WindowsImpersonationContext = _
'Do something under the context of the impersonated user. 

WindowsImpersonationContext ImpersonationCtx = WindowsIdentity.Impersonate(userToken); 
//Do something under the context of the impersonated user.

WindowsImpersonationContext* ImpersonationCtx = WindowsIdentity::Impersonate(userToken); 
//Do something under the context of the impersonated user.

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

WindowsImpersonationContext Class | WindowsImpersonationContext Members | System.Security.Principal Namespace

© 2014 Microsoft