Solved

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

Posted on 2008-06-25
2
790 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Some time ago I faced the need to use a uniform folder structure that spanned across numerous sites of an enterprise to be used as a common repository for the Software packages of the Configuration Manager 2007 infrastructure. Because the procedu…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

18 Experts available now in Live!

Get 1:1 Help Now