- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2017 09:26 AM
Inside our AD environment we have several users that have special characters, such as commas or apostrophes in their distinguished names. I've tried using .replace and .split, and various other methodologies of inserting the backslash as an escape character before these values (e.g. "\," or "\'", but everytime it appears as if ServiceNow is stripping them out before sending them over to the midserver for execution.
For example, when attempting a rename-adobject via Run Powershell activitity, what I need to send is:
rename adobject -Identity "CN=Test\, Bob,OU=Users,OU=domain,OU=com" -NewName "Bob Test"
What actually gets sent to the ECC queue is:
rename adobject -Identity "CN=Test, Bob,OU=Users,OU=domain,OU=com" -NewName "Bob Test"
Notice the missing slash before the common in the DN. This leads to the ECC Queue error of:
Cannot find an object with identity: 'CN=Bob, Test,OU=Users,OU=Users,DC=domain,DC=com' under: 'DC=domain,DC=com'.Stack Trace: at Microsoft.ActiveDirectory.Management.Commands.ADFactoryUtil.GetADObjectSearcherFromIdentity(ADEntity identityObj, String searchRoot, Boolean showDeleted, IADOPathNode structuralObjectFilter, IADOPathNode identityFilter, IdentityResolverDelegate[] identityResolvers, CmdletSessionInfo cmdletSessionInfo)at Microsoft.ActiveDirectory.Management.Commands.ADFactory`1.GetDirectoryObjectFromIdentity(T identityObj, String searchRoot, Boolean showDeleted)at Microsoft.ActiveDirectory.Management.Commands.ADRenameCmdletBase`3.ADRenameCmdletBaseProcessC SRoutine()at Microsoft.ActiveDirectory.Management.CmdletSubroutinePipeline.Invoke()at Microsoft.ActiveDirectory.Management.Commands.ADCmdletBase`1.ProcessRecord()
Issuing the command via Powershell directly and inserting the appropriate backslash works fine.
I have the same issue with someone whose last name is O'Conner.
Any help would be appreciated.
Solved! Go to Solution.
- Labels:
-
Orchestration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2017 12:35 PM
Here was my final code solution... since .slice() method didn't seem to be supported, I had to resort to a lot of splits. I'll move this to internal variables since nothing needs to be available outside this condition except the workflow.scratchpad.emp_dn. This assume's that you have already run your QueryAD to find your employee record and have sanitized the .path value from that query into the workflow.scratchpad.emp_dn variable.
var fIdx = workflow.scratchpad.emp_dn.indexOf(",");
var lIdx = workflow.scratchpad.emp_dn.indexOf(",OU=");
if (fIdx < lIdx){
// comma found in name
workflow.scratchpad.foundComma = 'yes';
workflow.scratchpad.oName = workflow.scratchpad.emp_dn.split(",OU=")[0];
workflow.scratchpad.oPath = workflow.scratchpad.emp_dn.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 + "";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2017 12:35 PM
Here was my final code solution... since .slice() method didn't seem to be supported, I had to resort to a lot of splits. I'll move this to internal variables since nothing needs to be available outside this condition except the workflow.scratchpad.emp_dn. This assume's that you have already run your QueryAD to find your employee record and have sanitized the .path value from that query into the workflow.scratchpad.emp_dn variable.
var fIdx = workflow.scratchpad.emp_dn.indexOf(",");
var lIdx = workflow.scratchpad.emp_dn.indexOf(",OU=");
if (fIdx < lIdx){
// comma found in name
workflow.scratchpad.foundComma = 'yes';
workflow.scratchpad.oName = workflow.scratchpad.emp_dn.split(",OU=")[0];
workflow.scratchpad.oPath = workflow.scratchpad.emp_dn.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 + "";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2017 09:44 AM
Hi Adam,
If question been answered (either by your own or another user's comment) can you mark that comment as the answer? Thanks!
Matthew