- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-20-2017 10:39 AM
I have been working on account creation in AD via ServiceNow's Orchestration and found a challenge in updating the manager record. This caused me a fair amount of time to resolve so I want to share my solution for others. While there are many pieces of the puzzle documented, none walked me through the entire process.
The basics:
- I have mid servers setup and working properly with PowerShell and they have appropriate security to modify Active Directory accounts. A good article for me was located [ here ].
- My environment imports the users from LDAP, Part of that process provides source record information in the form of:
- "ldap:CN=Blackstone\, John,OU=Users,DC=oasis,DC=local"
In order to update the manager in AD, you must pass the DN (Distinguished Name) which just so happens to be the part past the : in the source record. In this case it is "CN=Blackstone\, John,OU=Users,DC=oasis,DC=local"
The method I used started with splitting the string at the : and passing the array [1] down the workflow, the array[0] would be the LDAP portion. The article that helped can be found [ here ]
I found a issue where the escape character was being stripped and so the result was passed down to powershell from the workflow would fail. So I needed to add an additional escape characters, article that helped [ here ]
There are a number of articles on the community that documents the escape character issue, so I am just showing how I implemented my solution.
Step 1 Created Workflow using the example located at ServiceNow's product documentation [ here ]
Step 2 - Created Workflow Input for quick testing so I would not have to use a record producer of some sort
Step 3 - Populated the "Run Script" activity with the following code
var srce=workflow.inputs.u_manager_name.source;
srce=srce.toString();
srce=srce.split(":");
workflow.scratchpad.managerDN=srce[1];
var fIdx = workflow.scratchpad.managerDN.indexOf(",");
var lIdx = workflow.scratchpad.managerDN.indexOf(",OU=");
if (fIdx < lIdx){
workflow.scratchpad.oName = workflow.scratchpad.managerDN.split(",OU=")[0];
workflow.scratchpad.oPath = workflow.scratchpad.managerDN.split(workflow.scratchpad.oName)[1];
workflow.scratchpad.fPart = workflow.scratchpad.oName.split(", ")[0];
workflow.scratchpad.lPart = workflow.scratchpad.oName.split(", ")[1];
workflow.scratchpad.emp_dn = workflow.scratchpad.fPart + "\\, " + workflow.scratchpad.lPart + workflow.scratchpad.oPath;
}
Step 4 - Configure "Update AD Object"
Step 5 - Tested and confirmed the manager field in AD was updated.
I hope this helps you.
Thank you to all the previous authors who helped me.