Tuesday, January 18, 2011

Microsoft Lync Server 2010 Integration with Digium Asterisk

We have been using Microsoft Office Communications Server for a long time now, and have recently begun testing Lync.  It took mere minutes for me to get Lync working with Asterisk 1.6.2.  The same steps work for Asterisk 1.8 as well, and for the most part are the same in trixbox, freepbx, elastix, etc.

Asterisk Configuration
First, I configured my Asterisk installation, you have to enabled TCP SIP, and create a peer.  I added the following to the sip.conf general section:

[general]
tcpbindaddr=0.0.0.0
tcpenable=yes

and then I added my peer for Lync


[LYNC_TRUNK]
type=peer
host=192.168.11.4
qualify=no
transport=tcp,udp
canreinvite=no
port=5068
disallow=all
allow=ulaw
context=from-ocs

I used the context from-ocs, so I set up a basic context in extensions.conf, cutting off the + that comes through and sending the call to the normal internal call context for normal call handling:
[from-ocs]
exten => _+1XXX,1,Goto(internal-call,${EXTEN:1},1)
exten => _+1XXXXXXXXXX,1,Dial(SIP/${EXTEN}@OUTBOUND_PROVIDER,30)

You will need to make a test extension in your normal dial context to test calling in to Lync, something like this should work
exten => 1000,1,Dial(SIP/+2593@LYNC_TRUNK,30)

After restarting asterisk that side of things should be configured, now just to make sure you have Lync configured.

Lync Configuration (Standard Edition)
  1. Open the Lync 2010 Topology Builder
  2. Edit the properties of your standard edition pool
  3. Install the mediation server, I used the Collocated option because load is low enough it doesn't need a dedicated server.
  4. Under mediation server take note of the TCP Listening port, as that is the port you need to specify in sip.conf of Asterisk.  It defaults to 5068 so that's what I used.
  5. At the bottom find the section "The following gateways are associated with this mediation server." 
  6. Click New, and enter the IP address of your Asterisk server, and the port you use for Asterisk TCP SIP (5060 by default).
  7. Note that mine has a red X saying i already have this address configured.  This is because I was redoing the steps for this tutorial.  Also note I have two gateways added as my Asterisk server has multiple IP Addresses and you must make sure to enter all addresses in the gateway list.

  8. Once this is done make sure to publish your topology and re-run setup if you did not previously have the mediation service installed.  I restarted my entire Lync server at this point but if you'd prefer you should be able to restart the Mediation service to apply the new settings.
  9. Open your Lync control panel, go to users, edit your test user and enable Telephony for Enterprise Voice.
  10. We use 2XXX range extensions in Lync, and 1XXX range extensions in Asterisk, so you will see tel:+2593, and ext=1593.  The ext=1593 is for PSTN Conferencing support so Lync can see me
    call from 1593 and know I am Andrew, and automatically authenticate me in to my own conferences..
  11. Configure Voice Routing -> Dial Plan.  These are the rules I wrote in OCS 2007 R2 and imported using import-cslegacyconfiguration.  You will need to tweak them for your requirements.
  12. At this point you should be able to make/receive calls to and from Lync/Asterisk.

Exchange 2010 Backup Failure with Data Protection Manager 2010

About a month ago we created a new mailbox store on our Exchange 2010 SP1 server, and last night I started getting alarms that the server was running low on disk space on the drive that contains the transaction logs.  This happened because the new store was not automatically picked up by DPM 2010, and the transaction logs had built up over time eating away at the available disk space.  My fault for forgetting to verify DPM had the store being backed up.

I went to add it in DPM and got the following error upon expanding the exchange server to add the new database store:
DPM could not enumerate application component Microsoft Exchange Server\Microsoft Information Store\csgtacex1\17a465cc-90ca-4abd-927f-9aed49f33b5e on protected computer csgtacex1.domain.com. (ID: 964)

Please make sure that writer is in good state.


I discovered a VSS error on my exchange server which I fixed by cleaning up the ProfileList entry that had .bak attached to the end of it.  This is something i've seen break on Windows Vista machines recently, so I found it interesting that it started causing problems on an Exchange server.
To clean up the entries with .bak open regedit, and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\ and remove any keys that have .bak appended to them.  For good measure I made a backup before deleting the key.  After rebooting the VSS errors were gone, but DPM still didn't work.

I googled the DPM specific error and found this post on technet about the same error.  My system had everything working in vssadmin list writers, so further down Frans posts about missing registry keys for powershell.  This got me curious because I had noticed since upgrading to Exchange 2010 Service Pack 1 that the power shell had disappeared.  I immediately became suspicious.  His solution was to export the missing keys from another server that had them, and then import them on the missing server.  I had another server with the keys there, made an export, imported it, and DPM immediately worked.  If you would like, this is the .reg file I exported.  Save this to a .reg and import it and you should be good to go.



Windows Registry Editor Version 5.00


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns]
@=""


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.Exchange.Management.PowerShell.E2010]
"CustomPSSnapInType"="Microsoft.Exchange.Management.PowerShell.AdminPSSnapIn"
"ApplicationBase"="C:\\Program Files\\Microsoft\\Exchange Server\\V14\\bin"
"AssemblyName"="Microsoft.Exchange.PowerShell.Configuration, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
"Description"="Admin Tasks for the Exchange Server"
"ModuleName"="C:\\Program Files\\Microsoft\\Exchange Server\\V14\\bin\\Microsoft.Exchange.PowerShell.Configuration.dll"
"PowerShellVersion"="1.0"
"Vendor"="Microsoft Corporation"
"Version"="14.0.0.0"


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.Exchange.Management.PowerShell.Setup]
"CustomPSSnapInType"="Microsoft.Exchange.Management.PowerShell.SetupPSSnapIn"
"ApplicationBase"="C:\\Program Files\\Microsoft\\Exchange Server\\V14\\bin"
"AssemblyName"="Microsoft.Exchange.PowerShell.Configuration, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
"Description"="Setup Tasks for the Exchange Server"
"ModuleName"="C:\\Program Files\\Microsoft\\Exchange Server\\V14\\bin\\Microsoft.Exchange.PowerShell.configuration.dll"
"PowerShellVersion"="1.0"
"Vendor"="Microsoft"
"Version"="14.0.0.0"


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.Exchange.Management.Powershell.Support]
"CustomPSSnapInType"="Microsoft.Exchange.Management.Powershell.Support.SupportPSSnapIn"
"ApplicationBase"="C:\\Program Files\\Microsoft\\Exchange Server\\V14\\bin"
"AssemblyName"="Microsoft.Exchange.Management.Powershell.Support, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
"Description"="Support Tasks for the Exchange Server"
"ModuleName"="C:\\Program Files\\Microsoft\\Exchange Server\\V14\\bin\\Microsoft.Exchange.Management.Powershell.Support.dll"
"PowerShellVersion"="1.0"
"Vendor"="Microsoft Corporation"
"Version"="14.0.0.0"