<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic CMS LDAP Sync via PowerShell in TelePresence and Video Infrastructure</title>
    <link>https://community.cisco.com/t5/telepresence-and-video-infrastructure/cms-ldap-sync-via-powershell/m-p/4406917#M102656</link>
    <description>&lt;P&gt;Since LDAP doesn't sync automagicaly, I'm trying to write a PowerShell Script that will run and and send a Post to the server to kick off the sync.&amp;nbsp; My issue is I'm getting a 401 unauthorized.&amp;nbsp; I'm assuming its the "Username/Password" isn't what the API is expecting so its it failing?&amp;nbsp; &amp;nbsp;I do have a user ldapsync that has api rights.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ErrorMessage: Invoke-WebRequest : The remote server returned and error: (401) Unauthorized.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my code (go easy, this is my first PowerShell script).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Set-StrictMode -Version Latest&lt;BR /&gt;&lt;BR /&gt;[Net.ServicePointManager]::SecurityProtocol = 'Tls12'&lt;BR /&gt;$ErrorActionPreference = "stop"
$Body = @{
    Username = 'ldapsync'
    Password = 'syncme'
}
$LoginResponse = Invoke-WebRequest 'https://CMSFQDN:447/api/v1/ldapSyncs' -Body $Body -Method Post&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 22 May 2021 01:12:01 GMT</pubDate>
    <dc:creator>tormenteddave</dc:creator>
    <dc:date>2021-05-22T01:12:01Z</dc:date>
    <item>
      <title>CMS LDAP Sync via PowerShell</title>
      <link>https://community.cisco.com/t5/telepresence-and-video-infrastructure/cms-ldap-sync-via-powershell/m-p/4406917#M102656</link>
      <description>&lt;P&gt;Since LDAP doesn't sync automagicaly, I'm trying to write a PowerShell Script that will run and and send a Post to the server to kick off the sync.&amp;nbsp; My issue is I'm getting a 401 unauthorized.&amp;nbsp; I'm assuming its the "Username/Password" isn't what the API is expecting so its it failing?&amp;nbsp; &amp;nbsp;I do have a user ldapsync that has api rights.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ErrorMessage: Invoke-WebRequest : The remote server returned and error: (401) Unauthorized.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my code (go easy, this is my first PowerShell script).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Set-StrictMode -Version Latest&lt;BR /&gt;&lt;BR /&gt;[Net.ServicePointManager]::SecurityProtocol = 'Tls12'&lt;BR /&gt;$ErrorActionPreference = "stop"
$Body = @{
    Username = 'ldapsync'
    Password = 'syncme'
}
$LoginResponse = Invoke-WebRequest 'https://CMSFQDN:447/api/v1/ldapSyncs' -Body $Body -Method Post&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 May 2021 01:12:01 GMT</pubDate>
      <guid>https://community.cisco.com/t5/telepresence-and-video-infrastructure/cms-ldap-sync-via-powershell/m-p/4406917#M102656</guid>
      <dc:creator>tormenteddave</dc:creator>
      <dc:date>2021-05-22T01:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: CMS LDAP Sync via PowerShell</title>
      <link>https://community.cisco.com/t5/telepresence-and-video-infrastructure/cms-ldap-sync-via-powershell/m-p/4408890#M102676</link>
      <description>&lt;P&gt;I used this and finally got it to work, not super secure but it works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Set-StrictMode -Version Latest
[Net.ServicePointManager]::SecurityProtocol = 'Tls12'
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

$ErrorActionPreference = "Stop"

$username = "ldapsync"
$password = "syncme"
$pair = "${username}:${password}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
$url = 'https://CMSFQDN:447/api/v1/ldapSyncs/'

Invoke-WebRequest -uri $url -Headers $headers -Method Post -Body $Body&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 May 2021 14:39:13 GMT</pubDate>
      <guid>https://community.cisco.com/t5/telepresence-and-video-infrastructure/cms-ldap-sync-via-powershell/m-p/4408890#M102676</guid>
      <dc:creator>tormenteddave</dc:creator>
      <dc:date>2021-05-26T14:39:13Z</dc:date>
    </item>
  </channel>
</rss>

