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
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