and more in a single search tool across platforms. Read the announcement here. |
01/08/2024 11:49 AM
When creating AD Accounts in our environment we need to be able to configure different UserPrincipalName (UPN) based on the company name.
Is it possible to use CASE statements in CREATEACCOUNTJSON on the AD connexion?
We are doing something similar on our email generation rule, but I wasn’t sure if this is also an option in CREATEACCOUNTJSON. If not, we would like to know how to achieve this using another technique.
Example:
CASE
WHEN (users.companyname like '%company1.com%') THEN lower(concat(substring(users.systemUserName,1,8),'@company1.com'))
WHEN (users.companyname like '%company2.com%') THEN lower(concat(substring(users.systemUserName,1,8),'@company2.com'))
ELSE lower(concat(substring(users.systemUserName,1,8),'@defaultcompany.com'))
END
Thank you for the help!
Solved! Go to Solution.
01/08/2024 06:32 PM
In Json you need to use if-else or java ternary condition ( java function and not mysql)
"companyname": "${ if(user?.companyname.contains('company1.com'))
{user?.systemUserName.substring(0, Math.min(8, systemUserName.length())).concat("@company1.com").toLowerCase()}
else {if (user?.companyname.contains('company2.com')
{user?.systemUserName.substring(0, Math.min(8, systemUserName.length())).concat("@company2.com").toLowerCase()}
else
{user?.systemUserName.substring(0, Math.min(8, systemUserName.length())).concat("@defaultcompany.com").toLowerCase()}}}"
01/10/2024 05:20 AM
Hi rushikeshvartak,
Thank you very much for this useful information. I was able to make this work, but I had to work around a few issues along the road and make some adjustments from your suggestion.
I am sharing this here in case someone else needs to do something similar and run into similar issues.
Your suggestion:
"companyname": "${ if(user?.companyname.contains('company1.com')) {user?.systemUserName.substring(0, Math.min(8, sy...} else {if (user?.companyname.contains('company2.com') {user?.systemUserName.substring(0, Math.min(8, systemUserName.length())).concat("@company2.com").toLowerCase()} else {user?.systemUserName.substring(0, Math.min(8, systemUserName.length())).concat("@defaultcompany.com").toLowerCase()}}}"
What worked for me looks like this:
"userPrincipalName": "${ if(user?.companyname.contains(defaultcompany)) {user?.systemUserName.concat('@defaultcompany.com').toLowerCase()} else {if(user?.companyname.contains('company1')) {user?.systemUserName.concat('@company1.com').toLowerCase()} else {if (user?.companyname.contains('company2')) {user?.systemUserName.concat('@company2.com').toLowerCase()}}}}",
Thank you again for the help!