Synopsis: Out of the box, Lync Server 2013 does not have any way to block specific calls destined to any user or specific user inside of an organization. However, Microsoft added in the ability for users/partners/etc. to write custom scripts to help allow flexibility in Lync. That being said, this tutorial will go over deploying a custom script to allow Lync Server to block calls based on caller ID.
Before we begin, I would like to give credit to a few individuals. This guide will make use of David Paulino's guide/script for Lync Server 2013 (http://uclobby.com/2014/07/31/calleridblock/), which was a converted script from VoIP Norm's original Lync Server 2010 script (http://voipnorm.blogspot.co.uk/2011/06/blocking-calls-in-lync-based-on-caller.html). The only changes in this article is a more step-by-step deployment guide as well as the ability to control blocking of numbers at a user level and the ability to optionally leave comments on why a rule was added.
Tutorial
- Download a copy of the CallerIDBlock.am.txt script (or copy and paste this script into a file called CallerIDBlock.am) (if you downloaded this file, make sure you remove the .txt at the end)
/*<?xml version="1.0" ?>
<lc:applicationManifest
lc:appUri="http://jackstromberg.com/2015/02/CallerIDBlock"
xmlns:lc="http://schemas.microsoft.com/lcs/2006/05">
<lc:requestFilter methodNames="ALL" strictRoute="true"/>
<lc:responseFilter reasonCodes="NONE"/>
<lc:scriptOnly/>
<lc:file name="BlockedTelephoneNumbers"
path="\\<Lync Share Path>\CallerIDBlock\BlockedTelephoneNumbers.txt"
delimitedBy="comma"
keyColumnName="FromSIP"
static="false">
<lc:column name="FromSIP" />
<lc:column name="ToSIP" />
<lc:column name="Action" />
<lc:column name="Comments" />
</lc:file>
<lc:splScript><![CDATA[
Module Name: CallerIDBlock.am
*/if(sipRequest.Method == "INVITE"){
fromSIPUser = GetUserName(GetUri(sipRequest.From));
toSIPUser = GetUserName(GetUri(sipRequest.To));
sep = IndexOfString(fromSIPUser, ";");Log ("Debugr", false, "CallerIDBlock processing request:");
Log ("Debugr", false, "From - ", fromSIPUser);
Log ("Debugr", false, "To - ", toSIPUser);
if(sep != -1) {
fromSIPUser = SubString(fromSIPUser, 0, sep);
}action = BlockedTelephoneNumbers[fromSIPUser].Action;
if(action == "block") {
if(BlockedTelephoneNumbers[fromSIPUser].ToSIP == "*" || BlockedTelephoneNumbers[fromSIPUser].ToSIP == toSIPUser){
Log ("Debugr", false, "Rejected by CallerIDBlock");
Respond(403, "Forbidden");
}
} else {
Log ("Debugr", false, "Allowed by CallerIDBlock");
}
}
return;
]]></lc:splScript>
</lc:applicationManifest>
- Download a copy of the BlockedTelephoneNumbers.txt file (or copy and paste the code below into a file called BlockedTelephoneNumbers.txt)
FromSIP,ToSIP,Action,Comments
- Edit the CallerIDBlock.am file and change the BlockedTelephoneNumbers path to be your fileshare
- Edit the list of blocked numbers inside the BlockedTelephoneNumbers.txt file
- Notes: The FromSIP address is the Caller ID of the incoming call; the ToSIP is the individual that is trying to be reached (side-note, in this particular script, if you set this field so an asterisk (*), this will be a wildcard for any/every user; the Action should be set to "block" to block the call; the Comments field is an optional field to document when/why the number was added to be blocked
- Notes: The FromSIP address is the Caller ID of the incoming call; the ToSIP is the individual that is trying to be reached (side-note, in this particular script, if you set this field so an asterisk (*), this will be a wildcard for any/every user; the Action should be set to "block" to block the call; the Comments field is an optional field to document when/why the number was added to be blocked
- Create a new folder where your Lync share is
- Copy the CallerIDBlock.am and BlcokedTelephoneNumbers.txt files to your Lync Share where your new CallerIDBlock folder is
- Add the CallerIDBlock script as a Lync Server Application
- Enable the CallerIDBlockLync Server Application
- Verify the script is actively listening for calls