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

适用于