Error while trying to create an account in AD

avinash_16
New Contributor III
New Contributor III

Greetings, I have encountered a problem while creating an account in AD. So, I created an if else block in the CREATEACCOUNTJSON parameter in the connector and when I tried to create an account in the target application, I got this error in the provisioning comments of the task:

Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript6.groovy: 2: unexpected char: '\' @ line 2, column 1. \"cn\": \"${cn}\", ^ 1 error

The configuration for CREATEACCOUNTJSON is:

${if (${user.startdate} < sysdate()) {
"cn": "${cn}",
"displayname": "${user.displayname}",
"givenName": "${user.firstname}",
"name": "${user.displayname}",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"sAMAccountName": "${task.accountName}",
"sn": "${user.lastname}",
"userAccountControl": "546"
}
else {
"cn": "${cn}",
"displayname": "${user.displayname}",
"givenName": "${user.firstname}",
"name": "${user.displayname}",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"sAMAccountName": "${task.accountName}",
"sn": "${user.lastname}",
"userAccountControl": "544"
}
}

Can you pls help me in this?

Thanks.

17 REPLIES 17

pmahalle
Valued Contributor II
Valued Contributor II

Hi @avinash_16 ,

Can you try below one:

${if (user.startdate < sysdate()) {
"cn": "cn",
"displayname": "user.displayname",
"givenName": "user.firstname",
"name": "user.displayname",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"sAMAccountName": "task.accountName",
"sn": "user.lastname",
"userAccountControl": "546"
}
else {
"cn": "cn",
"displayname": "user.displayname",
"givenName": "user.firstname",
"name": "user.displayname",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"sAMAccountName": "task.accountName",
"sn": "user.lastname",
"userAccountControl": "544"
}
}


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

avinash_16
New Contributor III
New Contributor III

Thank you for the reply but still I'm getting the same error.
Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript4.groovy: 3: unexpected char: '\' @ line 3, column 1. \"cn\": \"cn\", ^ 1 

naveenss
All-Star
All-Star

remove $ inside the if/else conditino and retry the provisioning. Once you specify the "$" once you dont need to add it all the time inside the script. 

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

avinash_16
New Contributor III
New Contributor III

Thank you for the reply but still I'm getting the same error.
Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript4.groovy: 3: unexpected char: '\' @ line 3, column 1. \"cn\": \"cn\", ^ 1 

pmahalle
Valued Contributor II
Valued Contributor II

Hi @avinash_16 ,

Can you share the createaccount json you are using now. Also, did you have added ACCOUNTNAMERULE?


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

avinash_16
New Contributor III
New Contributor III

Yeah sure. 

CREATEACCOUNTJSON:
${if (user.startdate < sysdate()) {
"cn": "cn",
"displayname": "user.displayname",
"givenName": "user.firstname",
"name": "user.displayname",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"sAMAccountName": "task.accountName",
"sn": "user.lastname",
"userAccountControl": "546"
}
else {
"cn": "cn",
"displayname": "user.displayname",
"givenName": "user.firstname",
"name": "user.displayname",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"sAMAccountName": "task.accountName",
"sn": "user.lastname",
"userAccountControl": "544"
}
}

ACCOUNTNAMERULE: CN=${user.username},OU=AD_Offshore,DC=lab,DC=example,DC=com###cn=${account},OU=AD_Offshore,DC=lab,DC=example,DC=com

Thanks.

pmahalle
Valued Contributor II
Valued Contributor II

Hi @avinash_16 ,

Try this.

${if (user.startdate < sysdate()) {
'"cn": "'+cn+'",
"displayname": "'+user.displayname+'",
"givenName": "'+user.firstname+'",
"name": "'+user.displayname+'",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"sAMAccountName": "'+task.accountName+'",
"sn": "'+user.lastname+'",
"userAccountControl": "546"
}
else {
"cn": "'+cn+'",
"displayname": "'+user.displayname+'",
"givenName": "'+user.firstname+'",
"name": "'+user.displayname+'",
"objectClass": [
"top",
"person",
"organizationalPerson",
"user"
],
"sAMAccountName": "'+task.accountName+'",
"sn": "'+user.lastname+'",
"userAccountControl": "544"'
}
}


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

