AdvApi32ImpersonateLoggedOnUser Method

Lets the calling thread impersonate the security context of a logged-on user. The user is represented by a token handle.

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", ExactSpelling = true, SetLastError = true)]
public static bool ImpersonateLoggedOnUser(
	IntPtr hToken
)

Parameters

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.

Return Value

Boolean
If the function succeeds, the return value is .

If the function fails, the return value is .

Remarks

See Also