简体   繁体   中英

Query GAL contacts from Exchange Server by phone number

I would like to get users from the exchange server that matches a specific phone number. I specifically want the users in GAL (global address list) not from the personal phone book of the user. I have tried several methods but with no avail.

First I have used

service.ResolveName("SMTP:", ResolveNameSearchLocation.DirectoryOnly, true)

as described here: Get all contacts from exchange server , but I can not filter this list by phone number and the list is limited to 100 contacts.

Then I have used:

ContactsFolder.Bind(service, WellKnownFolderName.Contacts);

as described here: How to retrieve all contacts from Microsoft Exchange using EWS Managed API? and here: How do I get address lists (NOT global) using Exchange WebServices in C# . This only retrieves contacts from personal phone book.

Lastly I made SOAP calls as described here: How to get all users form Exchange with EWS , but this returns all contacts with no phone - I have to query again each person by id to get phone details. And the biggest problem is that I need to know the GAL's GUID which can not be retrieved by EWS.

Is there any possibility to filter the GAL by phone number? Is there any other method to achieve this?

My project is written in C# .Net in Visual Studio 2017. I have deployed a test Exchange Server 2017 (I can give more details and access if requested)

Exchange doesn't allow you to query the GAL by phone number. My suggestion is you forget about using EWS and just query the directory directly eg anything in the GAL is just the Active Directory properties for the user or contact object so you can use LDAP to query the directory directly or if you using Office365 you can use the Graph API to do the same thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM