Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

New Account task for AD is failing with error "Cannot invoke method replace() on null object"

manish97sh
New Contributor III
New Contributor III

Hi,

New Account task for AD is failing with below error:

 Error while creating account extusernew107t in AD - Cannot invoke method replace() on null object.

CreateAccountJson:

${
Map attrs = new HashMap();
 
attrs.put('objectclass', ['top', 'person', 'organizationalPerson', 'user']);
if(null!=user.displayname){
attrs.put('displayname', user.displayname);
}
if(null!=user.lastname){
attrs.put('sn', (user.customproperty1 != null)?(user.customproperty1 + ' ' + user.lastname) : user.lastname);
}
if(null!=user.preferedFirstName){
attrs.put('givenName', user.preferedFirstName);
}
if(null!=user.systemUserName){
attrs.put('sAMAccountName', user.systemUserName);
}
if(null!=user.middlename){
attrs.put('middleName', user.middlename);
}
if(null!=user.jobDescription){
attrs.put('title', user.jobDescription);
}
if(null!=user.country){
attrs.put('co', user.country);
}
if(null!=user.customproperty3){
attrs.put('countryCode', user.customproperty3);
}
if(null!=user.street){
attrs.put('streetAddress', user.street);
}
if(null!=user.city){
attrs.put('l', user.city);
}
if(null!=user.state){
attrs.put('st', user.state);
}
if(null!=user.regioncode){
attrs.put('postalCode', user.regioncode);
}
if(null!=user.departmentname){
attrs.put('department', user.departmentname);
}
if(null!=user.customproperty4){
attrs.put('division', user.customproperty4);
}
if(null!=user.email){
attrs.put('userPrincipalName', user.email);
}
if(null!=user.customproperty31){
attrs.put('extensionAttribute2', user.customproperty31);
}
if(null!=user.customproperty2){
attrs.put('extensionAttribute15', user.customproperty2);
}
if(null!=user.siteid){
attrs.put('extensionAttribute3', user.siteid.substring(0,2).toString());
attrs.put('c', user.siteid.substring(0,2).toString());
}
if((user.region=='North America'&&user.customproperty5=='Office') || (user.region=='Europe') || (user.region=='SouthAmerica') || (user.region=='Africa')){
attrs.put('mail', user.email);
attrs.put('targetAddress', 'SMTP:'+user.systemUserName+'@ardagh.mail.onmicrosoft.com');
attrs.put('mailNickname', user.systemUserName);
attrs.put('msExchRecipientDisplayType', '-2147483642');
attrs.put('msExchRecipientTypeDetails', '2147483648');
attrs.put('msExchRemoteRecipientType', '1');
attrs.put('proxyAddresses', 'SMTP:'+user.email+',smtp:'+user.systemUserName+'@ardagh.mail.onmicrosoft.com');
}
if(null!=user.customproperty5){
attrs.put('msExchExtensionAttribute16', user.customproperty5);
}
if(user.employeeType=='Employee'||user.employeeType=='Student'){
attrs.put('employeeType', 'Employee');
}else if(user.employeeType!='Third Party'){
attrs.put('employeeType', 'External');
}
if(null!=user.manager && null!=managerAccount)
{
attrs.put('manager',managerAccount.accountID);
}
if(user.employeeType=='Third Party'){
attrs.put('physicalDeliveryOfficeName', 'EXTERNAL');
}else if(null!=user.customproperty31){
attrs.put('physicalDeliveryOfficeName', user.customproperty31.substring(0,5).toString());
}
attrs.put('accountExpires', user.enddate==null?'9223372036854775807':(10000*(user.enddate.getTime() + 11644473600000)));
attrs.put('userAccountControl', '514');
attrs.put('iTSMID', 'ARD.' + user.systemUserName);
attrs.put('iTSMLicense', 'READ');
 
jsonBuilder = new groovy.json.JsonBuilder(attrs);
return jsonBuilder.toString();
}

 

2 REPLIES 2

rushikeshvartak
All-Star
All-Star

Does any field blank for mentioned user ?


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

manish97sh
New Contributor III
New Contributor III

Hi @rushikeshvartak,

yes some of the mandatory attributes were missing and i managed to make it and it is working now.

Though i am facing issue with one another attribute now which is accountExpires.

Please refer to the JSON below;
attrs.put('accountExpires', user.enddate==null?'9223372036854775807':(10000*(user.enddate.getTime() + 11644473600000)));

Error with above JSON is as below:

Error while creating account in AD - Malformed 'accountExpires' attribute value

 

Can you please help me on this attribute ?

Best regards,

Manish