Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The ImpersonateSelf function obtains an access token that impersonates the security context of the calling process. The token is assigned to the calling thread.
BOOL ImpersonateSelf(
[in] SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
);
[in] ImpersonationLevel
Specifies a SECURITY_IMPERSONATION_LEVEL enumerated type that supplies the impersonation level of the new token.
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.
The ImpersonateSelf function is used for tasks such as enabling a privilege for a single thread rather than for the entire process or for changing the default discretionary access control list (DACL) for a single thread.
The server can call the RevertToSelf function when the impersonation is complete.
For this function to succeed, the DACL protecting the process token must grant the TOKEN_DUPLICATE right to itself.
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps only] |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | securitybaseapi.h (include Windows.h) |
Library | Advapi32.lib |
DLL | Advapi32.dll |
Client/Server Access Control Functions
Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!