WindowsImpersonationContext.Undo Metod

Definition

Återställer användarkontexten till den Windows användare som representeras av det här objektet.

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

Undantag

Ett försök görs att använda den här metoden för något annat syfte än att återställa identiteten till sig själv.

Exempel

I följande exempel visas hur du personifierar en Windows identitet med en angiven användartoken.

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

Gäller för