Set virtual Attribute in User Provisioning Process

Hello,

i want to set a virtualAttribute in the user provisioning process. We enter the Last Name and we want to save it temp without "Ä/Ö etc.".

After that we want to use this virtual attribute for generating the SAM-Accountname

Thanks in advance,

Michael

Parents
  • Hi  

    You can use something like the below (not my code, src: active directory - How remove accents in PowerShell? - Stack Overflow) to remove Diacritics from a string. I've used something similar before to the below code to remove special characters.

    function Remove-Diacritics {
    param ([String]$src = [String]::Empty)
      $normalized = $src.Normalize( [Text.NormalizationForm]::FormD )
      $sb = new-object Text.StringBuilder
      $normalized.ToCharArray() | % { 
        if( [Globalization.CharUnicodeInfo]::GetUnicodeCategory($_) -ne [Globalization.UnicodeCategory]::NonSpacingMark) {
          [void]$sb.Append($_)
        }
      }
      $sb.ToString()
    }
    
    # Test data
    @("Rhône", "Basíl", "Åbo", "", "Gräsäntörmä") | % { Remove-Diacritics $_ }

    However please note this is not a perfect solution for all languages, but will probably hit 90 to 95%

    Also note if you're using this to samAccountName, it will not take account of other special characters in the string like ' or - for names like "O'Neil" or "Smith-Jones", which you'll need to handle seperately

    Hope this help

  • Hi Stu,

    i already have a script in place which replaces the characters i do not want (PostCreate). But we use Lastname and Forename to generate the SAM with 8 characters. After replacing the unwanted characters we have the issue that the SAM is 9 or more characters long.

    What we want is to save the lastname into the virtual attribute and use this one for generating the SAM in the user privisoning process.

    Can you help me out here? What i tried is:
    $Request.SetEffectivePolicyInfo($virtualattribute, $Request.EDS_EPI_UI_GENERATED_VALUE, $adaptedlastname)

    But this is not working.


    Regards,

    Michael

  • I would use a Change Workflow that intercepts the user create for this:

    Place all of these before the user create action in the workflow:

    1.  Pickup the lastname (sn) from the inbound user create and store it to your virtual attribute using a Modify Requested Changes Activity workflow Activity.

    2.  Fire your diacritics cleanup script against the contents of the VA using script Activity.

    3.  Use another Modify Requested Changes Activity to setup the samaccountname as you like - either use the built in rule therein or link a script as required.

  • Re Item 2 above, the VA will now be part of the $Request so you can retrieve its contents from your script thus:

    $NameToFix = $Request.Get("MyVA")

  • Thank you for the help. One more question regarding 2) --> Do i need any trigger in this script or how can i replace the content of the va?

    Just use something like that?

    Request.Put "VA", Replace(Replace(Replace(Replace(Replace(Replace(Request.Get("samAccountName"), "ä", "ae"),"ö", "oe") ,"ü","ue"),"ß","ss"),"é","e"),"è","e")

Reply
  • Thank you for the help. One more question regarding 2) --> Do i need any trigger in this script or how can i replace the content of the va?

    Just use something like that?

    Request.Put "VA", Replace(Replace(Replace(Replace(Replace(Replace(Request.Get("samAccountName"), "ä", "ae"),"ö", "oe") ,"ü","ue"),"ß","ss"),"é","e"),"è","e")

Children