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.