Script: Exchange Shared Contacts Folder over Aastra XML Menu

bmacdonald
Posts: 11
Member Since:
2009-11-18

We have an exchange server that hosts a "Shared Contacts" public folder, which serves as our company-wide directory of clients and contacts. I wanted to be able to access the directory from our Aastra 57i phones, and I wanted Asterisk to use the Shared Contacts folder for Caller ID lookups. I got everything working quite nicely in our environment, so I'm posting it here in case anyone else finds it useful or instructive. Feedback is welcome, but I don't have a lot free time for support and can't take any further feature requests. Consider this as-is, no warranty express or implied.

Important Notes:
This requires Exchange 2007 Service Pack 1 or later. Your Exchange server must have Exchange Web Services (EWS) enabled (which it is by default on SBS 2008, I believe). A working SSL certificate on your exchange server is probably also required.

I forget how I implemented it, but I think that it will only work out-of-the-box if you have only one Contacts folder within your public folders (and it must be in the root of your public folders). If you have a different setup, your results may vary - just modify the code as needed.

Only US/Canada phone numbers will be listed/recognized. You could easily adapt the code to support other countries, though.

To use it:

0. Download it: http://www.bradenm.com/misc/exchange_link.zip
1. Unzip within the /var/www/html/ folder of your asterisk server. This will install it to /var/www/html/exchange_link/
2. Be sure to chown asterisk:asterisk /var/www/html/exchange_link/ as the directory must be writeable by PHP
3. Edit /var/www/html/exchange_link/config.php - self explanatory
4. Edit the last line of /var/www/html/exchange_link/services.wsdl to reflect the proper EWS URL for your exchange server (change 'remote.yourcompany.com'); hackish but necessary
5. Add the following softkey to your phone's profile or web config (change 4 to a free softkey slot):

	softkey4 type:xml
	softkey4 label:Contacts
	softkey4 value:http://$$AA_XML_SERVER_AA$$/exchange_link/contacts.php
	softkey4 states:idle

6. Save changes and/or log in and log out of your phones and try the new softkey. If you set the automatic updates setting to false, you will have to use the 'update' menu option from within this script's main menu before first use.
7. (Optional) To integrate Caller ID lookup from the same source, go to "CallerID Lookup Sources" in FreePBX, and add a new HTTP source with host 'localhost', path '/exchange_link/cname.php' and query 'p=[NUMBER]'. Leave the other fields blank. Then, click on "Inbound Routes", and set the new source as your 'CID Lookup Source' for any inbound routes you have.



mag
Posts: 135
Member Since:
2006-05-31
Can't get it working

Hi,

Thanks for the scripts - I've installed everything as per instructions but am not able to get the contacts. I am running SBS 2008.
I see the following error in the apache logs when calling the script.

 PHP Fatal error:  Uncaught SoapFault exception: [soap11:Client] The request failed schema validation: 
The element 'FindFolder' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has incomplete content.
 List of possible elements expected: 'IndexedPageFolderView, FractionalPageFolderView, Restriction, ParentFolderIds' in namespace
 'http://schemas.microsoft.com/exchange/services/2006/messages'. in /var/www/html/exchange_link/update.php:166\nStack trace:
\n#0 [internal function]: SoapClient->__call('FindFolder', Array)\n#1 /var/www/html/exchange_link/update.php(166): 
ExchangeNTLMSoapClient->FindFolder(Object(stdClass))\n#2 /var/www/html/exchange_link/contacts.php(133):
 include('/var/www/html/e...')\n#3 {main}\n  thrown in /var/www/html/exchange_link/update.php on line 166

Any hints/tips on where the problem lies and how to resolve?

Thanks



bmacdonald
Posts: 11
Member Since:
2009-11-18
Sorry for the delay in replying

First thing to check: are you using Exchange 2007 Service Pack 1 ? It won't work without SP1.
Next, what version of PHP and PHP's SOAP extension, if different, are you using? Similar errors on the internet seem to be caused by upgrading/changing the PHP version.



Atcom Alberta
Posts: 220
Member Since:
2008-07-14
Hey MaG, Did you ever get it

Hey MaG,

Did you ever get it working? We have a customer asking for this and could use your expertise in "consulting" form :-)



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.