The GetTokenInformation function retrieves a specified type of information about an access token. The calling process must have appropriate access rights to obtain the information.
BOOL GetTokenInformation(
HANDLE TokenHandle, |
// handle of access token |
TOKEN_INFORMATION_CLASS TokenInformationClass, |
// type of information to retrieve |
LPVOID TokenInformation, |
// address of retrieved information |
DWORD TokenInformationLength, |
// size of information buffer |
PDWORD ReturnLength |
// address of required buffer size |
); |
Token Information Class |
Structure Returned |
TokenUser |
TOKEN_USER structure. TOKEN_QUERY access is needed to retrieve this information. |
TokenGroups |
TOKEN_GROUPS structure. TOKEN_QUERY access is needed to retrieve this information. |
TokenPrivileges |
TOKEN_PRIVILEGES structure. TOKEN_QUERY access is needed to retrieve this information. |
TokenOwner |
TOKEN_OWNER structure. TOKEN_QUERY access is needed to retrieve this information. |
TokenPrimaryGroup |
TOKEN_PRIMARY_GROUP structure. TOKEN_QUERY access is needed to retrieve this information. |
TokenDefaultDacl |
TOKEN_DEFAULT_DACL structure. TOKEN_QUERY access is needed to retrieve this information. |
TokenSource |
TOKEN_SOURCE structure. TOKEN_QUERY_SOURCE access is needed to retrieve this information. |
TokenType |
TOKEN_TYPE enumerated type. TOKEN_QUERY access is needed to retrieve this information. |
TokenImpersonationLevel |
SECURITY_IMPERSONATION_LEVEL enumerated type. TOKEN_QUERY access is needed to retrieve this information about a token. If the access token is not an impersonation token, the function fails. |
TokenStatistics |
TOKEN_STATISTICS structure. TOKEN_QUERY access is needed to retrieve this information. |
The formats for the retrieved structures and enumerated types are listed in
the following Remarks section.
If the value of the TokenInformationClass parameter is TokenDefaultDacl and the token has no default access-control list, the function sets the variable pointed to by ReturnLength to zero and stores no data in the buffer.
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.
AdjustTokenGroups, AdjustTokenPrivileges, OpenProcessToken, OpenThreadToken, SetTokenInformation, SECURITY_IMPERSONATION_LEVEL, TOKEN_DEFAULT_DACL, TOKEN_GROUPS, TOKEN_INFORMATION_CLASS, TOKEN_OWNER, TOKEN_PRIMARY_GROUP, TOKEN_PRIVILEGES, TOKEN_SOURCE, TOKEN_STATISTICS, TOKEN_TYPE, TOKEN_USER