Ldap directory for Cisco 7940 / 7960 IP Phones
To avoid having to run multiple address-books on various PC’s, and still having to search for a number when making a phone call, I decided to build a central ldap server inside my network.
Although probably overkill in a home network, a central address book would allow me to read my contacts from every PC. And of course, while at this stage, it was desired to be able to read the database from the Cisco 7960 IP phones as well.
I found a script on the internet, orginally written by Gael Marronnier, and modified it to meet my needs.
Oringally my IP-PBX was 3CX server, where I ran the ldap server and the webserver all on the same platform. After migrating to Trixbox, I decided to run the ldap standalone, to not put to much pressure on my Trixbox (it’s only a small Flepo server).
Requirements to make this work:
1) Load the below scripts on your webserver
1a) Your webserver must have the ldap module loaded
2) Make sure your directory button on the Cisco phone points to the right URL:
SIPDefault.cnf
directory_url: "http://192.168.1.3/cisco/services/directory.php"
directory.php
1 2 3 4 5 6 7 8 9 10 11 | <CiscoIPPhoneInput> <Title>Addressbook</Title> <Prompt>Prompt text.</Prompt> <URL>http://192.168.1.3/cisco/services/result.php</URL> <InputItem> <DisplayName>Filter</DisplayName> <QueryStringParam>filter</QueryStringParam> <InputFlags></InputFlags> <DefaultValue></DefaultValue> </InputItem> </CiscoIPPhoneInput> |
result.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | <?php // This XML-PHP page searches contacts in LDAP and display it on CISCO directory service // Script Provided by Gael Marronnier From Simstream Company www.simstream.com gael_asterisk@simstream.com // Modified by Arnaud Croes (arnaud@croesnet.eu) to make it work properly in a 3CX environment // // Get parameter from directory script $filter = $_REQUEST["filter"]; // LDAP server characteristics $ds=ldap_connect("192.168.1.2"); if (ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3)) { echo "Using LDAP v3"; }else{ echo "Failed to set version to protocol 3"; } $myldap="ou=addressbook,dc=domain,dc=com"; // Phone entries on my LDAP server are in the format +1 (800) 5551234, the way outlook likes it. // Names on the server (cn) are not supposed to have special characters like & // The script replaces the + by 00 , because 3CX doesn't like the + character in the dial string. // Also removing space, ( and ) characters. // Removing the ( and ) characters is just cosmetic, they do not cause functionality problems. // Phone number format change variables $patterns[0] = '/\+/'; $patterns[1] = '/\(|\)|-|\s+/'; $replacements[0] = '00'; $replacements[1] = ''; if ($ds) { $r=ldap_bind($ds); $filterldap="(|(givenname=*".$filter."*)(sn=*".$filter."*)(cn=*".$filter."*)(mail=*".$filter."*))"; $sr=ldap_search($ds, $myldap, $filterldap); // Lets start displaying XML infos echo "<CiscoIPPhoneDirectory>\n"; echo "<Title>IP Telephony Directory</Title>\n"; $info = ldap_get_entries($ds, $sr); echo "<Prompt>"; echo $info["count"]; echo " Reachable person(s)</Prompt>\n"; for ($i=0; $i<$info["count"]; $i++) { if ($info[$i]["mobile"][0]) { echo "<DirectoryEntry>\n"; echo "<Name>" . iconv("UTF-8","ISO-8859-1",$info[$i]["cn"][0]) . " (mobile)</Name>\n"; echo "<Telephone>" .preg_replace($patterns, $replacements, $info[$i]["mobile"][0]) ."</Telephone>\n"; echo "</DirectoryEntry>\n"; } if ($info[$i]["homephone"][0]) { echo "<DirectoryEntry>\n"; echo "<Name>" . iconv("UTF-8","ISO-8859-1",$info[$i]["cn"][0]) . " (home)</Name>\n"; echo "<Telephone>" .preg_replace($patterns, $replacements, $info[$i]["homephone"][0]) ."</Telephone>\n"; echo "</DirectoryEntry>\n"; } if ($info[$i]["telephonenumber"][0]) { echo "<DirectoryEntry>\n"; echo "<Name>" . iconv("UTF-8","ISO-8859-1",$info[$i]["cn"][0]) . " (business)</Name>\n"; echo "<Telephone>" .preg_replace($patterns, $replacements, $info[$i]["telephonenumber"][0]) ."</Telephone>\n"; echo "</DirectoryEntry>\n"; } } echo "</CiscoIPPhoneDirectory>"; ldap_close($ds); } else { echo "error"; } ?> |
Changed this parameters
$ds=ldap_connect(“192.168.1.2″);
$myldap=”ou=addressbook,dc=domain,dc=com”; with no success.
Also tried with authorized ldap bind, still no luck.
My search say : 0 Reachable person(0)
It must be my ldap connect/bind that has the error ?
change the search, and I get : Using LDAP v3 974 Reachable person(s)
The search on cisco result in : CMXML error, XML parse error
which PHP version is requested
[12:59:20:138010]
Http Recv [131] Bytes of Data
Data Packet is:
===============
Using LDAP v3
IP Telephony Directory
1 Reachable person(s)
===============
[12:59:20:138011] HTTP RECV (CLOSE CMD)
[12:59:20:138011] Platform_Close_Socket conn[2]
[12:59:20:138013] GUI_XML_Parse: Unknown Parse Error
[12:59:20:138014] Platform_Close_Socket conn[2]
@zzbo
Hi, have you tried using a different LDAP client to connect to your LDAP-server? For example LDAPAdmin (a cool, free windows tool).
I have the services scripts running on the trixbox itself, using PHP Version 5.2.5.
The LDAP server is OpenLDAP, running on a Linksys NLSU2.
I’m currently using this php directory, and it’s working perfect on my 7940/7960 phones. But my 7971 just give me XML Error [4]: Parse Error.
Can I http debug 7971 phones?
___________
directory.php:
Ventelo phonebook (fra AD)
Prompt text.
http://(webserver)/result.php
Name
filter
A
Shortnumber
filter
T
Mobile
filter
T
1
Search
SoftKey:Submit
2
<<
SoftKey:<<
3
Cancel
SoftKey:Cancel
It took me a while myself as well to get it to work with the 79×1 series. See my other post about that:
http://croesnet.eu/trixbox/ldap-directory-for-cisco-7941-7961-ip-phones/
I just had to modify the script, meaning I use two different parallel scripts now. One set for the 79×0 series, another one for the 79×1 series.
I also have not been able (yet) to make the directory button work on the 79×1 series. The ldap search is reachable via the services button.
got my directory.php to show under directory after I found a type error that the 7971 didn’t like. I had placed an with no start . However the result is just spinning.. “requesting…”