Platform SDK: Access Control |
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( SECURITY_IMPERSONATION_LEVEL ImpersonationLevel // impersonation level );
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 for a single thread.
The server can call the RevertToSelf function when the impersonation is complete.
Windows NT/2000: Requires Windows NT 3.1 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Advapi32.lib.
Client/Server Access Control Overview, Client/Server Access Control Functions, DuplicateToken, ImpersonateNamedPipeClient, RevertToSelf, SECURITY_IMPERSONATION_LEVEL