1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Private Sub Command1_Click()
Dim conn As ADODB.Connection '****
Dim rsSource As ADODB.Recordset '****
Dim mail,sn
AdresseIpSource = "x.x.x.x"
DnSourceLdap = "o=toto"
filtreLdapSource = "(objectClass=user)"
Set conn = New ADODB.Connection
conn.Provider = "ADSDSOObject"
conn.Properties("User ID") = "cn=admin,o=toto"
conn.Properties("Password") = "tototutu"
conn.Open "ADs Provider"
' Connexion à la base Source
mess = "<LDAP://" & AdresseIpSource & "/" & DnSourceLdap & ">;" & filtreLdapSource & ";mail,sn;subtree"
Set rsSource = conn.Execute(mess)
rsSource.MoveFirst
Do Until rsSource.EOF
mail= rsSource.Fields(0).Value
sn = rsSource.Fields(1).Value
If sn(0) <> "" Then
Debug.Print " " & sn(0)
End If
If mail(0) <> "" Then ' <-- Ligne provoquant l'erreur
Debug.Print " " & mail(0)
End If
rsSource.MoveNext
Loop
End Sub |
Partager