I'm trying to search Exchange 5.5 programmatically using wildcards to search
for a portion of a name or container. In the example code below, I'm trying
to enumerate all users with "user" somewhere in their container name. eg.
cn=TestUser1, cn=TestUser2 etc.

This code works fine using a wildcard at the end of the searchstring, but
not at the front, so "testuser*" works but "*user*" does not. It doesn't
give any errors, but it doesn't return any matches at all either, even
though they do exist...

I should note that querying Active Directory using the technique below works
correctly with the wildcards. This seems to be a bug with Exchange...

Any ideas?

Thanks in advance.

Steve

<snip>
strExchangeServer = "Exchange1"
strCN = "*user*"

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = ""
objConnection.Properties("Password") = ""
objConnection.Properties("Encrypt Password") = False
objConnection.Open "ADs Provider"

strQuery = "<GC://" & strExchangeServer &
":389>;(&(objectClass=organizationalPerson)cn=" & strCn &
");cn,givenName,sn;subtree"

objCommand.ActiveConnection = objConnection
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 99

Set objRecordSet = objCommand.Execute
</snip>


_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Web Interface: 
http://intm-dl.sparklist.com/cgi-bin/lyris.pl?enter=exchange&text_mode=&lang=english
To unsubscribe send a blank email to [EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.

Reply via email to