Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 229915

Re: Search for Child OUs

$
0
0

Hi deanvictrix . You are nearly there.

The ActiveDirectory.search function returns a set of objects of type AD_OrganizationalUnit, and you are then capturing all sub OUs into a new array arrchildOUs. The method ou.organizationalUnits returns an array of AD_OrganizationalUnit objects though, so your variable arrchildOus is actually an array where each entry is itself an array of AD_OrganizationalUnit objects.

 

So I'm assuming that your initial search will only ever return one OU, if not then you need to include a stage to verify the OU you are running this on is the correct one first. I'm guessing you are searching for a particular OU and only want the names of the child OUs for that one particular parent OU though, so amending your code to the following:

var parentOU = "Departments";
var ous = ActiveDirectory.search('OrganizationalUnit',parentOU);

for each (ou in ous){
var childOUs = ou.organizationalUnits;
}

 

Will give you an array of child OU objects stored in the variable childOUs. You can now loop through these and get the name of each OU like so:

for each (var ouObject in childOUs){

     System.log("OU Name: " + ouObject.name);

}

Let me know if you need any more help with this.

 


Viewing all articles
Browse latest Browse all 229915

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>