However, the initial consideration would be how is the incoming caller ID associated to the user, precisely, and in which system (CUCM/AD) is that relationship stored? For example, it could simply be an E164 string in AD, it could be a CUCM DN associated to a phone device associated to a user, it could be a DN associated directly to a user via 'primary line' in CUCM, etc.
If the 'source of truth' is AD, I would suggest using AD APIs to query/retrieve the data. If it's in CUCM via some line/user/field then we can further help recommend the AXL query to use...
The source of truth is AD which populates the telephone Number field in CUCM via the ipPhone field in AD. I want to cross reference the telephone number and retrieve the associated userid (SAMAccountName), Firstname, Lastname and MailID.
So do you think that querying AD would be the best option via a UCCX Script?
I found some info on running an SQL Query via AXL on CUCM which might work.
Good info, though keep in mind that this query likely involves a full, unindexed table scan of the user table in the CUCM DB, and may have a bigger performance impact than you might expect - would be worth some testing.