Retreiving user based on AD user id

Version 1
    This document was generated from CDN thread

    Created by: ali khawaja on 15-11-2013 04:20:04 AM
    Hi - i would like to retrieve a UCM user's extension based on his AD user id.  customer is storing in the profile of ech Cisco user, his or her AD ID as well.  how can i query UCM through AD ID and get that user's SIP extension?

    Thanks

    Subject: RE: Retreiving user based on AD user id
    Replied by: David Staudt on 15-11-2013 01:40:54 PM
    A few questions that may help us better guide you:

    - Is the UCM set to sync its user list from AD?  I.e. are the UCM ID and AD ID the same?
    - If the AD user ID is different than the UCM user ID, and the AD user ID is synced into a different UCM user field - which UCM user field is used to hold the AD ID?
    - How is the relationship between user and extension stored?  Is the user's extension stored in AD and imported into a UCM user field?  Is the user's extension designated in the 'Primary Extension' field in the user's UCM configuration page?  Is the user's extension just a single line on a single device associated to the user (via the UCM associated devices page?)

    Subject: RE: Retreiving user based on AD user id
    Replied by: ali khawaja on 15-11-2013 11:46:47 PM
    Hi David.  Really appreciate the reply.

    1. there is no synchronization. UCM ID and AD ID are different.
    2. owner user ID.  i believe its on the 3rd or 4th screen when you are creating a new user.  there is a find button beside it also.  the box itself is grayed out.  so you can pick the user from the find dialog box; thats where all the AD IDs are shown.
    3. so AD has no idea about the user's phone number/extension, whatever is being assigned by UCM.  the process is that AD admin creates a new user account, then UCM admin assigns him the new phone/extension (i am saying extension because phone number for the organization is same, but the extension changes.  i can probably get the full phone number from UCM).  final step is to update AD with the user's phone number that is in UCM.  thats the part we are trying to automate.  

    so for any UCM user, i know that UCM's owner user id field stores his AD ID.  so what i am trying to do is, write a utility, that iterate over all the AD user IDs, and queries UCM for their phone number/extension, and then once it gets the information back from UCM, updates AD with that phone number/extension

    i am not differentiating between phone number or extension, because i am not sure how the informatoin is in UCM.  i think either one will work.

    Subject: RE: Retreiving user based on AD user id
    Replied by: ali khawaja on 16-11-2013 12:57:16 AM
    can i call the executeSQL web service and send some query for the enduser table to accomplish this? i as looking at the data dictionary but could not quite make out it is storing owner user id.  but then also i could not figure out where it is storing the new phone numer.

    Subject: RE: Retreiving user based on AD user id
    Replied by: Thomas Ellis on 27-11-2013 10:11:38 AM
    Ali,
    try the executeSQLQuery function and pass the AD ID.  Something like this...
    SELECT * FROM enduser WHERE userid = 'yourusername'
    *assuming the userid field is what contains your AD ID. The 'telephonenumber' field of the result may be what you're looking for??