Reputation: 2550
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:
Upvotes: 3
Views: 1618
Reputation: 2365
I've seen this working OK. That is to say: using lyncClient.ContactManager.GetContactByUri()
works fine for me, even if the address being queried isn't in the client's contact list (and hasn't been queried).
One of the things I am doing though is also subscribing to presence changes. I wonder if that's why it's working for me: it takes a while for non-loaded contacts to be looked up, so it might be that my code does initially return Unknown, and is then updated in the event.
Just to check also: you're ensuring that your email addresses are SIP-prefixed? (i.e in the format sip:[email protected]).
Upvotes: 1