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

Active Directory advanced create account json question

igorvt77
New Contributor III
New Contributor III

I am hoping that someone can point me to the simple mistake I'm making because this has been driving me nuts for a week now.

Here is the error message I get when trying to create the account.  The account task is generated from a technical rule (arstasksObj.source = "ZERODAY").  From what I can tell the syntax for the json is correct but that because the requestAccessAttributes binding variable is {} (ie null) then its throwing off my if statement.  If I generate an ARS request task (arstasksObj.source = "REQUEST") then the first section of code in the create account json works just fine without any errors.

"2024-01-29T21:07:37.470+00:00","ecm-worker","ldap.SaviyntGroovyLdapService","quartzScheduler_Worker-4-vnxm5","ERROR","Error while creating account 123456 in AD - Error parsing JSON"
"2024-01-29T21:07:37.581+00:00","ecm-worker","","null-vnxm5","","org.codehaus.groovy.grails.web.converters.exceptions.ConverterException: Error parsing JSON at grails.converters.JSON.parse(JSON.java:292) at com.saviynt.ldap.SaviyntGroovyLdapService$_createAccountGLDAP_closure2.doCall(SaviyntGroovyLdapService.groovy:598) at com.saviynt.ldap.SaviyntGroovyLdapService.createAccountGLDAP(SaviyntGroovyLdapService.groovy:245) at com.saviynt.ecm.services.ArsTaskService.createAccountTarget(ArsTaskService.groovy:11680) at com.saviynt.ecm.services.ArsTaskHelperService$_whenTaskTypeIsThreeNewAccountAccess_closure50.doCall(ArsTaskHelperService.groovy:3075) at com.saviynt.ecm.services.ArsTaskHelperService.whenTaskTypeIsThreeNewAccountAccess(ArsTaskHelperService.groovy:3066) at com.saviynt.ecm.services.ArsTaskHelperService$_completeAutoProvTasksUpgraded_closure1.doCall(ArsTaskHelperService.groovy:175) at com.saviynt.ecm.services.ArsTaskHelperService.completeAutoProvTasksUpgraded(ArsTaskHelperService.groovy:160) at MultipleProvisioningJob.execute(MultipleProvisioningJob.groovy:222) at org.quartz.core.JobRunShell.run(JobRunShell.java:199) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)Caused by: org.codehaus.groovy.grails.web.json.JSONException: Expected a ':' after a key at character 7 of {null"
"2024-01-29T21:07:37.581+00:00","ecm-worker","","null-vnxm5","","}"
"2024-01-29T21:07:37.581+00:00","ecm-worker","","null-vnxm5",""," at grails.converters.JSON.parse(JSON.java:283)"
"2024-01-29T21:07:37.581+00:00","ecm-worker","","null-vnxm5",""," ... 10 more"

Please note that I have shorted the attached json code and removed sensitive stuff.  The instance version is 23.11

7 REPLIES 7

pmahalle
All-Star
All-Star

Hi @igorvt77 ,

Use if-else to check the source of the task, if source is Request then only use requestAccessAttributes  otherwise not. You can use below expression to check the source of the task.

${arstasksObj?.source.equalsIgnoreCase('REQUEST')}


Pandharinath Mahalle(Paddy)
If this reply helps your question, please consider selecting Accept As Solution and hit Kudos 🙂

rushikeshvartak
All-Star
All-Star

 

${arstasksObj?.source?.equalsIgnoreCase('REQUEST')}


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

I actually tried ${arstasksObj?.source != 'ZERODAY'} but it didn't seem to work.  Any reason why you must use the format you provided ?
Also do you know if you can nest the if statements ?

Example:
{${if(arstasksObj.source?.equalsIgnoreCase('REQUEST'))
if(requestAccessAttributes?.get('objecttype') == 'AdminAccount')
....
else
....

igorvt77
New Contributor III
New Contributor III

Update: I tried the provided solution above and I'm still receiving the same parsing json error.

igorvt77
New Contributor III
New Contributor III

In case anyone had seen this and was trying to do something similar, the code I had was fine and apparently the error was coming from the code I was using in my CHECKFORUNIQUE json which was trying to access a binding variable that was not supported.  Once I removed that then everything worked fine.

/what was that variable ?


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

I believe it was the "requestAccessAttributes" but hard to know for sure.  Here is what I had:

{${ if (requestAccessAttributes?.get('objecttype') == 'AdminAccount')
' "sAMAccountName": "' + arstasksObj?.accountName + '" '
else if ((arstasksObj?.accountKey?.accounttype == 'Employee') || (arstasksObj?.accountKey?.accounttype == 'NonEmployee'))
' "sAMAccountName": "' + user.username + '" '
}
}