Configuring CISCO 7940 / 7960 to retrieve directory from OpenLDAP
The purpoe of this post is to explain how to display a LDAP directory on CISCO 7940 / 7960.
First you need a LDAP configured.
In my example, I use OpenLDAP with this structure : dc=simstream,dc=com. LDAP server : serv3.simstream.com, no authentication
The job is done by two PHP pages: directory.php & result.php reachable via service and directory buttons on Cisco phones.
You need first to specify in the SIPDefault.cnf what page to call :
services_url: “http://serv1.simstream.com/phone/directory.php”
directory_url: “http://serv1.simstream.com/phone/directory.php”
serv1.simstream.com is an apache (HTTP) server with PHP4 and mod LDAP
Cisco SIPDefault.cnf
image_version: P0S3-06-2-00
proxy1_address: "serv2.simstream.com" ; Can be dotted IP or FQDN
proxy1_port: 5060
proxy_register: 1
# Phone Registration Expiration [1-3932100 sec] (Default - 3600)
timer_register_expires: 3600
# Codec for media stream (g711ulaw (default), g711alaw, g729a)
preferred_codec: g711ulaw
# TOS bits in media stream [0-5] (Default - 5)
tos_media: 5
# Inband DTMF Settings (0-disable, 1-enable (default))
dtmf_inband: 1
# Out of band DTMF Settings (none-disable, avt-avt enable (default), avt_always - always avt )
dtmf_outofband: avt
# DTMF dB Level Settings (1-6dB down, 2-3db down, 3-nominal (default), 4-3db up, 5-6dB up)
dtmf_db_level: 3
# SIP Timers
timer_t1: 500 ; Default 500 msec
timer_t2: 4000 ; Default 4 sec
sip_retx: 10 ; Default 10
sip_invite_retx: 6 ; Default 6
timer_invite_expires: 180 ; Default 180 sec
####### New Parameters added in Release 2.0 #######
# Dialplan template (.xml format file relative to the TFTP root directory)
dial_template: dialplan
# TFTP Phone Specific Configuration File Directory
tftp_cfg_dir: "./sip-phones/"
# Time Server (There are multiple values and configurations refer to Admin Guide for Specifics)
sntp_server: "134.59.1.5" ; SNTP Server IP Address
sntp_mode: directedbroadcast ; unicast, multicast, anycast, or directedbroadcast (default)
time_zone: CET ; Time Zone Phone is in
dst_offset: 1 ; Offset from Phone's time when DST is in effect
dst_start_month: April ; Month in which DST starts
dst_start_day: "" ; Day of month in which DST starts
dst_start_day_of_week: Sun ; Day of week in which DST starts
dst_start_week_of_month: 1 ; Week of month in which DST starts
dst_start_time: 02 ; Time of day in which DST starts
dst_stop_month: Oct ; Month in which DST stops
dst_stop_day: "" ; Day of month in which DST stops
dst_stop_day_of_week: Sunday ; Day of week in which DST stops
dst_stop_week_of_month: 8 ; Week of month in which DST stops 8=last week of month
dst_stop_time: 2 ; Time of day in which DST stops
dst_auto_adjust: 1 ; Enable(1-Default)/Disable(0) DST automatic adjustment
time_format_24hr: 1 ; Enable(1 - 24Hr Default)/Disable(0 - 12Hr)
# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control)
dnd_control: 0 ; Default 0 (Do Not Disturb feature is off)
# Caller ID Blocking (0-disbaled, 1-enabled, 2-disabled no user control, 3-enabled no user control)
callerid_blocking: 0 ; Default 0 (Disable sending all calls as anonymous)
# Anonymous Call Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control)
anonymous_call_block: 0 ; Default 0 (Disable blocking of anonymous calls)
# DTMF AVT Payload (Dynamic payload range for AVT tones - 96-127)
dtmf_avt_payload: 101 ; Default 101
# Sync value of the phone used for remote reset
sync: 1 ; Default 1
####### New Parameters added in Release 2.1 #######
# Backup Proxy Support
proxy_backup: "" ; Dotted IP of Backup Proxy
proxy_backup_port: 5060 ; Backup Proxy port (default is 5060)
# Emergency Proxy Support
proxy_emergency: "" ; Dotted IP of Emergency Proxy
proxy_emergency_port: 5060 ; Emergency Proxy port (default is 5060)
# Configurable VAD option
enable_vad: 0 ; VAD setting 0-disable (Default), 1-enable
####### New Parameters added in Release 2.2 ######
# NAT/Firewall Traversal
nat_enable: 0 ; 0-Disabled (default), 1-Enabled
nat_address: "" ; WAN IP address of NAT box (dotted IP or DNS A record only)
voip_control_port: 5060 ; UDP port used for SIP messages (default - 5060)
start_media_port: 16384 ; Start RTP range for media (default - 16384)
end_media_port: 32766 ; End RTP range for media (default - 32766)
nat_received_processing: 0 ; 0-Disabled (default), 1-Enabled
# Outbound Proxy Support
outbound_proxy: "" ; restricted to dotted IP or DNS A record only
outbound_proxy_port: 5060 ; default is 5060
####### New Parameter added in Release 3.0 #######
# Allow for the bridge on a 3way call to join remaining parties upon hangup
cnf_join_enable : 1 ; 0-Disabled, 1-Enabled (default)
####### New Parameters added in Release 3.1 #######
# Allow Transfer to be completed while target phone is still ringing
semi_attended_transfer: 1 ; 0-Disabled, 1-Enabled (default)
# Telnet Level (enable or disable the ability to telnet into the phone)
telnet_level: 2 ; 0-Disabled (default), 1-Enabled, 2-Privileged
####### New Parameters added in Release 4.0 #######
# XML URLs
services_url: "http://serv1.simstream.com/phone/directory.php" ; URL for external Phone Services
directory_url: "http://serv1.simstream.com/phone/directory.php" ; URL for external Directory location
logo_url: "http://serv1.simstream.com/phone/logo.bmp" ; URL for branding logo to be used on phone display
messages_uri: "123"
# HTTP Proxy Support
http_proxy_addr: "" ; Address of HTTP Proxy server
http_proxy_port: 80 ; Port of HTTP Proxy Server (80-default)
# Dynamic DNS/TFTP Support
dyn_dns_addr_1: "" ; restricted to dotted IP
dyn_dns_addr_2: "" ; restricted to dotted IP
dyn_tftp_addr: "" ; restricted to dotted IP
# Remote Party ID
remote_party_id: 0 ; 0-Disabled (default), 1-Enabled
####### New Parameters added in Release 4.4 #######
# Call Hold Ringback (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control)
call_hold_ringback: 0 ; Default 0 (Disable ringback of held call)
directory.php
<CiscoIPPhoneInput>
<Title>Annuaire LDAP Simstream</Title>
<Prompt>Prompt text.</Prompt>
<URL>http://serv1.simstream.com/phone/result.php</URL>
<InputItem>
<DisplayName>Filtre</DisplayName>
<QueryStringParam>filtre</QueryStringParam>
<InputFlags></InputFlags>
<DefaultValue></DefaultValue>
</InputItem>
</CiscoIPPhoneInput>
result.php
<?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 [email protected]
//
// First I get the parameter
$filtre = $_REQUEST["filtre"];
// Now I contuct the LDAP query
$ds=ldap_connect("serv3.simstream.com");
$myldap="dc=simstream,dc=com";
if ($ds) {
// $r=ldap_bind($ds);
$filtreldap="(&(objectclass=person)(|(givenname=*".$filtre."*)(sn=*".$filtre."*)(cn=*".$filtre."*)(mail=*".$filtre."*)))";
$sr=ldap_search($ds, $myldap, $filtreldap);
// 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 people</Prompt>\n";
for ($i=0; $i<$info["count"]; $i++) {
if ($info[$i]["mobile"][0]) {
echo "<DirectoryEntry>\n";
echo "<Name>M:" . iconv("UTF-8","ISO-8859-1",$info[$i]["cn"][0]) . "</Name>\n";
// I replace the french international extension (+33) by 0. It s not really clean, fell free to improve
echo "<Telephone>" .str_replace(" ","",str_replace("+33","0", $info[$i]["mobile"][0])) ."</Telephone>\n";
echo "</DirectoryEntry>\n";
}
if ($info[$i]["telephonenumber"][0]) {
echo "<DirectoryEntry>\n";
echo "<Name>T:" . iconv("UTF-8","ISO-8859-1",$info[$i]["cn"][0]) . "</Name>\n";
echo "<Telephone>" .str_replace(" ","",str_replace("+33","0", $info[$i]["telephonenumber"][0])) ."</Telephone>\n";
echo "</DirectoryEntry>\n";
}
if ($info[$i]["telephonenumber"][1]) {
echo "<DirectoryEntry>\n";
echo "<Name>T:" . iconv("UTF-8","ISO-8859-1",$info[$i]["cn"][0]) . "</Name>\n";
echo "<Telephone>" .str_replace(" ","",str_replace("+33","0", $info[$i]["telephonenumber"][1])) ."</Telephone>\n";
echo "</DirectoryEntry>\n";
}
if ($info[$i]["telephonenumber"][2]) {
echo "<DirectoryEntry>\n";
echo "<Name>T:" . iconv("UTF-8","ISO-8859-1",$info[$i]["cn"][0]) . "</Name>\n";
echo "<Telephone>" .str_replace(" ","",str_replace("+33","0", $info[$i]["telephonenumber"][2])) ."</Telephone>\n";
echo "</DirectoryEntry>\n";
}
}
echo "</CiscoIPPhoneDirectory>";
ldap_close($ds);
} else {
echo "error";
}
?>