Hi all,
Our team has developed a Before Provisioning Rule for Active Directory (AD). This rule updates the ‘AC_NewName’ and ‘displayName’ attributes in case of a name change scenario, and the ‘AC_NewParent’ attribute in case of an OU change scenario. In scenarios where both a name change and an OU change occur, the rule updates the ‘AC_NewName’, ‘displayName’, and ‘AC_NewParent’ attributes.
While working on a scenario involving both a name change and an OU change, we received the following error: [“Failed to update attribute ‘AC_NewName’. Error - An invalid DN syntax has been specified.”]
Here is the part of Before provisioning rule for reference,
if (plan!=null) {
List accountRequests = plan.getAccountRequests();
if (accountRequests!=null) {
for (AccountRequest accountRequest : accountRequests) {
AccountRequest.Operation op = accountRequest.getOperation();
Identity identity = plan.getIdentity();
String applicationName = application.getName();
String nativeIdentity = accountRequest.getNativeIdentity();
String firstName, lastName, middleinitial, defaultOU, lcs;
if(identity.getAttribute("oudetails")!=null) {defaultOU = (String) identity.getAttribute("oudetails");}
if(identity.getAttribute("firstname")!=null) {firstName = (String) identity.getAttribute("firstname");}
if(identity.getAttribute("lastname")!=null) {lastName = (String) identity.getAttribute("lastname");}
if(identity.getAttribute("middleInitial")!=null) {middleinitial = (String) identity.getAttribute("middleInitial");}
if(identity.getAttribute("cloudLifecycleState")!=null) {lcs = (String) identity.getAttribute("cloudLifecycleState");}
log.error("Before Rule: Values -> Operation:" + op + " | Identity:" + identity + " | Application:" + applicationName + " | Native Identity:" + nativeIdentity + " | OU Details" + defaultOU + " | First Name:" + firstName + " | Last Name:" + lastName + " | Middle Initial:" + middleinitial + " | LCS:" + lcs);
List attributeRequests = accountRequest.getAttributeRequests();
boolean nameChanged = false, ouChanged = false;
if(attributeRequests!=null) {
log.error("Before Rule: Fetching the values from Attr Req and comparing. Finding a match");
for (AttributeRequest attributeRequest : attributeRequests) {
String nameAttrReq = attributeRequest.getName();
if (nameAttrReq.equalsIgnoreCase("givenName") || nameAttrReq.equalsIgnoreCase("sn") || nameAttrReq.equalsIgnoreCase("initials")) {
nameChanged = true;
}
if (nameAttrReq.equalsIgnoreCase("company")) {
ouChanged = true;
}
}
}
if (null!=op && null!=nativeIdentity && op.equals(AccountRequest.Operation.Modify)) {
String name = generateName(firstName, lastName, middleinitial);
String newCN = generateCN(applicationName, name, defaultOU, nativeIdentity);
String newDN = "CN=" + newCN + "," + defaultOU;
if (null!=newCN && nameChanged) {
accountRequest.add(new AttributeRequest("AC_NewName", ProvisioningPlan.Operation.Set, newCN));
accountRequest.add(new AttributeRequest("displayName", ProvisioningPlan.Operation.Set, newCN));
}
if(null!=newDN && ouChanged) {
accountRequest.add(new AttributeRequest("AC_NewParent", ProvisioningPlan.Operation.Set, newDN));
}
log.error("Before Rule: Modify Operation Triggered -> CN:" + newCN + " | DN:" + newDN + " | Provisioning STATUS_COMMITED");
}
}