DESCRIPTION
The corporate policy may demand all newly created user should be located in special OU This script demonstrates how to meet this requirement.
Note: Check "Wait while post-event handlers complete operation" checkbox on policy entry UI.
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.
'*********************************************************************************
Option Explicit
'-- distinguished name of special OU
Const strAnotherOUDN = "OU=Special,DC=foo,DC=com"
'**************************************************************************
' EVENT HANDLERS
'**************************************************************************
Sub onPreCreate(Request)
'-- trigers for user object only ----------------
If (LCase(Request.Class) <> "user") Then Exit Sub
Dim strCN, strNewDN
'-- get cn --------------------------------------
strCN = Request.Get("cn")
'-- construct new dn for user object ------------
strNewDN = "CN=" & strCN & "," & strAnotherOUDN
Call Request.PutEx(ADS_PROPERTY_UPDATE, "distinguishedName", strNewDN)
'-- inform Web Interface that dn is changed
Call Request.PutOutControl(EDS_CONTROL_OBJECT_DN, 3, strNewDN)
End Sub ' onPreCreate
'***** END OF CODE ********************************************************