Run-time Error -2147217900 (80040e14)

afcruz

New member
Local time
Today, 09:37
Joined
Jun 12, 2013
Messages
2
Hi there,

I keep getting the following error when I run the very simple code listed below

Run-time Error -2147217900 (80040e14)
"one or more errors occurred during processing of command"

What I am trying to do is to query Active Directory.

This is the line with Error:

Set objrecordset = objCommand.Execute

======================== Code ========================

'*****************************************
'*Connects To AD and sets search criteria*
'*****************************************
'On Error Resume Next
Dim rs As ADODB.Recordset
Dim strSql As String
Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "ADs Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
'*************************************************
'*SQL statement on what OU to search and to look for User Objects ONLY*
'*************************************************
objCommand.CommandText = "SELECT top 2 * FROM 'LDAP://??????.com/OU=???,OU=Districts,OU=Standard Users,OU=XTO,DC=xtonet,DC=com' "

Set objrecordset = objCommand.Execute


While Not objrecordset.EOF
Debug.Print rs.Fields(1).Value
rs.MoveNext
Wend

objrecordset.Close
Set objrecordset = Nothing

================== end of code ==================

Thanks in advance for your help.

Alex
 
You haven't declared objrecordset, but you have declared rs - and then mixed them up in

While Not objrecordset.EOF
Debug.Print rs.Fields(1).Value
rs.MoveNext
Wend

might be the reason why
 

Users who are viewing this thread

Back
Top Bottom