AdvApi32DuplicateToken Method

Creates a new access token that duplicates one already in existence.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("AdvApi32.dll", SetLastError = true)]
public static bool DuplicateToken(
	IntPtr tokenHandle,
	SecurityImpersonationLevel impersonationLevel,
	ref IntPtr refDuplicateTokenHandle
)

Parameters

tokenHandle  IntPtr
A handle to an access token opened with Duplicate access.
impersonationLevel  SecurityImpersonationLevel
A SecurityImpersonationLevel enumerated type that supplies the impersonation level of the new token.
refDuplicateTokenHandle  IntPtr
A pointer to a variable that receives a handle to the duplicate token.

This handle has Impersonate and Query access to the new token.

When you have finished using the new token, call the CloseHandle(IntPtr) function to close the token handle.

Return Value

Boolean
If the function succeeds, the return value is .

If the function fails, the return value is .

To get extended error information, call GetLastWin32Error.

Remarks

See Also