AdvApi32ImpersonateLoggedOnUser Method
Lets the calling thread impersonate the security context of a logged-on user.
The user is represented by a token handle.
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", ExactSpelling = true, SetLastError = true)]
public static bool ImpersonateLoggedOnUser(
IntPtr hToken
)
<DllImportAttribute("AdvApi32.dll", ExactSpelling := true, SetLastError := true>]
Public Shared Function ImpersonateLoggedOnUser (
hToken As IntPtr
) As Boolean
Dim hToken As IntPtr
Dim returnValue As Boolean
returnValue = AdvApi32.ImpersonateLoggedOnUser(hToken)
public:
[DllImportAttribute(L"AdvApi32.dll", ExactSpelling = true, SetLastError = true)]
static bool ImpersonateLoggedOnUser(
IntPtr hToken
)
[<DllImportAttribute("AdvApi32.dll", ExactSpelling = true, SetLastError = true)>]
static member ImpersonateLoggedOnUser :
hToken : IntPtr -> bool
No code example is currently available or this language may not be supported.
- hToken IntPtr
-
A handle to a primary or impersonation access token that represents a logged-on user.
This can be a token handle returned by a call to LogonUser, CreateRestrictedToken,
DuplicateToken(IntPtr, SecurityImpersonationLevel, IntPtr), DuplicateTokenEx(IntPtr, TokenAccess, SecurityAttributes, SecurityImpersonationLevel, TokenType, IntPtr),
OpenProcessToken(SafeProcessHandle, TokenAccess, IntPtr), or OpenThreadToken(IntPtr, TokenAccess, Boolean, IntPtr) functions.
If hToken is a handle to a primary token,
the token must have Query and Duplicate access.
If hToken is a handle to an impersonation token,
the token must have Query and Impersonate access.
Boolean
If the function succeeds, the return value is
.
If the function fails, the return value is
.