_Security__ImpersonateSelf
Obtains an access token that impersonates the calling process security context
#include <Security.au3>
_Security__ImpersonateSelf([$iLevel = $SECURITYIMPERSONATION])
Параметры
$iLevel | [необязательный] Impersonation level of the new token: $SECURITYANONYMOUS. The server process cannot obtain identification information about the client, and it cannot impersonate the client. $SECURITYIDENTIFICATION. The server process can obtain information about the client, such as security identifiers and privileges, but it cannot impersonate the client. $SECURITYIMPERSONATION. The server process can impersonate the clients security context on its local system. The server cannot impersonate the client on remote systems. $SECURITYDELEGATION. The server process can impersonate the client's security context on remote systems. |
Возвращаемое значение
Успех: | Возвращает True |
Ошибка: | Возвращает False |
См. также
_Security__OpenThreadTokenExСм. также
Искать ImpersonateSelf в библиотеке MSDNПример
#include <SecurityConstants.au3>
#include <Security.au3>
#include <WinAPI.au3>
Local $hToken = _Security__OpenThreadToken($TOKEN_ADJUST_PRIVILEGES)
If $hToken Then
_WinAPI_CloseHandle($hToken)
Else
ConsoleWrite("_Security__OpenThreadToken failed with error description: " & _WinAPI_GetLastErrorMessage() & @CRLF)
ConsoleWrite("New attempt..." & @CRLF)
; Read remarks for _Security__OpenThreadToken function
_Security__ImpersonateSelf()
$hToken = _Security__OpenThreadToken($TOKEN_ADJUST_PRIVILEGES)
If $hToken Then
ConsoleWrite(">>> SUCCESS, $hToken = " & $hToken & @CRLF)
_WinAPI_CloseHandle($hToken)
Else
ConsoleWrite("!FAILED" & @CRLF)
EndIf
EndIf