Public/ClientAccess/Set-R1LdapClientAccess.ps1

# .ExternalHelp psRadiantOne-help.xml
function Set-R1LdapClientAccess {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
    [OutputType([void])]
    param(
        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [bool]$pagedResults,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [bool]$virtualListView,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [bool]$persistentSearch,

        [parameter(
            Mandatory = $false,
            ValueFromPipelineByPropertyName = $true
        )]
        [bool]$proxyAuthorization
    )

    Begin {

        Assert-R1Session -RequireToken

    }#begin

    Process {

        $URI = Resolve-R1ServiceUrl -Service Settings -Path 'client_access/ldap'

        #Retrieve the current settings and send them back with the supplied values applied over
        #them, so a setting left unspecified keeps its current value.
        $Existing = Get-R1LdapClientAccess

        $Template = [ordered]@{
            pagedResults       = $true
            virtualListView    = $false
            persistentSearch   = $false
            proxyAuthorization = $false
        }

        $Request = Merge-R1Parameter -Template $Template -BoundParameter ($PSBoundParameters | Get-Parameter) -Fallback $Existing

        $Body = $Request | ConvertTo-R1JsonBody

        if ($PSCmdlet.ShouldProcess($Script:psRadiantOneSession.BaseURI, 'Update LDAP Client Access Settings')) {

            $null = Invoke-R1RestMethod -Uri $URI -Method PUT -Body $Body

        }

    }#process

    End { }#end

}