Password Manager

Powershell Custom Activity Write into AD

Hello,

I am looking to create a custom activity that can allow user to update certain custom attributes in Active Directory.

Inside the SDK documentation, I have noticed a UserAccountInfo class and AttributeInfo class.

Please enlighten me on how can I utilize them in custom activity.

Thank you

Parents
No Data
Reply
  • Hi Terrance,

    Thank you for the suggestion.

    Currently I have wrote this in the custom activity

    function PostLoad($workflow, $activity)
    {
        #Edit this list to specify additional attributes that can contain phone numbers
        $ATTRS = [string[]] ("mobile", "mail")

        #Obtain user's AD Attributes' Values
        $user = $global.GetUserById($workflow.UserInfo.Domain, $workflow.UserInfo.Id, $ATTRS)

        if ($user -eq $null) {
            $workflow.CriticalError([QPM.Common.Scenarios.WorkflowErrorCode]::SystemError, "User not found")
        } else {
            #Populate textboxes with retrieved values
            $i = 0

            $ATTRS | %{
                $num = $user[$_]
                #retrieve and output attributes into individual textbox
                $num = $num.ToString()
                $activity.RunTime.Controls["elementID_$i"].Value = $num
                $i = $i + 1
            }
            if ($i -eq 0) {
                #No phone numbers could be used for authentication
                $workflow.CriticalError([QPM.Common.Scenarios.WorkflowErrorCode]::PhoneAuthenticationPhoneNumbersNotSet)
            }
        }
    }
    function PreExecuting($workflow, $activity)
    {
        #Add code to be executed after activity UI is shown, but before activity main part is executed here
        $workflow.UserInfo.AccountInfo.mobile = $activity.RunTime.Controls["elementID_0"].Value
        $workflow.UserInfo.AccountInfo.Mail = $activity.RunTime.Controls["elementID_1"].Value

    }

    I am able to retrieve the AD attribute's value:
    $activity.RunTime.Controls["elementID_$i"].Value = $workflow.UserInfo.AccountInfo.Mail

    But I am not able to update a new value into the AD attribute after I press "Next" in the GUI.

    this is the syntax I have used as shown in the above code: $workflow.UserInfo.AccountInfo.Mail = $activity.RunTime.Controls["elementID_1"].Value

    Will you be able to assist?

Children
No Data