This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

onPostModify Function

I'm writing a post modify PS function that updates the email address. I only want it to run if the first or last name is modified.

How do I tell within the $request what attribute was modified so I can stop the function if it wasn't first or last name?

 

Thank you.

Parents
  • I strongly recommend to look at ARS SDK (contains sample code) look at other legacy forums.
    here is example:
    --------------
    function onPreModify($Request)
    {
    if ($request.Class -ne "user") {return}

    if (IsAttributeModified "desriptiopn" $Request) {
    #If AD\user.description is modified do action here
    }
    }
    # IsAttributeModified
    function IsAttributeModified([string]$attr,$Request)
    {
    [bool]$Modified = $False
    if($Request -ne $null)
    {
    $Item = $Request.GetPropertyItem($attr,0)
    if($Item -ne $null)
    {
    if($Item.ControlCode -ne 0) { $Modified = $true }
    }
    }
    return $Modified
    }
Reply
  • I strongly recommend to look at ARS SDK (contains sample code) look at other legacy forums.
    here is example:
    --------------
    function onPreModify($Request)
    {
    if ($request.Class -ne "user") {return}

    if (IsAttributeModified "desriptiopn" $Request) {
    #If AD\user.description is modified do action here
    }
    }
    # IsAttributeModified
    function IsAttributeModified([string]$attr,$Request)
    {
    [bool]$Modified = $False
    if($Request -ne $null)
    {
    $Item = $Request.GetPropertyItem($attr,0)
    if($Item -ne $null)
    {
    if($Item.ControlCode -ne 0) { $Modified = $true }
    }
    }
    return $Modified
    }
Children
No Data