|
Overview |
|
|
|
Group |
|
|
|
Quick Info
Windows NT
| Yes
| Win95
| No
| Win32s
| No
| Import Library
| advapi32.lib
| Header File
| winbase.h
| Unicode
| No
| Platform Notes
| None
|
|
|
AdjustTokenPrivileges
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
| );
|
|
Parameters
TokenHandle
Identifies the access token that contains the privileges to be modified.
DisableAllPrivileges
Specifies whether the function disables all of the token's privileges. If this
value is TRUE, the function disables all privileges and ignores the NewState parameter. If it is FALSE, the function modifies privileges based on the
information pointed to by the NewState parameter.
NewState
Pointer to a TOKEN_PRIVILEGES structure that specifies an array of privileges and their attributes. If the DisableAllPrivileges parameter is FALSE, AdjustTokenPrivileges enables or disables these privileges for the token. If you set the
SE_PRIVILEGE_ENABLED attribute for a privilege, the function enables that privilege;
otherwise, it disables the privilege.
If DisableAllPrivileges is TRUE, the function ignores this parameter.
BufferLength
Specifies the size, in bytes, of the buffer pointed to by the PreviousState parameter. This parameter can be NULL if the PreviousState parameter is NULL.
PreviousState
Pointer to a buffer that the function fills with a TOKEN_PRIVILEGES structure containing the previous state of any privileges the function
modifies. The token must be open for TOKEN_QUERY access to use this parameter. This
parameter can be NULL.
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.
ReturnLength
Pointer to a variable that receives the required size, in bytes, of the buffer
pointed to by the PreviousState parameter. This parameter can be NULL if PreviousState is NULL.
Return Values
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.
Remarks
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
See Also
AdjustTokenGroups, GetTokenInformation, OpenProcessToken, OpenThreadToken, SetTokenInformation, TOKEN_PRIVILEGES
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|