DESCRIPTION
This script policy sample stamps the "manager" attribute (DN syntax) by given "manager' employee id" value during user creation and modification.
The sample assumes that the user class schema is extended by edsvaManagerId virtual attribute (Directory String syntax, stored in ARS DB).
Some notes:
- This sample is just a demo and has limited set of error handling.
- Using of this sample can dramatically decrease an ARS performance during bulk operations of user creation/modification.
Note This code may use functions from the Active Roles 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 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
'******************************************
' EVENT HANDLERS
'******************************************
Sub onPreCreate(Request)
Call Execute(Request)
End Sub ' onPreCreate
Sub onPreModify(Request)
Call Execute(Request)
End Sub ' onPreCreate
'******************************************
' helping routines
'******************************************
Sub Execute(ByRef Request)
If (Not IsObjectClassRequested("user", Request)) Then Exit Sub
If (Not IsAttributeModified("edsvaManagerId", Request)) Then Exit Sub
Dim strId, strDn
strId = GetAttribute("edsvaManagerId", Request)
strDn = GetDnById(strId)
Request.Put "manager", strDn
End Sub
Function GetDnById(ByVal strId)
Dim objRS
Set objRS = DoARSSearch("OU=Emplyees,DC=foocompany,DC=com", _
"(&(objectClass=user)(objectCategory=person)(employeeId=" & strId & "))", _
"distinguishedName", _
"SubTree")
If (Not objRS.EOF) Then
GetDnById = objRS("distinguishedName")
Else
GetDnById = Empty
End If
End Function
'***** END OF CODE ***************************************************************