RevertToSelf function
The RevertToSelf function reverts the security context of the calling thread to the security context of the thread that created the calling thread.
Syntax
BOOL RevertToSelf();
Parameters
This function does not take any parameters.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
A thread can impersonate another security context by calling functions such as
ImpersonateAnonymousToken,
ImpersonateClientOfHandle,
ImpersonateLoggedOnUser,
ImpersonateThread, or
SetThreadToken.
After the thread has finished impersonating the other security context, it should call
RevertToSelf to revert to its original security context.
Calling RevertToSelf restores the thread's original access token.
If the thread was not impersonating another security context,
RevertToSelf has no effect.
It is important to call RevertToSelf when impersonation is no longer
needed to prevent potential security vulnerabilities.
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows XP [desktop apps only] |
| Minimum supported server | Windows Server 2003 [desktop apps only] |
| Header | Securitybaseapi.h (include Securitybaseapi.h) |
| Library | Advapi32.lib |
| DLL | Advapi32.dll |