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

Dynamic Bound List Boxes using XML file

I'm trying to implement a Bound List Box following the guidance at the following link - https://support.oneidentity.com/active-roles/kb/139754/how-to-create-a-bound-list-box-with-4-levels  Hard-coding the possibilities in the script works but I would like to use an XML file as the source for the Level Possibilities.  The issue is that the values change periodically and we would rather update a source XML rather than periodically edit the script itself.  Has anyone modified the script provided in the KB to use an XML rather than hard-coding the values?     

  • Have you tried loading up some variables based on the values in the XML file at the beginning of the script? Then supplying these arrays as variables at the appropriate spots in the script where it is hard coding the values.

  • Would you be able to go to into more detail regarding the arrays? I have a similar issue where I have my XML values in an array, but I am not sure how to code/point to those values to be drop down values. The original example (the link in the top post with 4 levels) uses a switch statement but if I am looking to make a "dynamic switch statement" (since these values are based on the XML list and can change anytime), I feel like I would need a different logic control. Considering a foreach of some sort, but not 100% sure that would work either. Any suggestions?

  • "...supplying these arrays as variables at the appropriate spots in the script..."  This is exactly where I am.  In my head it seems this should be relatively simple but, unfortunately, I have a lot to learn with powershell.  I'll post a response once I have the placement and syntax sorted.   

  • I was trying to figure out something similar myself - but with CSVs - I also only had one choice at level 2 - but ended up doing it like this:

    function onGetEffectivePolicy($Request)
    {

    $Files = Import-Csv C:\list.csv

    $level1PossibleValues = $Files.Displayname

    $level1 = GetCurrentValue $Request 'edsvaLevel1'

    $level2PossibleValues = $Files | where {$_.Displayname -eq $level1 } | % description


    $Request.SetEffectivePolicyInfo('edsvaLevel1', $Constants.EDS_EPI_UI_POSSIBLE_VALUES, [string[]]$level1PossibleValues)
    $Request.SetEffectivePolicyInfo('edsvaLevel2', $Constants.EDS_EPI_UI_GENERATED_VALUE, [string[]]$level2PossibleValues)


    $Request.SetEffectivePolicyInfo('edsvaLevel1', $Constants.EDS_EPI_UI_RELOAD_EPI_BY_RULE, 'edsvaLevel1')
    #$Request.SetEffectivePolicyInfo('edsvaLevel3', $Constants.EDS_EPI_UI_RELOAD_EPI_BY_RULE, 'eedsvaLevel2')


    $Request.SetEffectivePolicyInfo('edsvaLevel1', $Constants.EDS_EPI_UI_RESTRICTED , $true)
    $Request.SetEffectivePolicyInfo('edsvaLevel2', $Constants.EDS_EPI_UI_RESTRICTED , $true)

    }

    function GetCurrentValue($Request, [string]$AttributeName)
    {
    trap {continue}
    $value = $Request.Get($AttributeName)
    if($value -eq $null)
    {
    $DirObj.GetInfoEx(@($AttributeName),0) | Out-Null
    $value = $DirObj.Get($AttributeName)
    }
    $value
    }

  • I re-implemented the SDK sample by populating from an XML file.

    Here is the sample XML file:

    <?xml version="1.0"?>

    <Departments>

                   <Department name="Development">

                                  <title>SD Engineer</title>

                                  <title>SD Manager</title>

                   </Department>

                   <Department name="Quality Control">

                                  <title>QC Engineer</title>

                                  <title>QC Manager</title>

                   </Department>

                   <Department name="Sales">

                                  <title>Salesperson</title>

                                  <title>Sales Manager</title>

                   </Department>

                   <Department name="Customer Service">

                                  <title>CS Representative</title>

                                  <title>CSR Manager</title>

                   </Department>

    </Departments>

    Save this to the following location on the Active Roles host: C:\Scripts\orgChart.xml

    Here is a working Policy Script:

    function onGetEffectivePolicy($Request)

    {

        if($Request.Class -eq "user")

        {

            $ScriptDir = 'C:\Scripts\orgChart.xml'

            [xml]$XML_Variable = Get-Content -Path $ScriptDir

            $departmentsArray = @()

            $possibleValues = @()

            $xmlDepartments = $XML_Variable.Departments.Department

            $departments = $xmlDepartments.name

            $Request.SetEffectivePolicyInfo('title', $Constants.EDS_EPI_UI_RELOAD_EPI_BY_RULE, 'department')

            $Request.SetEffectivePolicyInfo('department', $Constants.EDS_EPI_UI_POSSIBLE_VALUES, $departments)

            $department = GetCurrentValue -Request $Request -AttributeName 'department'

            ($xmlDepartments | Where-Object{$_.name -eq $department}).title | forEach-Object{ $possibleValues += $_.toString()}

            $Request.SetEffectivePolicyInfo('title', $Constants.EDS_EPI_UI_POSSIBLE_VALUES, $possibleValues)                

        }

    }

     

    function GetCurrentValue($Request, [string]$AttributeName)

    {  

        trap {continue}

        $value = $Request.Get($AttributeName)

        if($value -eq $null)

            {

            $DirObj.GetInfoEx(@($AttributeName),0) | Out-Null

            $value = $DirObj.Get($AttributeName)

            }

        $value

    }

    NOTE: All of these Bound List Box samples only work in the Active Roles Web Interface. This functionality is not possible in the Active Roles Console.

  • NOTE: All of these Bound List Box samples only work in the Active Roles Web Interface. This functionality is not possible in the Active Roles Console.

    Why do ARS MMC  Client and WI Client behave different for end user? Is it to be treated as a bug? (I used to have issues with the Bound List Boxes SDK sample at AR 7.0.x couple years ago, though do not remember was it MMC or WI)

  • This client discrepancy is tied into this line:

    $Request.SetEffectivePolicyInfo('title', $Constants.EDS_EPI_UI_RELOAD_EPI_BY_RULE, 'department')

    The Active Roles SDK notes the following:

    <quote>

    The EDS_EPI_UI_RELOAD_EPI_BY_RULE policy causes the Web Interface to retrieve and reapply the EDS_EPI_UI_POSSIBLE_VALUES and EDS_EPI_UI_GENERATED_VALUE policies only.

    </quote> 

    So, this option is only expected to be available in the Active Roles Web Interface.

    From my testing, this is correct. The Active Roles Console does not query dropdown box changes.

  • thank you! I don't think it is an issue and in real world scenarios WI is the tool for HelpDesk to use.