Back to ARS Script Policy Best Practices
And at last, example of well-formed ARS script policy that uses the suggested library.
Option Explicit
Sub onPostGet (Request)
'-- serve user accounts only
If (Not IsObjectClassRequested("user", Request)) Then Exit Sub
'-- serve specified attribute only
If (Not Request.IsAttributeRequested("esdvaMyAttribute1")) Then Exit Sub
Request.Put "esdvaMyAttribute1", "some value"
End Sub
Sub onPreModify (Request)
'-- serve user accounts only
If (Not IsObjectClassRequested("user", Request)) Then Exit Sub
'-- serve specified attribute only
If (Not IsAttributeModified("esdvaMyAttribute2", Request)) Then Exit Sub
Dim strOldValue, strNewValue
'-- prepare old values reading
DirObj.GetInfoEx Array("esdvaMyAttribute2"), 0
'-- read old value
strOldValue = GetAttribute ("esdvaMyAttribute2", DirObj)
'-- read new value
strNewValue = GetAttribute ("esdvaMyAttribute2", Request)
'-- if a new value is same as an old value
If (strOldValue = strNewvalue) Then
'-- generate a new value for the processed attribute
Request.Put "esdvaMyAttribute2", "some value"
End If
End Sub