Generating a unique CN and UPN Prefix

Hi,
I'm trying to write a script that will check the build the Uniqueness value of the cn attribute and then set the UPNPrefix (edsaUPNPrefix) attribute to the CN. I understand that the normal way is just to set a uniqueness value at the end of the SAM account name by Policy. However, that is not what I want. because the SAMAccountName is: . (J.Smith, J.Smith1 etc) but the CN has to be . (John.Smith, John.Smith1 etc).
A further complication is that it has to construct the CN by just the givenName, sn and the SAMAccountName. Added to that, the givenName and sn are provided by SPML code from a HR database. So the cn has to be constructed on a PreCreate method. That is, BEFORE the duplicate cn is detected.
As the SAM Account name is the only attribute that automaticall adds a uniqueness number on create, I have written a script that will on preCreate: 1. Read the last diget of the SAM and 2. if a number exists at the end of the SAM, add that value to the sn and 3. let the Policy validation build the CN and UPN Prefix. But this does not seem to actually change the object's sn even though a get sn after a put on the sn attribute indicates that it has in my script logging.
Any alternative ideas would be greatly appriciate.

  • The tricky thing is that you cannot set the CN per se.  You can set the Name which will then get used to set the CN and the DN.

    To maximize control of the process, I would do something like this:

    $NewName = $Request.get("givenname") + $Request.get("sn") + $Request.get("samaccountname")

    $Request.put("Name",$NewName)

    Having said this, I have struggled in the past with setting the Name BEFORE the account create and have often resorted to updating it after the fact - either with a Property Update Activity in a Change Workflow that is triggered by the User Create OR in an OnPostCreate handler.

    'Hope this gives you some food for thought.

  • Certainly does thanks, I will try this and update this forum as to the progress.

    Thanks