Well... maybe this will help as a primer...
// Get a one item array... it is a UserGroup Object (but in an array of 1) var srcgrps = ActiveDirectory.search("UserGroup","GrpIG_smkLabTest-MGR"); //Use an S at the end for plural arrays - good practice System.log("Warning... search returns an array always... even if there is only one."); for each (srcgrp in srcgrps){ System.log(srcgrp.getAttribute("cn")); } // Get a two item array... they are UserGroup Objects (but in an array of 2) var taggrps = ActiveDirectory.search("UserGroup","GrpIG_smkLabTest"); //Use an S at the end for plural arrays - good practice System.log("Warning... search returns an array always... even if there is only one."); for each (taggrp in taggrps){ System.log(taggrp.getAttribute("cn")); if (taggrp.getAttribute("cn") == "GrpIG_smkLabTest") { System.log("Setting the one I actually want from the array: " + taggrp.getAttribute("cn")); var singleTargetGroup = taggrp; } } System.log ("Do I have the right group?"); // should be "GrpIG_smkLabTest" in my Lab System.log (singleTargetGroup.getAttribute("cn")); // yeppers // ONE user group has a method for addElements that takes an ARRAY of UserGroup and/or User objects singleTargetGroup.addElements(srcgrps); System.log("Warning... groupMembers returns an array always... even if there is only one."); singleTargetGroupMembers = singleTargetGroup.groupMembers; //Use an S at the end for plural arrays - good practice //Loop through all the members of the UserGroup object and syslog the name for each (singleTargetGroupMember in singleTargetGroupMembers){ System.log(singleTargetGroupMember.getAttribute("cn")); }