Unified messaging

We recently managed to get asterisk-1.2.1 to connect to MS Exchange 2007 SP1 UM via ser-0.9.6, and wanted to share how we did it.


The ser.cfg we used is attached
. The key to relaying between UDP on asterisk and TCP on Exchange is to cope with the fact that Exchange listens initially on port 5060, and then hands off the call to a helper process listening on a port between 5065 and 5067. Instead of doing this internally, MS Exchange sends a "302 Moved Temporarily" message back to asterisk via ser, redirecting the call to the new listening process on the other port. However, the Diversion: header doesn't survive the journey, so we need to get "creative". ser needs to listen on all the ports that exchange uses, and also relay between them.


You need a sip.conf entry pointing to ser for each helper port that MS Exchange uses, e.g.:



Create similar entries for 5066 and 5067.


You need to program two things in your asterisk dialplan. The first is voicemail access (for subscribers to record greetings, retrieve messages, etc.):

exten => 2202,1,Dial(SIP/2202@<fqdn_of_ser_server)

That's the straightforward bit - like Asterisk, Exchange uses the CallerID(num) to determine whether to prompt for a mailbox number or not, and then prompts for a password, and you're in. Next, we need to send unanswered or busy calls to Exchange:

exten => _XXXX,1,Dial(SIP/${EXTEN},20)
exten => _XXXX,n,SipAddHeader("Diversion=<tel:${EXTEN}>\;reason=no-answer\;screen=no\;privacy=off")
exten => _XXXX,n,Dial(SIP/2202@ummail5065)
exten => _XXXX,n,Dial(SIP/2202@ummail5066)
exten => _XXXX,n,Dial(SIP/2202@ummail5067)

Told you we had to be creative! As mentioned earlier, the Diversion: header doesn't survive the "302 Moved Temporarily" in Asterisk, so we can't call on port 5060 and handle the redirect. We have to call the helper port directly. MS Exchange randomly changes the helper port, so we have to call each one in turn until one answers. Luckily, it takes a split second, and is transparent to the user.

MS Exchange Configuration

We are indebted to Jason Davies (aka The Beardy Brit) of ITS Consulting for his assistance with the MS Exchange side of things.

Create the Dial Plan, using a 4 digit internal numbering scheme. You can use as many digits as you like.

new-UMDialPlan -Name:'telephone' -NumberOfDigitsInExtension:'4' -AccessTelephoneNumbers 2202

Exchange 2007 SP1 note: When the dial plan is created go into the Exchange Management Console, Organization, Unified Messaging, Manage the properties for the dial plan and create the dial rule groups for your organization. The section following this shows how to create these group using phone number masks, If you do not do this you will not be able to dial out from within unified messaging.
Note: The URI Type must be Telephone, not SIP URI or Secured SIP URI, additionally your Active Directory Content should be reviewed carefully prior to mailbox enabling users to ensure that the content in terms of phone numbers and extensions entered is accurate and consistent across the board. Failure to do so may lead to errors in setup for users, and will lead to issues when users accessing UM try to dial out from directory listed numbers.

Create the gateway entry to the SER server. For the most reliable experience, use DNS or host files, in our example IP is used and though it works perfectly reading up on the subject shows that DNS is the more robust mechanism. (-Address: in that case would be ser.domain.suffix)

new-UMIPGateway -Name:'ser' -Address:’ip_address’ -UMDialPlan:'telephone'

Create the AutoAttendant, and make it accessible on extension '2000'

new-UMAutoAttendant -Name:'telephoneaa' -UMDialPlan:'telephone' -PilotIdentifierList:'2000' -Status:'Enabled' -SpeechEnabled:$true

Modify the settings of the AutoAttendant. These can be customized as you require.

Set-UMAutoAttendant -Identity AutoAttendant -AfterHoursTransferToOperatorEnabled $true -AllowExtensions $true -BusinessHoursTransferToOperatorEnabled $true -CallSomeoneEnabled $true -NameLookupEnabled $true -SendVoiceMsgEnabled $true -OperatorExtension '2202' -ContactScope GlobalAddressList

Associate the dial plan with the server to make it active. Replace the server shown below with the FQDN of your UM server

Set-UMServer –Identity:'ummail.domain.suffix’ -DialPlans telephone

Enable UM for your mailbox users, and associate an extension for them. Replace DOMAIN\Username with your own user account details, and the 'Pin' value with one of your choosing

Enable-UMMailbox -Identity:'DOMAIN\username' -UMMailboxPolicy:'telephone Default Policy' –Extensions 2380 -Pin 999999 -PinExpired $false

Create Dialing Rule Entries to allow outbound and internally dialing from within a UM Enabled mailbox. When dialing Rules are created ensure they are added to the Dialing Restrictions wherever noted, firstly and for mostly in the Dialing Restrictions for the Dial Plan created at the onset.

In this example we have created additional Hunt Groups for other numbering schemas we require, you can create as many hunt groups as you need. For more information see:

2000 – test huntgroup for mock extensions
4000 – test huntgroup for mock extensions

Subscriber Access Hunt Group - 2202
This was created due to issues getting the UM server to respond to SER forwards on 2202. The exchange server responded with a fast busy ring tone. Once the hunt group was setup the Autoattendant responded correctly.

Voicemail Access - 2999
Likewise for Voicemail access by a user dialing into UM from their own phone, without this hunt group the UM simply did not respond to this type of call.

Multiple tests were done to determine why these hunt groups where needed, according to documentation they should not be required, in our build they were needed to ensure full functionality. Once all the above is configured, and the open SER and Asterisk portions are setup UM worked flawlessly.

UM Commandlets

Disable UM Features

Disable-UMMailbox -identity:'domain\username'

Enable UM Features

Enable-UMMailbox -identity:'domain\username' -UMMailboxPolicy:’telephone default policy' -Extensions 4000,5000 -Pin 1986 -PinExpired $false

Change GSM encoding per individual

enable-ummailbox "domain\username" -callansweringaudiocodec GSM

Options - GSM/WMA/G.711 default is based on call plan set in features tab

Bulk Enable UM

Obtain list of users and extensions
echo 'samaccountname,extension' > userlist.csv
get-user | foreach { $_.samaccountname + ',' + $_.phone.substring($_.phone.length - 4) } >> userlist.csv
other variables - 
email address
import-csv userlist.csv | foreach { enable-ummailbox -id $_.samaccountname -ummailboxpolicy UMMailboxPolicy -extensions $_.extension -pin $_.extension }
Create users accounts in bulk
Import-CSV 'C:\provision1.csv' |
ForEach-Object {New-QADUser -organizationalUnit 'company.pri/Singers' -name ($_.'First Name' + '.' + $_.'Last Name') 
-samAccountName $_.'Logon name' -city $_.city -title $_.'Job title' -department $_.department}

MS Um Server Scaling
MS UM Bosses Overview
Exchange UM Permissions Requirements
UM Test Phone complete Package
Setting up the UM Test Phone
Testing with the UM Test Phone

Complimentary Guides

Configuring UM and Asterisk
Excellent Article for Asterisk and SIPX configuration
Configuring 3CX and MS Exchange Server 2013 UM

Created by: POSTCTI, Last modification: Wed 31 of May, 2017 (12:06 UTC) by 3cxphonesystem
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+