How Microsoft Exchange Server 2007 / 2010 Unified Messaging works

Edit 16th September 2015: Please note that 3CX Phone System only works with MS Exchange Server 2013 and 2013 SP1

Introduction

Microsoft Exchange Server Unified Messaging communicates with a PBX via the SIP protocol. However:

1) Only TCP transport is used. UDP transport is not supported.
2) Microsoft Exchange Server does not support authorization. It works like a bridge. That means that if the PBX will require authentication from MS Exchange, it will send a 407 “Proxy Authentication Required” response to the UM Server during the SIP session. This will result in the Unified Messaging Server rejecting the call.
3) MS Exchange does not require the PBX to be registered on the Exchange Server 2007/2010 side via the SIP REGISTER procedure. Microsoft Exchange Server needs the PBX to be configured as a SIP trunk.
4) The default Exchange Server port for SIP communication is 5060.

PBX Registration

There is a registration process but this is not like the normal SiP REGISTER between IP phones and SiP PBX’s. Before any communication starts between PBX and Exchange, the latter must be registered on the Microsoft Exchange Server 2007/2010 side. The PBX must be registered (as an IP address or fully qualified domain name) within the Exchange Management Console. Microsoft Exchange Server ignores any SIP packets if their source is unknown to MS Exchange. In other words, MS Exchange processes only SIP packets coming from registered PBX’s.

PBX Pinging
As soon as the PBX has been registered (within Exchange Management Console) on the Microsoft Exchange Server side, Exchange sends (every few seconds, typically 20 seconds) pinging packets (SIP OPTION) to the PBX. The PBX has to respond with the correct 200 OK response.
The example of pinging communication is shown below.

OPTIONS pinging packet from MS Exchange (192.168.44.130:5060) to PBX (192.168.44.1:5060)
OPTIONS sip:192.168.44.1:5060;transport=TCP SIP/2.0
FROM: <sip:fserver.exchange.3cx.test:5060>;epid=97-1A-5A-CE-20;tag=30185a849d
TO: <sip:192.168.44.1:5060;transport=TCP>
CSEQ: 70 OPTIONS
CALL-ID: 4b32633a9c7d40a78f11eb39d758f16d
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 192.168.44.130:1923;branch=z9hG4bK7b4b3ed5
ACCEPT: application/sdp
CONTACT: <sip:fserver.exchange.3cx.test:5060;transport=Tcp;maddr=192.168.44.130>
CONTENT-LENGTH: 0
USER-AGENT: RTCC/2.0.6017.0

200 OK response from PBX (192.168.44.1:5060) to MS Exchange (192.168.44.130:5060)
SIP/2.0 200 OK
Via: SIP/2.0/TCP 192.168.44.130:1923;branch=z9hG4bK7b4b3ed5
Contact: <sip:192.168.44.1:5060;transport=TCP>
To: <sip:192.168.44.1:5060;transport=TCP>;tag=9a6d1b6a
From: <sip:fserver.exchange.3cx.test:5060>;tag=30185a849d;epid=97-1A-5A-CE-20
Call-ID: 4b32633a9c7d40a78f11eb39d758f16d
CSeq: 70 OPTIONS
Accept: application/sdp
Accept-Language: en
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, NOTIFY, REFER, SUBSCRIBE
Content-Length: 0

If MS Exchange has not gotten a response after ping packet send, it will write an error message to the Windows event log on the MS Exchange machine. The fact that the last ping was not successful does not affect the other aspects of communication. For example, if MS Exchange gets INVITE from a registered PBX IP/Port, then it processes it despite the last ping to this IP/Port being successful or not. In other words, pinging of PBX has diagnostic rather than functional purposes.

Initiating a Call to MS Exchange 2007

The PBX initiates call to MS Exchange by sending a SIP INVITE message to the 5060 port of MS Exchange. MS Exchange sends 302 (Moved Temporarily) response to the PBX asking to repeat the INVITE on a different port (5065 for example). After the PBX repeats the INVITE sending, the call is established.

The examples of SIP packets are shown below.

The first INVITE from PBX (192.168.44.1:5060) to MS Exchange (192.168.44.130:5060):

