WindowsImpersonationContext.Undo 方法

定义

将用户上下文还原到由此对象表示的Windows用户。

public:
 void Undo();
public void Undo();
member this.Undo : unit -> unit
Public Sub Undo ()

例外

除了将标识还原为自我之外,还尝试使用此方法。

示例

以下示例演示如何使用指定的用户令牌模拟Windows标识。

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();
Dim ImpersonationCtx As WindowsImpersonationContext = _
   WindowsIdentity.Impersonate(userToken)
'Do something under the context of the impersonated user. 
ImpersonationCtx.Undo()

适用于