The AdjustTokenPrivileges function enables or disables privileges in the specified access token. Enabling or disabling privileges in an access token requires TOKEN_ADJUST_PRIVILEGES access.
BOOL AdjustTokenPrivileges(
HANDLE TokenHandle, |
// handle to token that contains privileges |
BOOL DisableAllPrivileges, |
// flag for disabling all privileges |
PTOKEN_PRIVILEGES NewState, |
// pointer to new privilege information |
DWORD BufferLength, |
// size, in bytes, of the PreviousState buffer |
PTOKEN_PRIVILEGES PreviousState, |
// receives original state of changed privileges |
PDWORD ReturnLength |
// receives required size of the PreviousState buffer |
); |
If DisableAllPrivileges is TRUE, the function ignores this parameter.
If you specify a buffer that is too small to receive the complete list of
modified privileges, the function fails and does not adjust any privileges. In
this case, the function sets the variable pointed to by the ReturnLength
parameter to the number of bytes required to hold the complete list of
modified privileges.
If the function succeeds, the return value is nonzero. To determine whether the function adjusted all of the specified privileges, call GetLastError, which returns one of the following values when the function succeeds:
Value |
Description |
ERROR_SUCCESS |
The function adjusted all specified privileges. |
ERROR_NOT_ALL_ASSIGNED |
The token does not have one or more of the privileges specified in the NewState parameter. The function may succeed with this error value even if no privileges were adjusted. The PreviousState parameter indicates the privileges that were adjusted. |
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The AdjustTokenPrivileges function cannot add new privileges to the access token. It can only enable or disable the token’s existing privileges. To determine the token’s privileges, call the GetTokenInformation function.
Note that the NewState parameter can specify privileges that the token does not have, without causing the function to fail. In this case, the function adjusts the privileges that the token does have, ignores the other privileges, and returns success. Call the GetLastError function to determine whether the function adjusted all of the specified privileges. The PreviousState parameter indicates the privileges that were adjusted.
The PreviousState parameter retrieves a TOKEN_PRIVILEGES structure containing the the original state of the adjusted privileges. To restore the original state, pass the PreviousState pointer as the NewState parameter in a subsequent call to the AdjustTokenPrivileges function
AdjustTokenGroups, GetTokenInformation, OpenProcessToken, OpenThreadToken, SetTokenInformation, TOKEN_PRIVILEGES
file: /Techref/os/win/api/win32/func/src/f01_16.htm, 7KB, , updated: 2000/4/7 11:19, local time: 2024/11/7 10:41,
18.220.209.64:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/techref/os/win/api/win32/func/src/f01_16.htm"> AdjustTokenPrivileges</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.