'===================================================
' La fonction suivante teste l'existence d'un utilisateur
'Exist_LDAP_User("user" )
Private Function Exist_LDAP_User(samAccountName)
strUserName = samAccountName
Set objConnection = CreateObject("ADODB.Connection" )
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command" )
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "<LDAP://dc=fabrikam,dc=com>;(&(objectCategory=User)" & "(samAccountName=" & strUserName & " ));samAccountName;subtree"
Set objRecordSet = objCommand.Execute
If objRecordset.RecordCount = 0 Then
Exist_LDAP_User = False
Else
Exist_LDAP_User = True
End If
objConnection.Close
End Function