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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Active Directory Error 424

Status
Not open for further replies.

CharlieT302

Instructor
Mar 17, 2005
406
US
Hi Folks

I am trying to query Active Directory by attaching code to a command button. When I run the code, which I have pieced together from various web links, I receive the message:
Error 424 Object Required. The line that "appears" to be the problem is as follows:

Wscript.Echo objRecordset.Fields("Name").Value

Does anyone see the error in the code below?


Private Sub Command0_Click()

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://dc=ad,dc=posdom,dc=org>;;name;subtree"

Set objRecordset = objCommand.Execute
While Not objRecordset.EOF
Wscript.Echo objRecordset.Fields("Name").Value
objRecordset.MoveNext
Wend



 
Replace this:
Wscript.Echo

with this:
MsgBox

or this:
Debug.Print

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks,

This got me much closer. The Debug.Print command worked by pulling the information into the Immediate Window.

At first, it gave me the name of every Windows object. By attaching the (ObjectCategory=Users) option I was able to limit the list to just the names.

I have two questions:

First, I would like to pull the list into a table, query, or as the recordsource of a combo box. Do you know how to do that?

Second, do you know how to pull the first and last names separately? The names that appear on the server have spaces between them (first name), but that does not appear to be the actual name.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top