SetTokenInformation function (securitybaseapi.h)

The SetTokenInformation function sets various types of information for a specified access token. The information that this function sets replaces existing information. The calling process must have appropriate access rights to set the information.

Syntax

BOOL SetTokenInformation(
  [in] HANDLE                  TokenHandle,
  [in] TOKEN_INFORMATION_CLASS TokenInformationClass,
  [in] LPVOID                  TokenInformation,
  [in] DWORD                   TokenInformationLength
);

Parameters

[in] TokenHandle

A handle to the access token for which information is to be set.

[in] TokenInformationClass

A value from the TOKEN_INFORMATION_CLASS enumerated type that identifies the type of information the function sets. The valid values from TOKEN_INFORMATION_CLASS are described in the TokenInformation parameter.

[in] TokenInformation

A pointer to a buffer that contains the information set in the access token. The structure of this buffer depends on the type of information specified by the TokenInformationClass parameter.

[in] TokenInformationLength

Specifies the length, in bytes, of the buffer pointed to by TokenInformation.

Return value

If the function succeeds, the function returns nonzero.

If the function fails, it returns zero. To get extended error information, call GetLastError.

Remarks

To set privilege information, an application can call the AdjustTokenPrivileges function. To set a token's groups, an application can call the AdjustTokenGroups function.

Token-type information can be set only when an access token is created.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header securitybaseapi.h (include Windows.h)
Library Advapi32.lib
DLL Advapi32.dll

See also

Access Control Overview

AdjustTokenGroups

AdjustTokenPrivileges

Basic Access Control Functions

GetTokenInformation

OpenProcessToken

OpenThreadToken

TOKEN_DEFAULT_DACL

TOKEN_INFORMATION_CLASS

TOKEN_OWNER

TOKEN_PRIMARY_GROUP