avinash_16
New Contributor III
New Contributor III

I tried but it still shows the error.
Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript7.groovy: 1: expecting ''', found '\n' @ line 1, column 325. ","userAccountControl": "546"}

I tried adding the "+" sign for "userAccountControl", but still it shows an error: Error while creating account in AD - Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript8.groovy: 1: expecting ''', found '\n' @ line 1, column 327. "userAccountControl": "+546+"}
Thanks.

pmahalle
Valued Contributor II
Valued Contributor II

Hi @avinash_16 ,

Try it once:

${if (user.startdate < sysdate()) {'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson","user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "546"'} else {'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson", "user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "544"'}}


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

avinash_16
New Contributor III
New Contributor III

Yeah the error is now resolved but now I'm getting a new error message.
Checking DN for CN=SamM,OU=AD_Offshore,DC=lab,DC=pronoesis,DC=com.Not FOund DN for CN=SamM,OU=AD_Offshore,DC=lab,DC=pronoesis,DC=com. Error while creating account in AD - No signature of method: SimpleTemplateScript9.sysdate() is applicable for argument types: () values: [] Possible solutions: isCase(java.lang.Object)Checking DN for CN=SamM,OU=AD_Offshore,DC=lab,DC=pronoesis,DC=com.Not FOund DN for CN=SamM,OU=AD_Offshore,DC=lab,DC=pronoesis,DC=com. Error while creating account in AD - No signature of method: SimpleTemplateScript206.sysdate() is applicable for argument types: () values: [] Possible solutions: isCase(java.lang.Object)

Also can you give me an explanation on why that error occurred in the first place and what changes you made so the error got resolved. Please?

Thanks.

pmahalle
Valued Contributor II
Valued Contributor II

Hi @avinash_16 ,

Try to use new Date() instead of sysdate and check.

${if (user.startdate < new Date())

 


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

avinash_16
New Contributor III
New Contributor III

Error message: Error while creating account in AD - Template contains string which are not allowed \bnew\s+(.*?)[(]

${(if user.startdate < new Date())
{'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson","user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "546"'}
else {'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson", "user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "544"'}}

naveenss
All-Star
All-Star

@avinash_16 use the format like below instead of sysdate()

${(if user.startdate < (new java.text.SimpleDateFormat('yyyy-MM-dd').format(new Date())))}{}

Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

avinash_16
New Contributor III
New Contributor III

Tried this but getting this error: Template contains string which are not allowed \bnew\s+(.*?)[(]

CREATEACCOUNTJSON parameter: ${(if user.startdate < (new java.text.SimpleDateFormat('yyyy-MM-dd').format(new Date())))
{'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson","user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "546"'}
else {'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson", "user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "544"'}}

naveenss
All-Star
All-Star

Hi @avinash_16 ,

Can you please try the below changes?

${def currentDate = Calendar.getInstance().getTime().format('yyyy-MM-dd HH:mm:ss');if(user.startdate < (currentDate)){'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson","user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "546"'}else {'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson", "user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "544"'}}
Regards,
Naveen Sakleshpur
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

pmahalle
Valued Contributor II
Valued Contributor II

Hi @avinash_16 ,

Try json provided by @naveenss, if still be an issue try below one once:

 

${(if user.startdate < (api.calendar()))
{'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson","user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "546"'}
else {'"cn": "'+cn+'", "displayname": "'+user.displayname+'", "givenName": "'+user.firstname+'", "name": "'+user.displayname+'", "objectClass": ["top", "person", "organizationalPerson", "user"], "sAMAccountName": "'+task.accountName+'", "sn": "'+user.lastname+'", "userAccountControl": "544"'}}


Regards,

Pandharinath Mahalle(Paddy)
If this reply answered your question, please Accept it As Solution to help others who may have a similar problem.

09
New Contributor III
New Contributor III

dum question, 

why are we  adding + in values? 

'"cn": "'+cn+'", "displayname": "'+user.displayname+'"