cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
150
Views
0
Helpful
1
Replies

Unpredictable LDAP Sync Behavior in CMS During Automation

Smile1
Level 1
Level 1

CMS (cisco meeting server) v. 3.11 Exhibits Unpredictable LDAP sync behavior during scripted powershell operations

Hello,

When configuring CMS and integrating LDAP, I noticed there is no automatic synchronization to update user account information. To handle this, I wrote a PowerShell script to perform the sync. However, I'm running into a strange issue: even if I specify a single LDAP source ID, the script synchronizes 4 random LDAP sources out of the 8 available. It completely ignores the ID I provide.

Even more oddly, if I give the script all 8 LDAP source IDs, it does loop through all of them—but for each ID, it performs the exact same action as it does when only one ID is provided (syncing the same 4 random sources).

What could be causing this behavior?

1 Reply 1

Smile1
Level 1
Level 1

Here is the script:

$uri = "https://cms.my.domain:8443/api/v1/ldapSyncs"  

$apiUser        = 'admin'                    

$apiPass        = 'password'                  

$ldapSourceID   = ( "1"

    #"2",

    #"3",

    #"4",

    #"5",

    #"6",

    #"7"

    #"8"
   #        )

$tenantID       = ""

$pair   = "$apiUser`:$apiPass"

$sec = ConvertTo-SecureString $apiPass -AsPlainText -Force

$info = New-Object System.Management.Automation.PSCredential($apiUser, $sec)

$encoded = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($pair))

 

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

 

foreach ($id in $ldapSourceID) {

    $syncPayload = @{

        tenant = @{ id = $tenantID}

        ldapSource = @(@{ id = $id })

        removeWhenFinished = $false

    }

    $syncPayloadJson = $syncPayload | ConvertTo-Json -Depth 3

 

    $response = Invoke-WebRequest -Uri $uri -Credential $info -Method Post -Body $syncPayloadJson -UseBasicParsing:$true

    Write-Host "TRIGERIUKAS source $id"

}

$job = ($response.Content | ConvertFrom-Json)

$jobID = $job.id

 

do {

    Write-Host "Nu....."

    Start-Sleep -Seconds 5

    $statusResp = Invoke-WebRequest -Uri "$uri/$jobId" -Credential $info -UseBasicParsing

    #Write-Host "TEST: [$($statusResp.Content)]"

      

    $statusXml = [xml]$statusResp.Content

 

    $status = $statusXml.ldapSyncs.ldapSync[0].state

    $count = [int]$statusXml.ldapSyncs.ldapSync[0].numUsersImported

    $sourcesCompleted = [int]$statusXml.ldapSyncs.ldapSync[0].numLdapSourcesComplete

 

    if($usersImported -gt 0) { $lastCount = $usersImported }

    #Write-Host "Current sync status: $status, users imported: $count, sources complete: $sourcesComplete"

} while ($status -eq "inProgress")

 

Write-Host "Status of sync: $status, users imported/updated: $lastCount, sources used/completed: $sourcesComplete"