Microsoft Lync and Skype for Business have a rich set of .NET APIs which make it easy to extend the platform and integrate it with other applications. This blog helps explain how to use those APIs.

Adding custom menu items to the Lync client

Posted: November 6th, 2011 | Author: | Filed under: Lync Development | Tags: , , , | 19 Comments »

One of the areas in which Lync can really streamline communication is in handling context. The term “contextual conversations” comes up a lot in reference to Lync, and for good reason. In traditional communication media, a lot of time tends to be wasted while one person or the other looks for necessary information, documents, or tools that are relevant to the topic at hand. As Lync becomes more and more integrated into people’s workflows, it can automate much of this sending and retrieval of appropriate context, saving time and increasing productivity.

In this post, I want to discuss one of the ways in which the Lync UI can be customized to help offer contextual options that are specific to your own business needs: by creating custom menu items. Continue reading “Adding custom menu items to the Lync client” »


Rerouting requests to a UCMA application with MSPL

Posted: September 4th, 2011 | Author: | Filed under: Lync Development, MSPL | Tags: , , | 25 Comments »

One of the most useful (and most confusing) things you can do with Microsoft SIP Processing Language (MSPL) is change the routing behaviour of Lync Server. There are a variety of reasons why you might want to do this, but in this post I want to discuss a specific case: rerouting calls to a UCMA application. Continue reading “Rerouting requests to a UCMA application with MSPL” »


Installing and troubleshooting MSPL scripts

Posted: July 26th, 2011 | Author: | Filed under: Lync Development, MSPL | Tags: , | 3 Comments »

In my last post, I described some of the basics of Microsoft SIP Processing Language, or MSPL, using a simple script as an example. That last post ended with a cliffhanger: how does the MSPL script get installed on the Lync Front End Server?

Today, I’m going to answer that question. Continue reading “Installing and troubleshooting MSPL scripts” »


Extending Lync Server routing with MSPL

Posted: July 8th, 2011 | Author: | Filed under: Lync Development, MSPL | Tags: , | 24 Comments »

Recently I’ve taken a number of questions about customizing the routing of messages in Lync Server, which is possible with the Lync Server 2010 SDK. Since most of the how-to material out there is about either UCMA or the Lync 2010 (client) SDK, I thought I would write up a few articles on the basics of what you can do with the Lync Server 2010 SDK, and particularly with Microsoft SIP Processing Language, a.k.a. MSPL. Continue reading “Extending Lync Server routing with MSPL” »


Looking up a user’s SIP address

Posted: June 22nd, 2011 | Author: | Filed under: Lync Development, OCS Development | Tags: , , | No Comments »

In writing applications to extend OCS or Lync — especially applications that mimic client functionality — I’ve run into a number of situations where the application has a user’s domain and username but needs to figure out the user’s SIP URI in order to perform OCS/Lync operations on behalf of that user. There is not much documentation out there on how to do this, and it’s hard to find. So I wanted to write up a quick explanation of how to look up the SIP URI of a given domain account from Active Directory.

I’ll start with a couple of notes. First, it’s true that some organizations by convention use a SIP URI format that makes it easy to derive the SIP URI from the username with a bit of string manipulation. For instance, if all users have SIP URIs of the form sip:username@fabrikam.com, the application can put together the SIP URI itself by concatenating the username with “@fabrikam.com”. Also, in many cases SIP URIs by convention are the same as email addresses with sip: added to the front. If this is the case, an application that has the email address of the user can simply add sip: to produce the SIP URI.

The important thing to note is that while some organizations use these SIP URI formats by convention, there is nothing to prevent an administrator from giving a user a completely different SIP URI. If you are creating an application that needs to work in environments besides your own, it is potentially dangerous to assume that all SIP URIs will follow a consistent format like the ones described above.

This isn’t a huge deal, because retrieving SIP URIs for users, assuming you can connect to Active Directory to do an LDAP query, is relatively simple. The SIP URI for a user (at least, for users who are UC-enabled and have SIP URIs assigned) is stored in the msRTCSIP-PrimaryUserAddress property. There are plenty of articles out there on the Internet describing how to retrieve information from Active Directory, so I won’t go into all the details here, but you can use code that looks something like this:

public string GetSipUri(string cn, string ou)
{
 DirectoryEntry entry = new DirectoryEntry(
  "<a href="ldap://dc.fabrikam.com/cn">LDAP://dc.fabrikam.com/cn</a>=" + cn + ", ou=" + ou +
  ", dc=fabrikam, dc=com");

 PropertyCollection properties = entry.Properties;
 return properties["msRTCSIP-PrimaryUserAddress"].ToString();
}

You’ll need to reference System.DirectoryServices to do this. Basically what you are doing is retrieving the object representing the user via LDAP, and grabbing the msRTCSIP-PrimaryUserAddress property from that object.

If you want to do the reverse of this (look up the username based on a SIP URI) you can use the DirectorySearcher object, with a search filter like the following:

searcher.Filter = "(&(objectClass=user)(msRTCSIP-PrimaryUserAddress=sip:michael@fabrikam.com))";

Feel free to get in touch if you have any questions!