and more in a single search tool across platforms. Read the announcement here. |
02/03/2023 07:38 AM
Hello,
I'm trying to do a use case where I need to generate a randompassword for non employee users and a password based formula for employee users in the CreateAccountJSON for Active Directory.
Below is the line of code I have.
${if(user?.username.startsWith('XT') || ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount'){"userPassword": "${randomPassword}"} else{"UnicodePwd": "${user?.lastname.substring(0,1).toUpperCase() + user?.lastname.substring(1,2).toLowerCase() + user?.customproperty63 + user?.username.substring(user?.username.length() - 3) + user?.customproperty64.substring(user?.customproperty64.length() -2) + '!'}"}},
I am getting the below error in the log.
Any suggestions, I'm sure I have some sort of syntax error.
Thanks,
Aundre
Solved! Go to Solution.
02/03/2023 07:56 AM
So if I understood your issue you have no problem with non-employee and service account section of logic. You are facing issue with password logic for employee?
02/03/2023 08:05 AM
I got the password logic working previously when it was in the connector by itself. I added in some IF/ELSE logic to the code above to check for if a user is a non employee or a service account. My issue is that I think I have some sort of syntax issue in the below line of code after adding in the IF/ELSE statement. I'm not sure what the issue is.
${if(user?.username.startsWith('XT') || ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount'){"userPassword": "${randomPassword}"} else{"UnicodePwd": "${user?.lastname.substring(0,1).toUpperCase() + user?.lastname.substring(1,2).toLowerCase() + user?.customproperty63 + user?.username.substring(user?.username.length() - 3) + user?.customproperty64.substring(user?.customproperty64.length() -2) + '!'}"}},
The full create account json is below if that helps visualize it better.
{
"sAMAccountName": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task?.accountName : user?.username}",
"displayName": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task.accountName : user?.displayname}",
"mail": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.email}}",
"employeeid": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.employeeid}}",
"CannotChangePassword": "",
"l": "${user?.city}",
"scriptPath": "default.bat",
"givenName": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task?.accountName : user?.firstname}",
"sn": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task?.accountName : user?.lastname}",
"objectclass": [
"top",
"person",
"organizationalPerson",
"user"
],
"userPrincipalName": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task?.accountName : user?.systemUserName}@test.com",
"company": "Test",
"description": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task.accountName : user?.displayname}",
"pwdLastSet": "0",
"department": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.departmentname}}",
"title": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.title}}",
"homePhone": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.phonenumber}}",
"streetAddress": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.street}}",
"st": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.street}}",
"postalcode": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.regioncode}}",
"extensionAttribute1": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.customproperty14}}",
"extensionAttribute2": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.customproperty15}}",
"pager": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.customproperty61}}",
${if(user?.username.startsWith('XT') || ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount'){"userPassword": "${randomPassword}"} else{"UnicodePwd": "${user?.lastname.substring(0,1).toUpperCase() + user?.lastname.substring(1,2).toLowerCase() + user?.customproperty63 + user?.username.substring(user?.username.length() - 3) + user?.customproperty64.substring(user?.customproperty64.length() -2) + '!'}"}},
"accountExpires": "0",
"userAccountControl": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {66048} else{544}}",
"manager": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{managerAccount?.accountID}}"
}
02/03/2023 08:21 AM
Try below
{
"sAMAccountName": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task?.accountName : user?.username}",
"displayName": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task.accountName : user?.displayname}",
"mail": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.email}}",
"employeeid": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.employeeid}}",
"CannotChangePassword": "",
"l": "${user?.city}",
"scriptPath": "default.bat",
"givenName": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task?.accountName : user?.firstname}",
"sn": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task?.accountName : user?.lastname}",
"objectclass": [
"top",
"person",
"organizationalPerson",
"user"
],
"userPrincipalName": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task?.accountName : user?.systemUserName}@test.com",
"company": "Test",
"description": "${ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount' ? task.accountName : user?.displayname}",
"pwdLastSet": "0",
"department": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.departmentname}}",
"title": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.title}}",
"homePhone": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.phonenumber}}",
"streetAddress": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.street}}",
"st": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.street}}",
"postalcode": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.regioncode}}",
"extensionAttribute1": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.customproperty14}}",
"extensionAttribute2": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.customproperty15}}",
"pager": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{user?.customproperty61}}",
"UnicodePwd": "${if(user?.username.startsWith('XT') || ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {randomPassword} else{user?.lastname.substring(0,1).toUpperCase() + user?.lastname.substring(1,2).toLowerCase() + user?.customproperty63 + user?.username.substring(user?.username.length() - 3) + user?.customproperty64.substring(user?.customproperty64.length() -2) + '!'}}",
"accountExpires": "0",
"userAccountControl": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {66048} else{544}}",
"manager": "${if(ServiceAccountOwnerMap.get("ServiceAccountType") == 'ServiceAccount') {} else{managerAccount?.accountID}}"
}
02/03/2023 11:11 AM
This worked, thank you!