UDF > Security >


_Security__SetTokenInformation

Définit différents types d'informations pour un jeton d'accès spécifié

#include <Security.au3>
_Security__SetTokenInformation ( $hToken, $iTokenInformation, $vTokenInformation, $iTokenInformationLength )

Paramètres

$hToken Handle du jeton d'accès pour lequel l'information doit être définie
$iTokenInformation Type d'informations à définir dans le jeton d'accès
$vTokenInformation Une (un pointeur sur une) structure qui contient les informations à définir dans le jeton d'accès
$iTokenInformationLength La longueur, en octets, du tampon pointé par $vTokenInformation

Valeur de retour

Succès: Retourne True.
Échec: Retourne False.

En relation

_Security__GetTokenInformation

Voir aussi

Consultez SetTokenInformation dans la librairie MSDN.

Exemple

#RequireAdmin ; A un sens pour cet exemple

#include <MsgBoxConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPIHObj.au3>

Example_SeTokInfo()

Func Example_SeTokInfo()
    Local $hProcess = _WinAPI_GetCurrentProcess()
    If @error Then Return ; Teste des erreurs possibles

    Local $hToken = _Security__OpenProcessToken($hProcess, $TOKEN_ALL_ACCESS)

    ; Si le jeton est obtenu...
    If $hToken Then
        ; Définit un niveau d'intégrité moyen pour ce jeton.
        Local $tSID = _Security__StringSidToSid($SID_MEDIUM_MANDATORY_LEVEL)
        ; Définir la structure TOKEN_MANDATORY_LABEL
        Local Const $tTOKEN_MANDATORY_LABEL = DllStructCreate("ptr Sid; Attributs DWORD")
        ; La remplit avec les données 
        DllStructSetData($tTOKEN_MANDATORY_LABEL, "Sid", DllStructGetPtr($tSID, 1))
        DllStructSetData($tTOKEN_MANDATORY_LABEL, "Attributes", $SE_GROUP_INTEGRITY)

        If _Security__SetTokenInformation($hToken, $TOKENINTEGRITYLEVEL, $tTOKEN_MANDATORY_LABEL, DllStructGetSize($tTOKEN_MANDATORY_LABEL)) Then

            ; Par défaut IL est $SID_HIGH_MANDATORY_LEVEL, cependant...
            MsgBox($MB_SYSTEMMODAL, "SetTokenInformation", "$hToken = " & $hToken & @CRLF & "Ce jeton a Medium Integrity Level qui n'est pas par défaut")
            ;
            ; ... Placez du code ici...
            ;
        EndIf
        ; Ferme le handle du jeton lorsqu'il n'est plus nécessaire
        _WinAPI_CloseHandle($hToken)
    EndIf
EndFunc   ;==>Example_SeTokInfo