Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript to LDAP Query Multiple Domains

Status
Not open for further replies.

djtech2k

MIS
Jul 24, 2003
1,097
US
I have done a lot of scripting to do things in AD, but 90% of it has been in a single domain environment. I now have the need to query data from multiple (2) domains.

What do I need to do differently? I normally use the same old ADO search/query and bounce out the stuff I want or don't want. I always use the RootDSE to dynamically grab the domain that the user is logged into and find the DC dynamically that way.

I need to know what steps do I need to change in order to query users and putting out a single report for both domains.

Thanks in Advance.
 
I'd suggest you make an array with your domain info. Then loop through the array in place of where you normally use RootDSE.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
You mean like creating an array with a DC/GC from each domain and connecting directly to a DC/GC?
 
You mean like creating an array with a DC/GC from each domain and connecting directly to a DC/GC?

Sort of yes. What I was suggesting was you replace your RootDSE information which might look like this:

DC=Company, DC=local

With something like this

Code:
Dim DomArray(2)
DomArray(0) = "DC=DomainA, DC=Company, DC=local"
DomArray(1) = "DC=DomainB, DC=Company, DC=local"

For Each DomainString In DomArray
	'Here you can now use DomainString to connect to the individual domains.
	'Replace whatever variable you have set to RootDSE.Get(DefaultNamingContext)
	'to DomainString.
	WScript.Echo DomainString
Next

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top