Asterisk – setting the caller id through an ldap lookup

Having just upgraded to asterisk 1.6, I was faced with the problem of callerid lookup no longer working.
We’d previously used the external LDAPGet module to lookup against our internal LDAP directory – but the module doesn’t compile in 1.6, so here’s a quick and dirty workaround which requires you have ldap-utils installed on your server.

In my extensions.conf :
exten => _[a-zA-Z0-9].,9,Set(CALLERID(name)=${SHELL(ldapsearch -w thepassword -D “cn=admin,dc=mydomain,dc=com” -h ldapserver -b “ou=addressbook,dc=mydomain,dc=com” -s children “(&(objectClass=person)(telephoneNumber=${CALLERID(num)}))” cn | grep ^cn | cut -d: -f2 | xargs echo -n)})

Where I used to have :

exten => _[a-zA-Z0-9].,9,LDAPget(CALLERID(name)=cidname)

1 thought on “Asterisk – setting the caller id through an ldap lookup”

  1. That is only working if you do not have it base 64 coded, I use:
    exten => s,n,Set(CALLERID(name)=${SHELL(ldapsearch -w password -D “cn=x,dc=x,dc=x” -h localhost -b “ou=x,dc=x,dc=x” -s children “(&(o
    bjectClass=person)(|(telephoneNumber=${CALLERID(number)})(otherPhone=${CALLERID(number)})(primaryPhone=${CALLERID(number)})(companyPhone=${CALLERID(number)})(mob
    ile=${CALLERID(number)})(homePhone=${CALLERID(number)})(pager=${CALLERID(number)})(primaryPhone=${CALLERID(number)})))” cn | grep ^cn | perl -MMIME::Base64 -lpe
    ‘s/^([^:]*:):(\s*)(.*)/”$1$2″.decode_base64($3)/e’ |cut -d: -f2 | xargs echo -n)})

Leave a Reply

Your email address will not be published. Required fields are marked *