WindowsImpersonationContext.Undo 方法

定義

將使用者內容還原成由這個物件表示的 Windows 使用者。

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

例外狀況

為了將識別還原成本身以外的其他因素而嘗試使用這個方法。

範例

下列範例示範如何使用指定的使用者 token 模擬 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()

適用於