
LDAP Query for Exchange 2000
Can anyone give me a hand.. I have some code which extracts a list of
Exchange 2k mailboxes on our system. The problem is, the code will return
"custom receipients" for which mailboxes don't really exist. Is there a way
to modify my code to return only valid user mailboxes?? No custom recips,
or public folders...
Here's a snipit of my code:
DomainName = "xyz.com"
GALDN = "CN=Default Global Address List,CN=All Global Address
Lists,CN=Address Lists Container,CN=RFBD,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=xyz,DC=com"
Set oRoot = GetObject("LDAP://" & DomainName & "/rootDSE")
strDefaultNamingContext = oRoot.get("defaultNamingContext")
Set objGAL = GetObject("LDAP://" & DomainName & "/" & GALDN)
GALQueryFilter = objGAL.get("purportedSearch")
strQuery = "<LDAP://" & DomainName & "/" & strDefaultNamingContext & ">;" &
GALQueryFilter &
";distinguishedName,displayName,mailNickname,msExchHideFromAddressLists;subt
ree"
Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "ADsDSOOBJECT"
oConn.Open "ADs Provider"
Set oComm = CreateObject("ADODB.Command")
oComm.ActiveConnection = oConn
oComm.Properties("Page Size") = 1000
oComm.CommandText = strQuery
Set rs = oComm.Execute
While Not rs.EOF
WScript.Echo rs.Fields("mailNickname")
rs.MoveNext
Wend
Any suggestions would be appreciated.
Thanks,
Troy