Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found listed in my profile here: http:…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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