Got some good code from a Tek-tips member to get a list of all members of an OU in AD. I want to tailor that to get a list of all users with a certain email address and all users with a certain name. However, no matter what syntax I use, the recordset returned is always empty. This is one variation:
For the actual command text I have tried other variations:
Can anyone tell me the proper syntax to check for a certain email address or to check for a certain name.
I could just get every record in the particular OU and then loop through them looking for a match. But I am adding several hundred contacts to AD and I would have to parse through the full list every time I add one.
Mighty
Code:
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "<LDAP://OU=myOU,DC=myCompany,DC=local>;(email=' & emailAddr & "');name;onelevel"
Set rs = cmd.Execute
For the actual command text I have tried other variations:
Code:
cmd.CommandText = "<LDAP://OU=myOU,DC=myCompany,DC=local>;(targetAddress=' & emailAddr & "');name;onelevel"
cmd.CommandText = "<LDAP://OU=myOU,DC=myCompany,DC=local>;(mail=' & emailAddr & "');name;onelevel"
cmd.CommandText = "<LDAP://OU=myOU,DC=myCompany,DC=local>;(name=' & contactName & "');name;onelevel"
cmd.CommandText = "<LDAP://OU=myOU,DC=myCompany,DC=local>;(cn=' & contactName & "');name;onelevel"
Can anyone tell me the proper syntax to check for a certain email address or to check for a certain name.
I could just get every record in the particular OU and then loop through them looking for a match. But I am adding several hundred contacts to AD and I would have to parse through the full list every time I add one.
Mighty