cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1932
Views
12
Helpful
7
Replies

Is it possible to call a Cisco Unity LDAP Sync via the CUPI (or any other) API?

aidangconnolly
Level 1
Level 1

Is it possible to call a Cisco Unity LDAP Sync via the CUPI (or any other) API?

7 Replies 7

https://communities.cisco.com/message/160213#160213

http://docwiki.cisco.com/wiki/Cisco_Unity_Connection_Provisioning_Interface_(CUPI)_API_--_User_Import

For Clarity Venperum and Deepak are saying the following?

  • There is no method exposed on any Unity API to trigger the Sync between Unity and LDAP.
  • 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

Is this correct?

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

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.

Deepak Rawat
Cisco Employee
Cisco Employee

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

jtrohm
Level 1
Level 1

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()

 

how did you get the pkid of the ldap configuration name in cuc?