Lync 2013 E.164 CLI and carriers (It’s that Plus sign!)

If you’re using Lync properly, you must have all your numbers in accordance with the E.164 format, as recommended by Microsoft and as often preached by Ken Lasko.

There are many benefits for using E.164, but – like any good thing – it comes with some flaws. One of these flaws when using Lync 2013 is that Lync will cease normalizing numbers that are prefixed with +.
The moment you add the ‘+’ sign to your number, Lync will consider it already normalized and will not process any more rules.

This can cause issues with some providers that require us to remove the leading ‘+’ sign from the number.
The work around for dialled numbers (Or as Lync describes it “Called Numbers”) is to use the Set-CsTrunkConfiguration command to remove ‘+’ sign at the trunk level by adding the parameter -RemovePlusFromUri $true.

This is all good for numbers Called – but what about numbers Calling? How can we manipulate the “Source” number?
If we look at a trace from Lync we can see that the destination number is stripped from it’s leading ‘+’, but the source number still has that annoying sign, although I have a rule that says it’s removing it:

With plus

The SIP invite shows the issue:
INVITE sip:3531891170170@MediaGateway.y0av.local;user=phone SIP/2.0
FROM: <sip:+35314396804;ext=6804@y0av.com;user=phone>;epid=3DFA3756A7;tag=1e448bc93
TO: <sip:3531891170170@MediaGateway.y0av.local;user=phone>

As you can see in the image above, the ‘+’ sign is removed from the destination number, but it’s still there on my source number.
This might result on certain carriers dropping the call since they’re expecting the CLI with no ‘+’.

The workaround:

If you’re working with a gateway or a SBC, you’ll usually be able to work around this issue by stripping the ‘+’ there, simple as this.

If you’re working with Lync only and using a direct SIP trunk to your provider – it’s easy too!
The numbers are not normalized due to Lync’s lack of ability to ignore the rest of the data in the FROM line; when we’re creating normalization rules within Lync, we will usually be looking at numbers and specific characters, not the entire weird string.
The workaround then, is to treat the entire string as… a string.
I add the following rule for my “Calling Numbers” manipulation in the trunk:

Rule

This rule says that whenever a number starts with a plus and has at least 8 characters (ANY character) following it, we should ignore the ‘+’ and send only the characters:
Pattern to match: ^\+(.{8,})
Translation rule: $1
Of course, you can change that to look for more numbers if you have other rules there.

Once the rule has been placed and committed, traces look like this now:

Without Plus

The SIP Invite shows the difference:
INVITE sip:3531891170170@MediaGateway.y0av.local;user=phone SIP/2.0
FROM: “Yoav Barzilay”<sip:35315267877;ext=7877@y0av.com;user=phone>;epid=3DFA3756A7;tag=c9b24cf3b
TO: <sip:3531891170170@MediaGateway.y0av.local;user=phone>

 

Lync not populating contact cards phone numbers from Active Directory (Or: How to normalize AD phone numbers for Lync Server 2010 and 2013)

** This article also works for Lync Server 2013!

 

You’ve seen it. The contact card in Lync shows you everything you entered in Active Directory, except for phone numbers. even when you know you have them there!

This can be quite frustrating, especially if you’re not yet connected with enterprise voive and clients want to pull all the relevant information from Lync during an IM session, including the other side’s phone numbers.

Here’s what you get:

Instead of seeing the relevant phone numbers from Lync like here (sort of…)

You’re getting a card that has no phone info what so ever:

As you can see, ‘test’ Springsteen here, has no phone info in his contact card.

Let’s take a look at Active Directory, see what’s configured there:

This can’t be right! All the information is there! Home, Mobile, even the Office phone is there.

How can we resolve this issue, even without implenenting Lync Enterprise Voice?

Let’s take a look at the event viewer to get some help.

If you scroll down the Lync server logs in event viewer, you’ll probably see event number 21034 generated by LS Address Book Server. It will tell you something like this:

“One or more phone numbers failed to normalize.

‘X’ total numbers failed to normalize.  They are listed in the text file: ‘\\<Lync Server Name>\<Lync Share>\1-WebServices-1\ABFiles0000000-0000-0000-0000-0000000000000000000-0000-0000-0000-000000000000\Invalid_AD_Phone_Numbers.txt’ Cause: One or more phone number attributes in Active Directory contained text that could not be normalized.  Normalization rules are contained in the optional Company_Phone_Number_Normalization_Rules.txt file located in the output location or in the generic rules built into Address Book Server.  Refer to the documentation for a description of the built-in generic normalization rules.  Use the ABServer -dumpRules command to see all the rules that Address Book Server is currently configured with.”

It looks like this:

If you press the path in the event propertis or browse to the file location in your server (always in the same place, in the same name), you will see the following:

What you get here is a list of the users and they’re phone numbers you thought were ok.

Why is this happening?

Well, Lync expects all the phone numbers in your AD to be in the E.164 format, meaning they should be +1-111-11111111 etc. If they’re not like this (as the example above shows us), you will have to normalize them if you want Lync to publish them.

How can I fix this?

Quite easily, to be honest. If you continue reading in event  21034, you’ll see the following:

“Either create a Company_Phone_Number_Normalization_Rules.txt file in the output location and make sure it covers all cases found in your Active Directory deployment or fix the invalid phone number(s) in the Active Directory record(s).”

You get a free advice – you don’t throw it away, do you? What Lync actually tells you, is to create  a file called “Company_Phone_Number_Normalization_Rules.txt” in the root of the AB folder of your Lync shared folder (Not in a sub folder, not by a different name, EXACTLY this one) – like it shows you here:

In this file, you must enter normalization rules according to your country code and other variables.

I used to freak out when I heard normalization rules, but fortunately the guys at Lync made it quite simple for us: I use the Lync Server Control Panel to generate and test my normalization rules. It’s really easy and fun to use – Just enter the details and copy the results. In the next example I created a rule to normalize our internal numbers:

I copied the “Pattern to match” and the “Translation Rule” from the wizard and copied them one line below the other (in the order they appear at the wizard) to the txt file I created. Note you can add “##” at the beginning of each line if you want to write comments.

This is how my file looks like at the end:

Now, all I have to do is run the “Update-CsAddressbook” command from Lync Management Shell and that’s it.

If you configured the rules correctly – you will see the results in your clients. It might take a while for the clients to download the updates, but eventually you’ll see it works perfectly:

Now you can call Bruce 🙂