using System; using System.Collections.Generic; using System.Web; using System.Runtime.InteropServices; namespace CG67.FicheCollege.Tools { /// /// Ensemble de méthodes pour gérer l'impersonification /// public static class Impersonation { /// /// Permet de créer un jeton d'authentification /// /// Le compte à utiliser /// Le domaine du compte /// Le mot de passe /// Le type d'ouverture de session /// Le fournisseur de jeton /// Le jeton à récupérer /// Un booléen indiquant le résultat de l'opération [DllImport("advapi32.dll", SetLastError = true)] public static extern bool LogonUser( string principal, string authority, string password, LogonSessionType logonType, LogonProvider logonProvider, out IntPtr token); /// /// Ferme un handle sur un objet /// /// Un handle valide pour ouvrir un objet /// Retourne un résultat différent de 0 en cas de réussite [DllImport("kernel32.dll", SetLastError = true)] public static extern bool CloseHandle(IntPtr handle); } }