This topic has not yet been rated - Rate this topic

SetTokenInformation function

Applies to: desktop apps only

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 WINAPI SetTokenInformation(
  __in  HANDLE TokenHandle,
  __in  TOKEN_INFORMATION_CLASS TokenInformationClass,
  __in  LPVOID TokenInformation,
  __in  DWORD TokenInformationLength
);

Parameters

TokenHandle [in]

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

TokenInformationClass [in]

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.

TokenInformation [in]

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.

TokenInformationLength [in]

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

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Winbase.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

See also

Access Control Overview
Basic Access Control Functions
AdjustTokenGroups
AdjustTokenPrivileges
GetTokenInformation
OpenProcessToken
OpenThreadToken
TOKEN_DEFAULT_DACL
TOKEN_INFORMATION_CLASS
TOKEN_OWNER
TOKEN_PRIMARY_GROUP

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Missing access right
Found on Windows Vista (at least) : TOKEN_ADJUST_DEFAULT is also needed for TokenSessionId (at least)