Click or drag to resize
Xcalibur Systems LLC Logo

ProcessHelperAdjustTokenPrivileges(IntPtr, Boolean, TokenPrivileges, UInt32, TokenPrivileges, UInt32) Method

The AdjustTokenPrivileges function enables or disables privileges in the specified access token. Enabling or disabling privileges in an access token requires access.

AdjustTokenPrivileges function


Namespace: Xcalibur.NativeMethods.V2.Processes
Assembly: Xcalibur.NativeMethods.V2 (in Xcalibur.NativeMethods.V2.dll) Version: 1.0.1.0
Syntax
[DllImportAttribute("advapi32.dll", SetLastError = true)]
public static bool AdjustTokenPrivileges(
	IntPtr tokenHandle,
	bool disableAllPrivileges,
	ref TokenPrivileges newState,
	uint bufferLength,
	out TokenPrivileges previousState,
	out uint returnLength
)

Parameters

tokenHandle  IntPtr
A handle to the access token that contains the privileges to be modified. The handle must have access to the token. If the PreviousState parameter is not NULL, the handle must also have access.
disableAllPrivileges  Boolean
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  TokenPrivileges
A pointer to a structure that specifies an array of privileges and their attributes. If the disableAllPrivileges parameter is FALSE, the AdjustTokenPrivileges function enables, disables, or removes these privileges for the token. The following table describes the action taken by the AdjustTokenPrivileges function, based on the privilege attribute.
bufferLength  UInt32
Specifies the size, in bytes, of the buffer pointed to by the previousState parameter. This parameter can be zero if the previousState parameter is NULL.
previousState  TokenPrivileges
A pointer to a buffer that the function fills with a structure that contains the previous state of any privileges that the function modifies. That is, if a privilege has been modified by this function, the privilege and its previous state are contained in the structure referenced by previousState. If the PrivilegeCount member of is zero, then no privileges have been changed by this function. This parameter can be NULL.
returnLength  UInt32
A 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 Value

Boolean
If the function succeeds, the return value is nonzero. To determine whether the function adjusted all of the specified privileges, call .
See Also