Goal:
Produce a list of AD group names in a dropdown for selection on catalog request for vRa. This can be used for vRa or vRo as an External Source on a field in the form.
Requirements:
- vRealize Orchestrator – I am using 7.6
- Active Directory Plugin configured by running "Add Active Directory Server" workflow successfully
- Run " Configure Active Directory plug-in options" workflow and set the default Active Directory Server successfully
Action:
We are naming our action.. getADGroupNamesFilterByNamePrefix
The action basically uses the default Active Directory Server to query for groups using a string search using an input called nameStartsWith. This is important to understand as the groups returned will be any name that has that string in the name of the group. This process relies heavily on a developed naming scheme for the AD Groups used.
The code is here…
arr_groups = new Array()
System.log("Name Starts With: " + nameStartsWith)
System.log("Running active Directory Search")
var groups = ActiveDirectory.search("UserGroup", nameStartsWith)
for (var i in groups) {
System.log("building group array : " + groups[i].name)
arr_groups.push(groups[i].name)
}
return arr_groups
The action will need an input called nameStartsWith as shown below. Be sure to mark the return as an Array of strings.
Field Configuration:
We want these as inputs to a workflow so we are going to add them as custom fields on the input form in vRo. This process is exactly the same in vRa except you would require a custom property on the blueprint that you can use for the field. Easier to get to this data in vRo.
We are going to add the variable adGroup as an input. Be sure that this is not an array but just a string.
Now we go to the input form and configure the field.
adGroup should show on the form. Click on it so you can access the field editor.
- Change the Display Type to DropDown
- Click on Values
- Expand Value Options
- Select External Source as Value Source
- Find the action in the list
- Define the namesStartsWith as a constant to whatever you need (I am using "lab_tower_" in this example)
Now save and run your workflow.
Now you can use this in your workflow as the adGroup variable to make decisions or perform action.
Enjoy!
UPDATED – EXCEPTION LIST FEATURE
I have created same process as above but with an exception list for the group names.
Usage of this script as an action in vRo:
This is an action script in vRo that should have two inputs as string.
Usage of this action in vRa blueprint custom form:
This should be set as a action based field in vRa and configured as pictured below.
Two examples below showing no exceptions with the "none" as a place holder and the other with multiple groups seperated by comma with no spaces.
The nameStartsWith fieled is the beginning of your group name. The exceptionList is a string that will be split by the comma in the action script to create an array of group names.
The gist!
Enjoy!