Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change vbscript to ldap query across two domains instead of just one

Posted on 2008-06-25
2
Medium Priority
?
835 Views
Last Modified: 2010-04-21
I have a script that I use to query for servers on our domain. I need this same script to get servers from my domain (dom1) as well as another domain (dom2). I've attached the LDAP query section, but I have little LDAP experience and am not sure how to ammend the code to make it work with both domains.




Set objRootDSE = GetObject("LDAP://RootDSE")
objCommand.CommandText = "SELECT name, operatingSystem " &_
	"FROM 'LDAP://" & objRootDSE.Get("defaultNamingContext") &_
	"' WHERE objectClass='computer' AND (operatingSystem='Windows Server 2003*' OR operatingSystem='*2000 Server*')"
Set objRootDSE = Nothing

Open in new window

0
Comment
Question by:bbcac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
Jared Luker earned 2000 total points
ID: 21867303
I think you'll want to do two queries...

The account you are running the script on will need to have rights in both domains.

I don't have a way to test this, but I think it'll work.
objCommand2.CommandText = "SELECT name, operatingSystem " &_
	"FROM 'LDAP://DOM2" &_
	"' WHERE objectClass='computer' AND (operatingSystem='Windows Server 2003*' OR operatingSystem='*2000 Server*')"
Set objRootDSE = Nothing

Open in new window

0
 

Author Closing Comment

by:bbcac
ID: 31470645
Thats Great.... works like a charm
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On a regular basis I get questions about slow RDP performance, RDP connection problems, strange errors and even BSOD, remote computers freezing or restarting after initiation of a remote session. In a lot of this cases the quick solutions made b…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

610 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