deathsurfer
Messages postés35Date d'inscriptionlundi 15 juin 2009StatutMembreDernière intervention28 juillet 2009
-
3 août 2007 à 14:30
ken94
Messages postés1Date d'inscriptionjeudi 23 mars 2006StatutMembreDernière intervention21 août 2007
-
21 août 2007 à 15:33
Bonjour à tous! Voici mon problème j'arrive à récuperer les groupes d'une OU dans une dropdownliste, puis à récupérer les utilisateurs de chaque groupe dans une listbox. Le problème c'est que les utlisateurs apparaissent sous la forme "CN=MonUser, CN=Users, DC=dom. J'aimerai plutot avoir un le log de l'utilisateur. Comment faire ? merci.
Voici le code:
Dim objADAM As DirectoryEntry
Dim objEntry As DirectoryEntry
Dim objSearchADAM As DirectorySearcher
Dim objSearchResults As SearchResultCollection
Dim strFilter As String
Dim strPath As String
' Construct the binding string.
' Get AD LDS object.
Try
objADAM = New DirectoryEntry("LDAP://BIZONE/OU=bizone,DC=domaine", "DOMAINE\administrator", "admin", AuthenticationTypes.Secure)
objADAM.RefreshCache()
Catch ev As Exception
label1.text = "Error: Bind failed."
Return
End Try
' Get search object,
' specify filter and scope,
' perform search.
Try
objSearchADAM = New DirectorySearcher(objADAM)
objSearchADAM.Filter = strFilter
objSearchADAM.SearchScope = SearchScope.Subtree
objSearchResults = objSearchADAM.FindAll()
Catch ev As Exception
label1.text = "Error: Search failed."
Return
End Try
' Enumerate filtered objects.
Try
If objSearchResults.Count <> 0 Then
label1.text = "Results: Following objects found."
Dim objResult As SearchResult
For Each objResult In objSearchResults
objEntry = objResult.GetDirectoryEntry()
dropdownlistgpe.items.add(objEntry.Properties.Item("SAMAccountName").Value.ToString)
Dim objMember As New Object
For Each objMember In objEntry.Properties("member")
If objEntry.name = "CN=" & dropdownlistgpe.SelectedItem.Text Then
Listboxuser.items.add(objMember.ToString)
'ICI LE LOGIN GENRE objMember.item.properties("logonAccount").value.tostring mais ça ne marche pas'
End If
Next objMember
Next objResult
Else
label1.text = "Results: No objects found."
End If
Catch ev As Exception
label1.text = "Error: Enumerate failed."
Return
End Try
ken94
Messages postés1Date d'inscriptionjeudi 23 mars 2006StatutMembreDernière intervention21 août 2007 21 août 2007 à 15:33
Bonjour,
Lorsque tu récupères ton résumtat en CN=,etc... tu refais une boucle de type, "LDAP:// & TonRésultat" pour te connecter sur ton utilisateur, ensuite tu peux récupérer ta propriété Samaccount,