Bonjour

via un directorySearcher je scanne les utilisateur de l'AD. Pour chaque utilisateur j'aimerais récupérer son SID .

Le problème c'est que même en cherchant je ne trouve pas comment convertir le type SID qui est un array je crois en string. apparemment la fonction
ConvertSidToStringSid peut aider mais je ne vois pas comment l'implémenter dans mon projet.

Le code ci dessous montre comment j'ai fait pour le GUID mais apparrement pour le SID ce n'est pas pareil
Merci pour votre aide

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        For Each result As SearchResult In searcher.FindAll()
 
            'Total of users found
 
            Dim totUser = searcher.FindAll().Count
 
            Dim entry As DirectoryEntry = result.GetDirectoryEntry()
            Dim cn As String = entry.Properties("cn").Value
            Dim sAMAccountName As String = entry.Properties("sAMAccountName").Value
            'Retreive GUID
            Dim guid() As Byte = entry.Properties("objectGuid").Value
            Dim myGUID As Guid = New Guid(guid)
            Dim UserGUID As String = ""
            UserGUID = Replace(myGUID.ToString, "-", "")
            UserGUID = UserGUID.ToUpperInvariant