Setting Virtual Attribute on the fly when user Properties are opened

Hey Everyone,

First post and still quite a newb with Active Roles so don't mind the brief ignorance you may see :)

Basically my end goal is to make a Tab in the web interface User Object properties window only visible when a virtual attribute is set to true.

I have the WI all ready with the visibility settings looking for my va to be true.

I am now trying to get a policy script which will populate that at the opening or right before the user properties opens so it can determine if the va is true or not for visibility.

I have all my logic setup to determine it in a policy script, I just cant seem to write anything to the VA .

Can anybody see if anything is seriously out of place or if I am completely in the wrong area to make my end goal happen.  Don;t mind all the debug statements,  Its just for testing.

My Put statement just doesn't work.

function onGetEffectivePolicy($Request) {
    if ($Request.Class -eq "User") {
    
        # Manual Test variables
        # $EmpID = "01234567"
        # $SAM = "comp1User1"
        # $BA = "Company 1"

        $DirObj.GetInfoEx(@("edsvaACsAMAccountRenameVIS"), 0)

        # Populate variables from user object
        $SAM = [string]$DirObj.Get("samAccountName")
        $BA = (get-qaduser $Request.name -DontUseDefaultIncludedPropertie -includedProperties 'extensionAttribute3').'extensionAttribute3'
        $EmpID = (get-qaduser $Request.name -DontUseDefaultIncludedPropertie -includedProperties 'employeeid').'employeeid'

        Write-Debug "onGetEffectivePolicy" "Entered $EmpID $SAM"
        Write-Debug "onGetEffectivePolicy" "Entered Name =  Request.Name"
        
        $newSAM = "a" + $EmpID
        Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - EmpID is $EmpID `n SAM = $SAM `n NewSAm = $NewSAM BA = $BA"
        $coll = 'IT', 'Industrial Tech', 'ITBA', " ", ""
        
        if (!($BA)) {
            Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - Business Area is empty"
            $makeTabVisible = "false"
            break
        }
        else {
            Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - Business Area is not empty"
        }
        
        if ($coll -contains $BA) {
            Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - Business Area is not listed or is Industrial Tech"
            $makeTabVisible = "false"
            break
        }
        else {
            Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - Business Area is participating"
        }

        if ($EmpID -notmatch '^\d{8}$') {
            Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - EmployeeID is not present or is not exactly 8 digits"
            $makeTabVisible = $false
            break
        }
        else {
            Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - EmployeeID is exactly 8 digits"
        }

        if ($SAM -eq $newSAM) {
            #Write-Host "current sam already is converted"
            Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - Samaccount is already set to current standards"
            $makeTabVisible = "false"
            break
        }
        else {
            #Write-Host "current sam CAN be converted"
            Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - Samaccount CAN be converted"
            $makeTabVisible = "true"
        }
        
        Write-Debug "onGetEffectivePolicy" "SAMACCOUNT - End make visible"

        $Request.Put("edsvaACsAMAccountRenameVIS", "true")
        #$Request.SetEffectivePolicyInfo("edsvaACsAMAccountRenameVIS", $Constants.EDS_EPI_UI_GENERATED_VALUE, "true")

    }
}

function Get-Value {

    param (
    
        $obj,
    
        $attr,
    
        [switch]$preload
    
    )
    
    trap { continue }
    
    if ( $preload -eq $true ) { $obj.GetInfoEx(@($attr), 0) }
    
    return $obj.Get($attr)
    
    return $null
    
} # Get's an attribute value if it exists from the Cache
    
### Not tested this as I just thought of this...
    
function Get-Value {
    param (
        $obj,
        $attr,
        [switch]$preload
    )
    
    trap { continue }
    
    if ( $preload -eq $true ) { $obj.GetInfoEx(@($attr), 0) }
    
    $returnValue = $obj.Get($attr)
    
    if ( ( $returnValue -ne $null ) -or ( $preload -eq $true ) ) { Return  $returnValue }
    
    else { $obj.GetInfoEx(@($attr), 0) }
    
    return $obj.Get($attr)
    
} # Get's an attribute value if it exists from the Cache
function Write-Debug {
    param
    (
        [Parameter(Mandatory = $true)][string]$Function,
        [Parameter(Mandatory = $true)][string]$Message      
    )
    [bool]$DebugExt = $false
    
    if ($DebugExt) {
        Write-Host "$Function`n------------------------------`n$Message`n==============================" 
    }
    else {
        $EventLog.ReportEvent($Constants.EDS_EVENTLOG_WARNING_TYPE, "$Function`n------------------------------`n$Message`n==============================")
    }
}

Thanks again for any direction you might have.

Clay

Parents Reply Children
No Data