語言

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

適用於