Policy user logon name Compound Name

Hello!
In Spain it is very common to have compound names, for example: Maria Del Carmen.
I am looking for how to create the samaccountname as follows:
Maria (Attribute 1)
Del Carmen (Attribute 2)
Perez (Attribute 3)
First letter of attribute 1 + First letter of attribute 2 (without "Del") + attribute 3
The idea is that attribute 2 is counted from space because it can be "From" or "From"
Can you help me?
Thank you!

  • Hi  

    There are two methods you could use

    1) Instead of 3 attributes, have 4, IE: Maria Del Carmen Perez would be entered into

    Attribute1: Maria

    Attribute2: Del

    Attribute3: Carmen

    Attribute4: Perez

    The user the OOTB Username generation, where you use 

    1%<Attribute1>%1%<Attribute3>%%<Attribute4>%

    Creating

    MCPerez

    You may need to add a counter to the end so if the username is already taken, it adds a number.

    This would mean that if the user does not have a compound name, you'd leave attribute 2 blank, and put the value into attribute 3 only

    2) The other option is to script the creation of the samAccountName, where you

    • Retrieve the first characters of Attribute1
    • Retieve the whole value of Attribute2, then
      • Split on " " (space)
      • Check the number of elements in the array
      • If value > 1, take the first value of item 1 (second item in the array)
      • If value = 1, take the first character of Attribute2
    • Retrieve the whole value of Attribute3
    • Combine the values to create the samaccountName
    • Check if the samAccountName is already in use, if not use that value, otherwise, add a number, until you get a unique entry.

    You have two options here also, you could write the value to a customAttribute, then use that in the OOTB username genreation to use your generated value as the source, or you could write the script to directly write the value to samAccountName

    Hope this helps

    Stu

  • Thank you!
    I discarded option 1, because when they fill it up, they might do it wrong.
    I’ll see if I can make the script work!
    Thanks for your help!