DESCRIPTION
A common Active Roles query is how to replace national characters (for ex: æ,ø,å) with general Latin characters (for ex: ae, o, a) in generated user logon name (sAMAccountName) based on a user first & last names that can contain these national characters.
Here is a step-by-step guide:
- Using the Active Roles Console, create a virtual attribute (VA), name it edsvaFirstName (DirectoryString syntax, single-valued, non-stored in Active Roles DB), and apply it to the user object class.
- Create a second VA, name it edsvaLastName (DirectoryString syntax, single-valued, non-stored in Active Roles DB), and apply it to the user object class.
- Reconnect the Active Roles Console to refresh the console schema cache.
- Create a script module, copy-paste the SCRIPT ONE code from this article into the script module.
- Create a second script module, copy-paste the SCRIPT TWO code from this article into the second script module.
- Create a policy object with the User Logon Name Generation Policy with one or many generation rules based on the edsvaFirstName & edsvaLastName virtual attributes, not on the givenName & sn attributes (Active Directory defined attributes for user first & last names).
- Add to this policy object two script execution policies: one for SCRIPT ONE, another for SCRIPT TWO. Arrange the policies in the following order:
- SCRIPT ONE Script Execution Policy
- User Logon Name Generation Policy
- SCRIPT TWO Script Execution Policy
- Apply this policy object to the desired scope.
And now, it is time to test our solution:
- Start the New User Wizard in an OU where the policy object is applied.
- In the wizard fill the user's first & last names containing national characters
- Press a small button with lightning (Generate button) nearby User Logon Name (pre-Windows 2000) entry.
- Ensure that the generated user logon name doesn't contain any national accent characters. All the national character should be replaced with Latin equivalents.
NOTE: The SCRIPT ONE & SCRIPT TWO scripts use several functions from the Active Roles Script Policy Best Practices library. Just copy-paste these functions from the library to SCRIPT ONE & SCRIPT TWO.
SCRIPT ONE code
'*********************************************************************************
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
' PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.
'*********************************************************************************
Option Explicit
'===========================================================================
Function Correct(ByVal strValue)
strValue= Replace(strValue, "æ", "ae")
strValue= Replace(strValue, "ø", "o")
strValue= Replace(strValue, "å", "a")
Correct = strValue
End Function
'===========================================================================
' EVENT HANDLERS
'===========================================================================
Sub onCheckPropertyValues(Request)
If (Not IsObjectClassRequested("user", Request)) Then Exit Sub
Request.Put "edsvaFirstName", Correct(GetAttribute("givenName", Request))
Request.Put "edsvaLastName", Correct(GetAttribute("sn", Request))
End Sub
Sub onPreCreate(Request)
If (Not IsObjectClassRequested("user", Request)) Then Exit Sub
Request.Put "edsvaFirstName", Correct(GetAttribute("givenName", Request))
Request.Put "edsvaLastName", Correct(GetAttribute("sn", Request))
End Sub
' ****** END OF CODE **********************************************************
SCRIPT TWO code
'*********************************************************************************
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
' PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.
'*********************************************************************************
'
Option Explicit
'===========================================================================
Function Correct(ByVal strValue)
strValue= Replace(strValue, "æ", "ae")
strValue= Replace(strValue, "ø", "o")
strValue= Replace(strValue, "å", "a")
Correct = strValue
End Function
'===========================================================================
' EVENT HANDLERS
'===========================================================================
Sub onGetEffectivePolicy(Request)
If (Not IsObjectClassRequested("user", Request)) Then Exit Sub
If (Not IsAttributeGenerationRequested("sAMAccountName", Request)) Then Exit Sub
Request.Put "edsvaFirstName", Correct(GetAttribute("givenName", Request))
Request.Put "edsvaLastName", Correct(GetAttribute("sn", Request))
End Sub
' ****** END OF CODE **********************************************************