Microsoft Lync Call Blocker

After receiving a question about how to block specific phone numbers from calling Lync endpoints I decided to write an application to handle this scenario. The solution uses the Lync Server 2010 SDK which I covered in a previous post.

In MSPL we can add a file to the request filter. You simply define a file element and point it to a local file. I am using a comma delimited file with two columns. A phone number and an action.

For example:

+17275555555,block

The following MSPL Script is installed on my Lync Front End Server and will check each SIP request against my callerid file. If the number of the calling party is in my text file the call will be blocked. You could easily create an administrative tool to edit the blocked numbers list so you could manage this remotely.

I will be uploading a short video on how to install this sample in a few days.

<?xml version="1.0"?>
<r:applicationManifest r:appUri="http://www.gotuc.net/TelFilter" 
   xmlns:r="http://schemas.microsoft.com/lcs/2006/05">
  <r:requestFilter methodNames="ALL" strictRoute="true"/>
    <r:responseFilter reasonCodes="NONE"/>
      <r:scriptOnly/>
    <r:file name="BlockedTelephoneNumbers" 
       path="C:\Work\TelFilter\BlockedTelephoneNumbers.txt" delimitedBy="comma" 
       keyColumnName="Phone" static="false">
        <r:column name="Phone" />
        <r:column name="Action" />
    </r:file>
  <r:splScript><![CDATA[
/*++
Module Name: TelFilter.am    
--*/
    //
    // Main program.
    //
    Log ("Debugr", false, "We have a request - ", sipRequest.Method);
    Log ("Debugr", false, "From - ", GetUserName(GetUri(sipRequest.From)));
    Log ("Debugr", false, "To - ", GetUserName(GetUri(sipRequest.To)));
    action = BlockedTelephoneNumbers[GetUserName(GetUri(sipRequest.From))].Action;
    if(action == "block") 
    {
        Log ("Debugr", false, "Exit. Rejected by policy");
        Respond(403, "Forbidden");
    }
    else
    {
        Log ("Debugr", false, "Exit. Allowed by policy");
    }
    return;
]]></r:splScript>
</r:applicationManifest>
Add a Comment