Given an eMail address, I am trying to determine if it is a valid user's signin address.
I've tried the code below, but it only works if the user has been queried by the Lync Client by the user before, otherwise the user is identified as Unknown.
using Microsoft.Lync.Model;
using Microsoft.Lync.Model.Extensibility;
private bool IsLyncUser(string eMail, out Microsoft.Lync.Model.Contact imContact)
{
var lyncClient = LyncClient.GetClient();
imContact = lyncClient.ContactManager.GetContactByUri(eMail);
if (null != imContact)
{
try
{
var sourceType = (ContactSourceTypes)imContact.Settings[ContactSetting.Source];
return (ContactSourceTypes)0 != (ContactSourceTypes.ExchangeService | ContactSourceTypes.GlobalAddressList | sourceType);
}
catch
{
imContact = null;
}
}
return false;
}
Questions:
- Why is the data only loaded when the user is queried via the Lync Client GUI?
- How can I "fetch" the data, so that it will be available when queried?
- Is there a better way to query if the email belongs to a valid Lync user?