|
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.ProcessesAssembly: 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
)
<DllImportAttribute("advapi32.dll">]
Public Shared Function DuplicateTokenEx (
existingTokenHandle As IntPtr,
desiredAccess As UInteger,
ByRef tokenAttributes As SecurityAttributes,
impersonationLevel As Integer,
tokenType As Integer,
ByRef duplicateTokenHandle As IntPtr
) As Boolean
public:
[DllImportAttribute(L"advapi32.dll")]
static bool DuplicateTokenEx(
IntPtr existingTokenHandle,
unsigned int desiredAccess,
SecurityAttributes% tokenAttributes,
int impersonationLevel,
int tokenType,
IntPtr% duplicateTokenHandle
)
[<DllImportAttribute("advapi32.dll")>]
static member DuplicateTokenEx :
existingTokenHandle : IntPtr *
desiredAccess : uint32 *
tokenAttributes : SecurityAttributes byref *
impersonationLevel : int *
tokenType : int *
duplicateTokenHandle : IntPtr byref -> bool
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
BooleanIf the function fails, the return value is zero. To get extended error
information, call .
See Also