Partager via


CAccessToken::Impersonate

Call this method to assign an impersonation CAccessToken to a thread.

bool Impersonate(
   HANDLE hThread = NULL
) const throw(...);

Parameters

  • hThread
    Handle to the impersonation token to assign to the thread. This handle must have been opened with TOKEN_IMPERSONATE access rights. If hThread is NULL, the method causes the thread to stop using an impersonation token.

Return Value

Returns true on success, false on failure.

Remarks

In debug builds, an assertion error will occur if CAccessToken does not have a valid pointer to a token.

The CAutoRevertImpersonation class can be used to automatically revert impersonated access tokens.

Requirements

Header: atlsecurity.h

See Also

Concepts

CAccessToken Class

CAccessToken Members