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 41 42 43 44
| Function OuvertureMembreExchange()
On Error GoTo OuvertureMembreExchange_Err
Const ADS_SCOPE_SUBTREE = 2
Dim objConnection As ADODB.Connection
Dim objCommand As ADODB.Command
Dim objRecordSet As ADODB.Recordset
DoCmd.Hourglass True
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
strSQL = "SELECT mailNickname, name, sn, givenName, mail, initials, displayName, streetAddress, postOfficeBox, l, st, postalCode, co, "
strSQL = strSQL & "homePhone, pager, mobile, facsimileTelephoneNumber, ipPhone, whenCreated, whenChanged, memberOf FROM 'LDAP://OU=Contacts,DC=LeServeur,DC=local' "
strSQL = strSQL & "WHERE objectCategory='contact' And memberOf = 'CN=Membres,OU=Contacts,DC=LeServeur,DC=local'"
objCommand.CommandText = strSQL
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
'Ici l'action que tu veux
objRecordSet.MoveNext
Loop
objRecordSet.Close
Set objRecordSet = Nothing
Set objConnection = Nothing
Set objCommand = Nothing
DoCmd.Hourglass False
Exit Function
OuvertureMembreExchange_Err:
MsgBox "Impossible de mettre à jour le serveur Exchange, les données des membres ne seront donc pas à jour!", vbCritical
DoCmd.Hourglass False
End Function |
Partager