INVITE sip:810@192.168.44.130:5060;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 192.168.44.1:1205;branch=z9hG4bK-d87543-e3474a2c0c519d17-1–d87543-;rport
Max-Forwards: 70
Contact: <sip:100@192.168.44.1:1205;transport=TCP>
To: <sip:810@192.168.44.130:5060;transport=TCP>
From: “3CX Phone”<sip:100@127.0.0.1:5070>;tag=0b1e252b
Call-ID: NmEzMjg3ODgzZjk3ZmExMjAwODA5NDIzYzg4ZWVmMjA.
CSeq: 1 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, NOTIFY, REFER, SUBSCRIBE, INFO, PRACK, SUBSCRIBE
Content-Type: application/sdp
Content-Length: 343

v=0
o=- 3381640660 3381640660 IN IP4 127.0.0.1
s=SIPPER for 3CX Phone
c=IN IP4 127.0.0.1
t=0 0
m=audio 5072 RTP/AVP 8 0 2 3 97 110 101
a=fmtp:101 0-15
a=ptime:20
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:3 GSM/8000
a=rtpmap:97 iLBC/8000
a=rtpmap:110 speex/8000
a=rtpmap:101 telephone-event/8000

302 (Moved Temporarily) response from MS Exchange (192.168.44.130:5060) to PBX (192.168.44.1:5060)

SIP/2.0 302 Moved Temporarily
FROM: “3CX Phone”<sip:100@127.0.0.1:5070>;tag=0b1e252b
TO: <sip:810@192.168.44.130:5060;transport=TCP>;tag=7152365629
CSEQ: 1 INVITE
CALL-ID: NmEzMjg3ODgzZjk3ZmExMjAwODA5NDIzYzg4ZWVmMjA.
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 192.168.44.1:1205;branch=z9hG4bK-d87543-e3474a2c0c519d17-1–d87543-;rport
CONTENT-LENGTH: 0
SERVER: RTCC/2.0.6017.0
CONTACT: <sip:810@192.168.44.130:5065;transport=TCP>

The second INVITE (reinvite) from PBX (192.168.44.1:5060) to MS Exchange (192.168.44.130:5065)

INVITE sip:810@192.168.44.130:5065;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 192.168.44.1:1205;branch=z9hG4bK-d87543-2c2fa879fb105264-1–d87543-;rport
Max-Forwards: 70
Contact: <sip:100@192.168.44.1:1205;transport=TCP>
To: <sip:810@192.168.44.130:5060;transport=TCP>
From: “3CX Phone”<sip:100@127.0.0.1:5070>;tag=0b1e252b
Call-ID: NmEzMjg3ODgzZjk3ZmExMjAwODA5NDIzYzg4ZWVmMjA.
CSeq: 2 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, NOTIFY, REFER, SUBSCRIBE, INFO, PRACK, SUBSCRIBE
Content-Type: application/sdp
Content-Length: 343

v=0
o=- 3381640660 3381640660 IN IP4 127.0.0.1
s=SIPPER for 3CX Phone
c=IN IP4 127.0.0.1
t=0 0
m=audio 5072 RTP/AVP 8 0 2 3 97 110 101
a=fmtp:101 0-15
a=ptime:20
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:3 GSM/8000
a=rtpmap:97 iLBC/8000
a=rtpmap:110 speex/8000
a=rtpmap:101 telephone-event/8000

When the PBX creates an INVITE for sending to MS Exchange it has to consider the following things:

  • MS Exchange takes destination DN from request line (not from ‘To’ field).
  • MS Exchange does not understand ‘From’ fields with domain name in the address (example: field containing <sip:100@3CXPhoneSystem> address).The ‘From’ field’s address to be in the format ‘<sip:DN@IP:Port>’; otherwise, MS Exchange drops the call.
  • The destination DN from the request line is used by MS Exchange for decision of what kind of interactive voice menu to be activated.
  • MS Exchange uses the DN defined within the ‘From’ field’s address for identification of the caller. If the DN is known to MS Exchange (matches some mailbox extension’s number), then the context of the voice menu is changed to make the menu more convenient for the caller.

