Search code examples
c#wpflyncskype-for-business

Why ContactManager.BeginSearch return zero result for some strings even if strings present as contact


I am searching string to find contact details using Lync SDK but for some of strings are returning zero search result even if I have contact same as string.

ContactManager contact_manager = LyncClient.GetClient().ContactManager;
contact_manager.BeginSearch(name, SearchProviders.Default, SearchFields.AllFields, SearchOptions.Default, 50, SearchCallback, new object[] { name, SearchProviders.Default });

In above code I am getting ContactManager even I am able to search some of string.

What can be the reason of not getting result for all string?

Note: Whatever string I am searching that is present as Lync contacts.


Solution

  • If you read the docs for SearchProviders believe it or not SearchProviders.Default is actually deprecated. If you want to mimic the behaviour of the Lync client use SearchProviders.Reserved1 (if you check Microsoft.Office.Uc.SearchProviders this maps to ucSearchProviderLync). I have found that in certain AD/Exchange setups this provider does not always work. So at least have a fall back to SearchProviders.Default if SearchProviders.Reserved1 fails.