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 |