Activating Welcome Menu

MS Exchange Welcome menu is the analogue of the 3CX PhoneSystem special voice menu, but has a bit different and enhanced functionality.
If PBX wants to activate MS Exchange Welcome menu, then it has to send an INVITE with destination DN, which does not match any of extension numbers registered within MS Exchange. As far as all extension numbers in MS Exchange are digital strings, using of literal string as a destination number always grants that Welcome Menu will be activated. For example, an INVITE with the INVITE sip:MNU@192.168.44.130:5060;transport=TCP SIP/2.0 request line will always activate Welcome menu.

Activating Auto Attendant Menu

MS Exchange Auto Attendant Menu is an interactive voice menu for accessing MS Exchange users; it has functionally similar to 3CX PhoneSystem Digital Receptionist. Each Auto Attendant has an assigned extension number.
For activation of Auto Attendant Menu, PBX has to send an INVITE with destination DN that matches the extension number of the Auto Attendant. For example, to activate the menu of the Auto Attendant with extension number ‘800’, PBX has to send an invite with the following request line:

INVITE sip:800@192.168.44.130:5060;transport=TCP SIP/2.0

Activating Menu for Voice Message Saving

Voice Message Saving dialog allows to record a message for a MS Exchange user. This menu is also accessible from Auto Attendant menu. The user must have an extension number (assigned within MS Exchange); otherwise, it is not accessible via MS Exchange interactive voice menus.
To activate Message Saving dialog, PBX has to send an INVITE with destination DN corresponding to the user’s extension number. PBX has also to add a ‘Diversion’ tag (header) to the INVITE as shown below.

INVITE from PBX (192.168.44.1:5060) to MS Exchange (192.168.44.130:5060) with diversion tag that activates Voice Message Saving dialog for the user with the ‘101’ extension number.

INVITE sip:101@192.168.44.130:5060;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 192.168.44.1:1205;branch=z9hG4bK-d87543-3c2d1616af40aa16-1–d87543-;rport
Max-Forwards: 70
Contact: <sip:100@192.168.44.1:1205;transport=TCP>
To: <sip:101@192.168.44.130:5060;transport=TCP>
From: “3CX Phone”<sip:100@192.168.44.1:5070>;tag=7f25cf6e
Call-ID: MjJjNGVhYTkyZjBhYjZlMDg3ZjYwZjU2NWRlNTI0Njk.
CSeq: 1 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, NOTIFY, REFER, SUBSCRIBE, INFO, PRACK, SUBSCRIBE
Content-Type: application/sdp
Content-Length: 349
Diversion: <tel:101>;reason=user-busy;screen=no;privacy=off
v=0
o=- 3381814733 3381814733 IN IP4 192.168.44.1
s=SIPPER for 3CX Phone
c=IN IP4 192.168.44.1
t=0 0
m=audio 5072 RTP/AVP 8 0 2 3 97 110 101
a=fmtp:101 0-15
a=ptime:20
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:3 GSM/8000
a=rtpmap:97 iLBC/8000
a=rtpmap:110 speex/8000
a=rtpmap:101 telephone-event/8000

Note: The information about diversion headers can be found on Microsoft Technet.
The DN after the ‘<tel:’ has to be the same as the destination DN. Possible values for the ‘reason’ value (this value describes why the call has been redirected to Message Saving dialog)

