DESCRIPTION
Performs some case conversion to the user name to conform to a standard convention.
Note This code may use functions from the ARS Script Policy Best Practices. Please, follow the link to obtain instructions and code for those functions.
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 MERCHANTBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
' PLEASE CONTACT QUEST PROFESSIONAL SERVICES.
'*********************************************************************************
'
' This code is published on the ActiveRoles Script Center:
' http://communities.quest.com/docs/DOC-9991
'
' This code may use functions from the ARS Script Policy Best Practices:
' http://communities.quest.com/docs/DOC-10016
'
' Please, follow the link to obtain instructions and code for those functions.
'*********************************************************************************
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' (C) 2007 Quest Software, Inc.
'' This script is a part of custom solution for Quest ActiveRoles Server
'' delivered by Quest according to applicable Statement of Work. For
'' support policy please refer to Exhibit 2 of SOW.
''
'' PLEASE DO NOT MODIFY THIS FILE. It is protected by cryptographic
'' digital signature to ensure original contents.
''
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
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 ***************************************************************
COMPATIBILITY
Script compatible with the following version(s): <Not specified>