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

Use workflow script to modify attribute of removed member

I have a need to modify an attribute whenever a user is removed from a group. Stored in every users extensionattribute5 are values like this   1024adm;1025adm;1969adm;1429adm;

 

We have matching groups for each of those values.   What I would like is that when a user is removed from group 1969adm it removes that text from the users extensionattribute5.    I was hoping a workflow would do the trick BUT i am having a hard time referencing the user that was removed from the group.

When i use an script to get a variable for the object it references the group and not the user.

function onPreModify($Request)
{
$attrib = $Dirobj.get("extensionattribute5")    #this reads groups extensionatttribute5.
return $attrib
}

Any help on how to reference the user(Activity target) in a powershell script would be great.  

Thanks

 

 

  

 

  • If you are triggering on a group member add/remove then your workflow activity target IS the group and attributes you try to obtain using $Dirobj will be those of the group.

    You could instead trigger on a change to a user's "memberof" - this would give you the name of the group they were removed from. It would also mean that the attribute set you accessed using $Dirobj would now be that of the affected user.
  • Thanks I understand that logic. I do need to do change workflow on the group though. Under the "Activity Target" and "Target properties" I can ALMOST do what i need but i need to do it via scripting.
    I have set the activity target to be the "Distinguished Name of the Removed Member" but in the next screen "Target properties" i select script and then need to reference that user object. It seems via the GUI it is possible, so i would think that it could be possible via scripting if you knew what to reference as an object.
  • OK - since you have figured out the Activity Target, you should be able to do something like this to get the DN of the object in question:

    $WorkflowStepName = "Insert name of the workflow step that you want to get the object name from"

    $MyTargetObject = $workflow.ActivityTarget($WorkflowStepName).get("distinguishedName")
  • It seems like the script module that I am trying to write does not have reference to any of the workflow reference activities. For example if i try to make reference to a saved property from an earlier "Save object Properties" activity i cant access any of the data.

    $Workflow.SavedObjectProperties("Saved").get("description")