DESCRIPTION
Validate moving operations. Apply this script policy to the Active Directory node.
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
'***********************************************************************************
'** CUSTOMIZABLE SETTINGS
'***********************************************************************************
Const strInterestingClass = "computer"
Const strInterestingAttribute = "name"
Const strErrorMessage = "This object can't be moved to this container"
Const strScriptName = "Validate moving operations"
'***********************************************************************************
'** SUBROUTINES
'***********************************************************************************
Function GetParameter(ByRef Request, ByVal strName)
On Error Resume Next
GetParameter = Request.Parameter(strName)
On Error GoTo 0
End Function ' GetParameter
Function GetAttribute(ByRef objObject, ByVal strName)
On Error Resume Next
GetAttribute = objObject.Get(strName)
On Error GoTo 0
End Function ' GetAttribute
'***********************************************************************************
'** EVENT HANDLERS
'***********************************************************************************
Sub onPreMove(Request)
If (LCase(Request.Class) <> LCase(strInterestingClass)) Then Exit Sub
Dim strTargetContainerDN, strObjectName
'--- get distinguished name of target container
strTargetContainerDN = GetParameter(Request, "TargetContainer")
'--- get object name
strObjectName = GetAttribute(Request, strInterestingAttribute)
'--- validation. replace this condition with your own condition using strTargetContainerDN and strObjectName
If (- some condition-) Then
'--- prevent moving and report an event
Err.Raise 1, strScriptName, strErrorMessage
End If
End Sub
'***** END OF CODE ***************************************************************