DESCRIPTION
Performs some case conversion to the user name to conform to a standard convention.
SCRIPT
'*********************************************************************************
' 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.
'*********************************************************************************
Sub onPreCreate(Request)
If Request.Class "user" Then Exit Sub
Dim strUsername
Dim strFirstName
Dim strLastName
Dim strLogonNamePW2K
Dim strLogonName
strLastName = ChangeCase(Request.Get("sn"))
strFirstName = ChangeCase(Request.Get("givenName"))
strUsername = strFirstName & " " & strLastName
strLogonNamePW2K = Request.Get("samAccountName")
strLogonName = Request.Get("userPrincipalName")
Request.Put "cn", strUsername
Request.Put "displayName", strUsername
Request.Put "samAccountName", LCase(strLogonNamePW2K)
Request.Put "userPrincipalName", LCase(strLogonName)
Request.Put "givenName", strFirstName
Request.Put "sn", strLastName
End Sub
Private Function ChangeCase(strName)
Dim oRegExp
Dim oMatches
Dim oMatch
strName = UCase(Left(strName,1)) & LCase(Right(strName, Len(strName)-1))
Set oRegExp = New RegExp
oRegExp.Pattern = "[\s\-']"
oRegExp.Global = True
Set oMatches = oRegExp.Execute(strName)
For Each oMatch In oMatches
strName = Left(strName, oMatch.FirstIndex+1) & _
UCase(Mid(strName, oMatch.FirstIndex+2, 1)) & _
Mid(strName, oMatch.FirstIndex+3, Len(strName)-3)
Next
Set oMatch = Nothing
Set oMatches = Nothing
Set oRegExp = Nothing
ChangeCase = strName
End Function
'***** END OF CODE ***************************************************************