WindowsImpersonationContext.Undo 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將使用者上下文還原為由此物件代表的 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()