Solved

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

Posted on 2008-06-25
2
787 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
2 Comments
 
LVL 17

Accepted Solution

by:
Jared Luker earned 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

17 Experts available now in Live!

Get 1:1 Help Now