02-10-2016 11:29 AM - edited 03-19-2019 10:43 AM
Is it possible to call a Cisco Unity LDAP Sync via the CUPI (or any other) API?
02-10-2016 11:39 AM
https://communities.cisco.com/message/160213#160213
http://docwiki.cisco.com/wiki/Cisco_Unity_Connection_Provisioning_Interface_(CUPI)_API_--_User_Import
02-11-2016 04:18 AM
For Clarity Venperum and Deepak are saying the following?
Is this correct?
02-11-2016 04:33 AM
There is no method exposed on any Unity API to trigger the Sync between Unity and LDAP.
Correct, nothing on Unity Connection side but the AXL API can be used to trigger a LDAP sync rather than waiting for the predefined time limit of 6 hours. As said earlier, not sure if it will work for CUC but worth checking
There is a method to import users to Unity once the Sync between Unity and LDAP has completed i.e. http://docwiki.cisco.com/wiki/Cisco_Unity_Connection_Provisioning_Interface_%28CUPI%29_API_--_User_Import
Correct, the above will only work if the Sync is already established between CUC and LDAP
Regards
Deepak
02-11-2016 07:13 AM
Thanks Deepak,
I checked out AXL against CUC and it does not work, AXL does not work against CUC.
It would seem if CUC is linked directly to LDAP there is no mechanism to trigger the Sync via an API.
Are there any plans by Cisco to provide this functionality in the same way it is exposed for Call Manager.
02-10-2016 08:24 PM
Also you have an AXL API available on CUCM not sure if it will work for CUC as well, I assume it should but do not have a LDAP running in my lab at this point to verify
https://communities.cisco.com/message/144353#144353
Regards
Deepak
09-28-2021 10:07 PM - edited 09-28-2021 10:08 PM
I've had this issue a number of times. Our in-house automation is intended to be run in real-time, so waiting for a scheduled LDAP sync isn't usually reasonable. There is no API call exposed for this, but you can simulate the button push if you have the PKID of the directory you want to sync.
Below is a POC I cooked up in Python3:
import requests from bs4 import BeautifulSoup if __name__ == '__main__': adminuser = 'sampleadmin' adminpass = 'samplepassword' hostname = 'cuchost.yourdomain.local' LDAPpkid = 'abcdef12-abcd-abcd-abcd-abcd123456789' with requests.Session() as session: # Create a Session # Log in session.post(f"https://{hostname}/cuadmin/j_security_check", f"j_username={adminuser}&j_password={adminpass}", headers={"User-Agent": "Mozilla/5.0", "content-type": "application/x-www-form-urlencoded"}, verify=False) # Get the edit form for the associated LDAP Directory html_text = session.get(f"https://{hostname}/cuadmin/directoryEdit.do?key={LDAPpkid}", headers={"User-Agent": "Mozilla/5.0"}, verify=False).content # Use BeautifulSoup to extract the form data into a dictionary soup = BeautifulSoup(html_text, features="html.parser") data = {e['name']: e.get('value', '') for e in soup.find_all('input', {'name': True})} # Strip out all the unneeded fields keysAll = list(data) keysKeep = ( 'struts.token.name', 'token', 'pkid', 'name', 'interval', 'syncNow' ) for key in keysAll: if key not in keysKeep: data.pop(key, None) # Override the fields required to initiate a Sync data['syncNow'] = 1 data['groupsyncronize'] = 1 data['interval'] = 1 data['unit'] = 2 # Issue the command (simulate the button push) session.post(f"https://{hostname}/cuadmin/directorySave.do", data, headers={"User-Agent": "Mozilla/5.0"}, verify=False) # Clean up session.cookies.clear() session.cookies.keys()
12-15-2024 10:52 AM
how did you get the pkid of the ldap configuration name in cuc?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide