1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
' - Execution de la requete SQL sur le LDAP -
objCommand.CommandText = "SELECT SN, givenName, samAccountName, telephoneNumber, mail FROM 'LDAP://dc=TON_DOMAINE_NT,dc=local' WHERE objectCategory='User' ORDER BY 1"
Set objRecordSet = objCommand.Execute
' - Gestion du RecordSet -
objRecordSet.MoveFirst
Do While Not objRecordSet.EOF
nom = objRecordSet.Fields("SN").Value
objRecordSet.MoveNext
Loop
objRecordSet.Close
Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing |
Partager