Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADSI query

Status
Not open for further replies.

sfriday

IS-IT--Management
Feb 23, 2002
211
DE
I have the following code:

Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name from 'LDAP://OU="& oudesc & ",OU=Servers,OU=name,DC=one,DC=com'" & " where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Call Report_Events
objRecordSet.MoveNext
Loop

If the LDAP string is wrong or can not be seen it throws up an error of Table does not Exist.

I have tried setting On Error Resume Next and try to capture the err.number however it does not return one and terminates the script regardless.

The error occurs at Set objRecordSet = objCommand.Execute
any ideas on how I can capture it??

Regards
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top