GetTokenInformation
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 |
); |
|
Parameters
TokenHandle
Identifies an
access token from which information is retrieved.
TokenInformationClass
Specifies a
variable of the TOKEN_INFORMATION_CLASS
TokenInformation
Points to a
buffer the function fills with the requested information. The structure put
into this buffer depends upon the type of information specified by the TokenInformationClass
parameter, as shown in the following list:
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.
TokenInformationLength
Specifies the
size, in bytes, of the buffer pointed to by the TokenInformation
parameter.
ReturnLength
Points to a
variable receiving the actual number of bytes needed for the buffer pointed to
by the TokenInformation parameter. If this value is larger than the
value specified in the TokenInformationLength parameter, the function
fails and stores no data in the buffer.
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.
Return Values
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
See Also