AdvApi32OpenThreadToken(SafeHandle, TokenAccess, Boolean, IntPtr) Method
Opens the access token associated with a thread.
Namespace: DevCase.Win32.NativeMethodsAssembly: 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(
SafeHandle threadHandle,
TokenAccess desiredAccess,
bool openAsSelf,
ref IntPtr refTokenHandle
)
<DllImportAttribute("AdvApi32.dll", SetLastError := true>]
Public Shared Function OpenThreadToken (
threadHandle As SafeHandle,
desiredAccess As TokenAccess,
openAsSelf As Boolean,
ByRef refTokenHandle As IntPtr
) As Boolean
Dim threadHandle As SafeHandle
Dim desiredAccess As TokenAccess
Dim openAsSelf As Boolean
Dim refTokenHandle As IntPtr
Dim returnValue As Boolean
returnValue = AdvApi32.OpenThreadToken(threadHandle,
desiredAccess, openAsSelf, refTokenHandle)
public:
[DllImportAttribute(L"AdvApi32.dll", SetLastError = true)]
static bool OpenThreadToken(
SafeHandle^ threadHandle,
TokenAccess desiredAccess,
bool openAsSelf,
IntPtr% refTokenHandle
)
[<DllImportAttribute("AdvApi32.dll", SetLastError = true)>]
static member OpenThreadToken :
threadHandle : SafeHandle *
desiredAccess : TokenAccess *
openAsSelf : bool *
refTokenHandle : IntPtr byref -> bool
No code example is currently available or this language may not be supported.
- threadHandle SafeHandle
-
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.
Boolean
If the function succeeds, the return value is
.
If the function fails, the return value is
.
To get extended error information, call
GetLastWin32Error.