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

Space in System username

haardik_verma
Regular Contributor
Regular Contributor

Hi,

We had an issue where if there are 2 words in firstname of user, the AD account name is having space in between. (we do not want spaces in samaccountname and UPN)

Example:

User Firstname: Karan Arjun

User Lastname: Aayenge

The AD Account name was generated as: adminKaran ArjunA  (notice there is a space)

The CHECKFORUNIQUE configured is:

{"sAMAccountName": "${
if(('admin'.concat(user.firstname).concat('.').concat(user.lastname)).length()<20){'admin'.concat(user.firstname).concat('.').concat(user.lastname)}else{'admin'}
}###${
if(('admin'.concat(user.firstname).concat(user.lastname.substring(0,1))).length()<20){'admin'.concat(user.firstname).concat(user.lastname.substring(0,1))}else{'admin'}
}###${
if(('admin'.concat(user.firstname).concat(user.lastname.substring(0,2))).length()<20){'admin'.concat(user.firstname).concat(user.lastname.substring(0,2))}else{'admin'}
}###${
if(('admin'.concat(user.firstname.substring(0,1)).concat(user.lastname)).length()<20){'admin'.concat(user.firstname.substring(0,1)).concat(user.lastname)}else{'admin'}
}###${
if(('admin'.concat(user.firstname.substring(0,3)).concat(user.lastname.substring(0,3))).length()<20){'admin'.concat(user.firstname.substring(0,3)).concat(user.lastname.substring(0,3))}else{'admin'}
}###${
if(('admin'.concat(user.firstname).concat(user.lastname.substring(0,3))).length()<20){'admin'.concat(user.firstname).concat(user.lastname.substring(0,3))}else{'admin'}
}###${
if(('admin'.concat(user.firstname).concat(user.lastname.substring(0,4))).length()<20){'admin'.concat(user.firstname).concat(user.lastname.substring(0,4))}else{'admin'}
}###${
if(('admin'.concat(user.firstname.substring(0,2))).concat(user.lastname).length()<20){'admin'.concat(user.firstname.substring(0,2)).concat(user.lastname)}else{'admin'}
}###${
if(('admin'.concat(user.firstname.substring(0,3))).concat(user.lastname).length()<20){'admin'.concat(user.firstname.substring(0,3)).concat(user.lastname)}else{'admin'}
}###${
if(('admin'.concat(user.firstname.substring(0,4))).concat(user.lastname).length()<20){'admin'.concat(user.firstname.substring(0,4)).concat(user.lastname)}else{'admin'}
}","userPrincipalName": "admin${user.systemUserName}@email.com###SameAsSamaccountname"}

 

This I solved by adding .replaceAll in the sAMAccountName like this

###${
if(('admin'.concat(user.firstname).concat(user.lastname.substring(0,1))).length()<20){'admin'.concat(user.firstname).concat(user.lastname.substring(0,1)).replaceAll(' ','')}else{'admin'}

But for UPN, it uses the system user name. 

Now I need help in 2 things here.

1) What is correct syntax to use replaceAll in the UserPrincipalName(UPN) part of CHECKFORUNIQUE ?

2) If I do not want to add replaceAll in UPN logic, then I have to dependent on system Username to remove the space.

So if there is space in first name of user, the System username will also have space, hence the UPN will also have space.

Now here is the main problem for which I raised this ticket.

While testing with the above example user, that has space in firstname, his systemusername did not have space.

User System Username: KaranArjun.Aayenge

 

I looked around and found that the global configuration has provision of adding rules for creation of system username..But when I checked that query, it did not have any logic for removal of space..

The existing System Username Generation Rule:

case when char_length(concat(FN_REMOVE_ACCENTS1(users.firstname) , '.', FN_REMOVE_ACCENTS1(users.lastname)))&lt;20
then concat(FN_REMOVE_ACCENTS1(users.firstname) , '.', FN_REMOVE_ACCENTS1(users.lastname))
else 'admin'
end
###
case when char_length(concat(FN_REMOVE_ACCENTS1(users.firstname), '.', substring(FN_REMOVE_ACCENTS1(users.lastname),1,1)))&lt;20
then concat(FN_REMOVE_ACCENTS1(users.firstname), '.', substring(FN_REMOVE_ACCENTS1(users.lastname),1,1))
else 'admin'
end
###
case when char_length(concat(substring(FN_REMOVE_ACCENTS1(users.firstname),1,1), '.', FN_REMOVE_ACCENTS1(users.lastname) ))&lt;20
then concat(substring(FN_REMOVE_ACCENTS1(users.firstname),1,1), '.', FN_REMOVE_ACCENTS1(users.lastname) )
else 'admin'
end
###
case when (FN_REMOVE_ACCENTS1(users.middlename) is not null) and (char_length(concat(FN_REMOVE_ACCENTS1(users.firstname), substring(FN_REMOVE_ACCENTS1(users.middlename),1,1), '.', substring(FN_REMOVE_ACCENTS1(users.lastname),1,1))))&lt;20
then concat(FN_REMOVE_ACCENTS1(users.firstname),substring(FN_REMOVE_ACCENTS1(users.middlename),1,1),'.', substring(FN_REMOVE_ACCENTS1(users.lastname),1,1))
else 'admin'
end
###
case when char_length(concat(substring(FN_REMOVE_ACCENTS1(users.firstname),1,3), '.', substring(FN_REMOVE_ACCENTS1(users.lastname),1,3) ))&lt;20
then concat(substring(FN_REMOVE_ACCENTS1(users.firstname),1,3), '.', substring(FN_REMOVE_ACCENTS1(users.lastname),1,3) )
else 'admin'

end
###
case when char_length(concat(FN_REMOVE_ACCENTS1(users.firstname), '.', substring(FN_REMOVE_ACCENTS1(users.lastname),1,2) ))&lt;20
then concat(FN_REMOVE_ACCENTS1(users.firstname), '.', substring(FN_REMOVE_ACCENTS1(users.lastname),1,2) )
else null end
###

The function FN_REMOVE_ACCENTS1 was designed by saviynt team to replace accented characters, but upon checking, it surely does not remove spaces.

haardik_verma_0-1674831520240.png

Now I am unable to understand, from where the space got removed automatically in system username ?

 


Thanks & Regards,
Haardik Verma
3 REPLIES 3

rushikeshvartak
All-Star
All-Star
,"userPrincipalName": "admin${user.systemUserName.replaceAll(' ','')}@email.com###SameAsSamaccountname"

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

Thanks @rushikeshvartak .

Any idea about the 2nd question? How is the space getting removed without any space removal logic in place?


Thanks & Regards,
Haardik Verma

Saviynt must internally doing with code.


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