AdvApi32OpenThreadToken(IntPtr, TokenAccess, Boolean, IntPtr) Method

Opens the access token associated with a thread.

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 OpenThreadToken(
	IntPtr threadHandle,
	TokenAccess desiredAccess,
	bool openAsSelf,
	ref IntPtr refTokenHandle
)

Parameters

threadHandle  IntPtr
A handle To the thread whose access token Is opened.
desiredAccess  TokenAccess
Specifies an access mask that specifies the requested types of access to the access token.

These requested access types are compared with the discretionary access control list (DACL) of the token to determine which accesses are granted or denied.

openAsSelf  Boolean
if the access check is to be made against the process-level security context.

if the access check is to be made against the current security context of the thread calling the OpenThreadToken(IntPtr, TokenAccess, Boolean, IntPtr) function.

The openAsSelf parameter allows the caller of this function to open the access token of a specified thread when the caller is impersonating a token at SecurityIdentification level. Without this parameter, the calling thread cannot open the access token on the specified thread because it is impossible to open executive-level objects by using the SecurityIdentification impersonation level.

refTokenHandle  IntPtr
A IntPtr handle that identifies the newly opened access token when the function returns.

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