Include the following: unknown, user-busy, no-answer, unconditional, deflection, and follow-me (the information is taken from here:

Redirecting Call to Extension

MS Exchange Auto Attendant menu has a functionality which allows to redirect the current interactive voice session to an extension (in other words, to transfer the current call). In this case, MS Exchange just sends SIP REFER packet to the PBX without the current call dropping (standard SIP procedure of call redirection).

REFER from MS Exchange (192.168.44.130:5060) to PBX (192.168.44.1:5060). The call is redirected to the ‘101’ extension. The ‘192.168.44.1:1205’ address is the address of the phone that initiated the call. ‘810’ is the extension number of the Auto Attendant that redirected the call.

REFER sip:100@192.168.44.1:1205;transport=TCP SIP/2.0
FROM: <sip:810@192.168.44.130:5060;transport=TCP>;epid=67-99-54-E8-1E;tag=d965e756a5
TO: <sip:100@192.168.44.1:5070>;tag=ae5b3130
CSEQ: 1 REFER
CALL-ID: NmM3NDRlMDdkMzhjYjNkZmFjZDg1ZDg1MTUwZDZiOTg.
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 192.168.44.130:5065;branch=z9hG4bK1ddde115
CONTACT: <sip:fserver.exchange.3cx.test:5065;transport=Tcp;maddr=192.168.44.130>
CONTENT-LENGTH: 0
REFER-TO: <sip:101@192.168.44.1:1205;transport=TCP;user=phone>
USER-AGENT: RTCC/2.0.6017.0
Referred-By: sip:810@192.168.44.130:5060;transport=TCP

Playing Message to Extension

Outlook 2007 has a functionality which allows playing of user voice messages to a defined phone. This option is available only if Outlook 2007 has been successfully integrated (as a Unified Messaging client) with MS Exchange 2007.

Author did not trace message playing dialogs due to problems with Outlook 2007/MS Exchange 2007 integration. It looks obvious that MS Exchange sends to PBX an INVITE with the destination DN, as it would be done by any SIP phone. The main difference from the SIP phone is the fact that MS Exchange does not support authorization.

Problem of Authorization

As it was described earlier, MS Exchange does not support SIP authorization procedure. The only way is to allow messages (some or any) which come from the addresses of known MS Exchanges.

MS Exchange initiates new SIP session in at least two cases:

  1. When it pings PBX (sends OPTIONS packet).
  2. When it plays a user message from Outlook 2007.

When MS Exchange sends some SIP message (like INVITE, OPTIONS, or REFER) to a PBX, the former either:

A) Defines its IP and Port within the ‘FROM’ header as shown below.

Message containing IP and port of MS Exchange within the ‘FROM’ header.

REFER sip:100@192.168.44.1:1205;transport=TCP SIP/2.0
FROM: <sip:810@192.168.44.130:5060;transport=TCP>;epid=67-99-54-E8-1E;tag=d965e756a5
TO: <sip:100@192.168.44.1:5070>;tag=ae5b3130
CSEQ: 1 REFER
CALL-ID: NmM3NDRlMDdkMzhjYjNkZmFjZDg1ZDg1MTUwZDZiOTg.
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 192.168.44.130:5065;branch=z9hG4bK1ddde115
CONTACT: <sip:fserver.exchange.3cx.test:5065;transport=Tcp;maddr=192.168.44.130>
CONTENT-LENGTH: 0
REFER-TO: <sip:101@192.168.44.1:1205;transport=TCP;user=phone>
USER-AGENT: RTCC/2.0.6017.0
Referred-By: sip:810@192.168.44.130:5060;transport=TCP

Or  B) defines its domain name and port within the ‘FROM’ header, and its IP within the ‘CONTACT’ header. A sample is shown below.

Message containing domain name and port of MS Exchange within the ‘FROM’ header, and IP within the ‘CONTACT’ header.

OPTIONS sip:192.168.44.1:5060;transport=TCP SIP/2.0
FROM: <sip:fserver.exchange.3cx.test:5060>;epid=97-1A-5A-CE-20;tag=30185a849d
TO: <sip:192.168.44.1:5060;transport=TCP>
CSEQ: 70 OPTIONS
CALL-ID: 4b32633a9c7d40a78f11eb39d758f16d
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 192.168.44.130:1923;branch=z9hG4bK7b4b3ed5
ACCEPT: application/sdp
CONTACT: <sip:fserver.exchange.3cx.test:5060;transport=Tcp;maddr=192.168.44.130>
CONTENT-LENGTH: 0
USER-AGENT: RTCC/2.0.6017.0

The PBX can take the MS Exchange Server address from the incoming message, compare it with the addresses of known MS Exchange Servers, and decide whether the message should be allowed or rejected.

Liked this article?


Get notified of new articles
or share
You might also be interested in: