Click or drag to resize
Xcalibur Systems LLC Logo

ProcessHelperDuplicateTokenEx Method

The DuplicateTokenEx function creates a new access token that duplicates an existing token. This function can create either a primary token or an impersonation token.

DuplicateTokenEx function


Namespace: Xcalibur.NativeMethods.V2.Processes
Assembly: Xcalibur.NativeMethods.V2 (in Xcalibur.NativeMethods.V2.dll) Version: 1.0.1.0
Syntax
[DllImportAttribute("advapi32.dll")]
public static bool DuplicateTokenEx(
	IntPtr existingTokenHandle,
	uint desiredAccess,
	ref SecurityAttributes tokenAttributes,
	int impersonationLevel,
	int tokenType,
	ref IntPtr duplicateTokenHandle
)

Parameters

existingTokenHandle  IntPtr
A handle to an access token opened with access.
desiredAccess  UInt32
Specifies the requested access rights for the new token. The DuplicateTokenEx function compares the requested access rights with the existing token's discretionary access control list (DACL) to determine which rights are granted or denied.
tokenAttributes  SecurityAttributes
A pointer to a structure that specifies a security descriptor for the new token and determines whether child processes can inherit the token. If tokenAttributes is NULL, the token gets a default security descriptor and the handle cannot be inherited. If the security descriptor contains a system access control list (SACL), the token gets ACCESS_SYSTEM_SECURITY access right, even if it was not requested in desiredAccess.
impersonationLevel  Int32
Specifies a value from the enumeration that indicates the impersonation level of the new token.
tokenType  Int32
Specifies one of the following values from the enumeration.
duplicateTokenHandle  IntPtr
A pointer to a HANDLE variable that receives the new token.

Return Value

Boolean
If the function fails, the return value is zero. To get extended error information, call .
See Also