https://gallery.technet.microsoft.com/office/AD-Department-to-Skype-for-2a95b578
The last piece of the programming puzzle is to create a Skype for Business group using the Lync client sdk, then add users to it.
Step 1
We need to use the SDK to get a contact object from the users AD info.
string uri = result.Properties["msRTCSIP-PrimaryUserAddress"][0].ToString();
Contact c = lc.ContactManager.GetContactByUri(uri);
You will notice is the code last week, when we do this, if they don't have a SIP uri, we then try from their email address, and lastly try from their telephone number. This will at least cover the bases and help us if they are on a different system for voice.
Step 2
private void createGroup(string name)
{
try
{
lc.ContactManager.BeginAddGroup(name, myar =>
{
lc.ContactManager.EndAddGroup(myar);
}, null);
}
catch { }
}
If we don't have a group with that name we need to create one. The above code will do that for us.
Step 3
We need to find the Group object that matches the name we want.
foreach (Microsoft.Lync.Model.Group.Group g in lc.ContactManager.Groups)
{
if (g.Name == searchname)
{
//We found our group
}
}
Step 4
Now we need to have a function as we scan through our AD results that lets us add a Contact to a Group.
private void addToGroup(Group g, Contact c)
{
try
{
g.BeginAddContact(c, myar =>
{
g.EndAddContact(myar);
}, null);
}
catch
{
addToGroup(g, c);
}
}
That will wrap us this series. Thanks for reading, and have a safe Memorial Day weekend.
Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC Developer BridgeOC Twitter - @droutledge @ndbridge |
No comments:
Post a Comment
Any spam comments will be deleted and your user account will be disabled.