The unique username generator rule will generate a unique username for an Active Directory source.
Requirements
Access to IdentityNow
Guide
With this rule you’ll be able to generate a unique username and check for uniqueness for an Active Directory source.
The unique username will be generated as follows.
Retrieve the first name, last name and other name of the user.
Remove diacritical marks and remove any characters outside the range [a-zA-Z0-9]
If the other name is not available, use the first name.
First, check the length of (othername | firstname).lastname. If it is greater than 12 then use the first 12 letters of the first name, add a period . and append the first character of the last name. Convert to lowercase. Check for uniqueness.
If it is not unique then use the first 12 characters of the first name and add a period . and append the second character of the last name. Convert to lowercase. Check for uniqueness.
Follow this pattern until a unique username is found. If all characters of the last name are exhausted, return null.
This is excellent, thank you so much for sharing
my java is not strong enough, how does this rule treat names that contain a character with an accent like “é”?
In this particular rule there is sanitization that will remove all characters that are not within the following ranges a-z, A-Z or 0-9 this will remove characters with diacritical marks like you’ve shown.
That would be a great addition to the rule, I tested it out and it works well!
If you’re comfortable with creating a PR to add this new code feel free, otherwise I can take care of it for you. I would add it to the sanitation checks like below:
@tyler_mairose Thank you so much for testing it out, you saved me a ton of time and tickets
please feel free to take care of it and use it in your code
What happens in the scenario when you run out of letters of the surname? ie There are 6 ‘Sam Smith’ in your database Do they not get a username?
Why not add a number afterwards and then you’ll never run out of options