Solved

ldap searching using vbs

Posted on 2014-09-19
3
152 Views
Last Modified: 2014-09-19
Given

Dim strDescription
 
Const ADS_SCOPE_SUBTREE = 1000
 
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, Location, Description from 'LDAP://s.d.local/DC=s,DC=d,DC=local' Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE  
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
 
Wscript.Echo "Computer Name"
 
do Until objRecordSet.EOF
 
WScript.Echo objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
loop

What is the correct object class to return all computes in a domain ?

I am getting Active Directory: There is no such object on the server
0
Comment
Question by:HalCHub
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Joshua Grantom earned 500 total points
ID: 40333400
This

 "Select Name, Location, Description from 'LDAP://s.d.local/DC=s,DC=d,DC=local' Where objectClass='computer'"

Should be this

    "Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _
        & "Where objectClass='computer'"
0
 
LVL 1

Author Closing Comment

by:HalCHub
ID: 40333600
How did you get so smart :).. Thank you and have a great weekend.
0
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40333601
Lol, thanks. You as well.
0

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now