LDAP-2-CardDAV Phone Book Gateway (l2cpbg)

An LDAP to CardDav (1 way read) Phone Book Gateway.

Use case

Most modern (business) voice phones have the capability to do comfortable LDAP directory look-up like:

  • Directory search by alphabet letters
  • Reverse lookup for inbound calls
  • Reverse lookup by entering parts or the phone number

Unfortunately, most of the 'smaller' companies (i guess companies beyond 100 employee) don't have an 'enterprise' LDAP directory, much less than private persons.

Most of such companies do have something like a cloud address book, often based on WebDAV / CardDAV (i.e. Nextcloud, Ownlcoud, ...).

This is, where this Gateway might make your live easier (hopefully).

If this program get started on some kind of hardware (Windows, Mac, Linux, ???), it will do the following:

  1. Answer on LDAP requests from your voice phone(s)
  2. Ask your CardDAV (Nextcloud, Owncloud, ...) Server for the LDAP requested phone book entry
  3. Return the CardDAV query results, back as LDAP results to your phone.


  • Query your CardDAV address book(s) by entering the alphabetic letters (or parts of the telephone number) in you (LDAP capable) (business) phone (and dial one of the matching numbers).
  • Reverse lookup inbound calls and display matching contact information on the phone.
  • Work with local (non- E.164) formatted CardDAV entered phone numbers like: '040-123456' or '001 807 1234567' as well as '+49 (0)40 1234567-8'.
  • Alphabetic search requests get queried live (without a caching layer or sync delay). This might get changed or optionally enhanced in future, once I do have some experience with different CardDAV Server and larger (+1000 CardDAV) address books.
  • Reverse lookup on phone numbers, depend on a tiny caching layer and thus a (configurable) sync interval.


You need some kind of 24/7 machine where this Gateway live. Windows, Linux, Mac, (ARMx might come later).

In this current 'early' or 'beta' version, it runs in foreground. So, if you require to log off out of your machine, run it i.e. via 'screen'.

No installation required. Only one simple executable. Place it wherever your like. But I advice to start it as normal (non-root, non-administrative) user.

It will look for a configuration file in the following places (in the given order):

  1. ./.l2cpbgrc (or in it's parents)
  2. $HOME/.l2cpbgrc
  3. $HOME/.config/l2cpbg
  4. /etc/l2cpbgrc
  5. and some more uncommon places

Config file syntax

The config file syntax is 'ini' based. Following a quick sample:

; Comments get started with a semicolon
; The Gateway will act/listen as LDAP Server with the following settings
    host      =
    ;port      = 1389
    base      = dc=example, dc=com
    dn   = cn=pbx
    pass = your-password
    server       =
    user         = cloud-login-name
    pass         = cloud-login-password
    ;addressbooks = regular-expression-of-lookup-adressbook
    syncinterval = 5      ; Minutes
;  tel = TEL
;  fn  = FN
    int           = 1
    area          = 807
    maxarealength = 7
    country       = en

Config file description

[ldap] part

host : Which IP to listen for LDAP requests. Defaults to '' (=localhost). '' means: 'Listen on all interfaces'. You've to point your LDAP phone settings to this machines IP.
port : Port to listen for LDAP requests. Defaults to port 1389. You normally don't need to change this.
base : This LDAP's 'base DN'. Choose whatever you want, but use the same settings within your phone's LDAP settings. Defaults to 'dc=example, dc=com'.

[ldap.bind] part

dn : Distinguish name. Name, how the phone has to log into/authorize to the gateway.
pass : Related 'dn' password, a phone has to use when logging in/authorize to the gateway.

[dav] part

server : Your WebDAV/CardDAV server address/URL. Please see 'Limitations'!
user : WebDav username with read access to the relevant addressbook which shall be requested for phone book lookups. Might also be a 'shared' address book.
pass : Related user password.
addressbooks : Optional regular expression of matchable addressbook(s) used for phone book lookups. If unsure, enter something. l2cpbg will log all found address books of the logged in user during startup and log them as 'Non-matching' or 'Matching' address book.

[] part

tel : CardDAV attribute which contain the phone numbers. Normally (and by default) 'TEL'.
fn : CardDAV's 'Full Name' attribute. Normally (and default) 'FN'.

[location] part

int : International area code (1 = North America, ..., 44 = United Kingdom, 49 = Germany, ...) of your location.
area : Local area code without leading 0 (20 = London (UK), 40 = Hamburg (DE), ...).
maxarealength : Longest possible length of a telephone number within your local area. If a found or received number is shorter or equal, it's identified as a number without local area prefix.
country : Two-letter ISO 3166-1 alpha-2 country code (i.e. US, GB, DE, ...).

Phone configuration

p(. Here's a sample of a Yealink SIP-T52S configuration:
Yealink SIP-T52S settings sample
Take attention that Server Address, Base, User Name and Password get filled with the same values as defined in your L2CPG config file.


This early version is currently only tested (working) with:

  • CardDAV Server:
  • Phone Extensions:
    • Yealink SIP-T52S, SIP-T54S, SIP-T54W
  • Gateway Host OS:

Limitations and Known Issues

There are already some known issues!!! Not sure which will get fixed, might depend on how much people are interested in.

  • The LDAP Server doesn't support LDAPS (encrypted LDAP communication) at the moment. Therefore it should not be used in an untrusted nextwork!
  • The CardDAV Server HTTP-Authentication is currently restricted to 'Basic Authentication'. No 'Digest Access Authentication' like required i.e. for Daylite.
  • 'Basic Authentication' over 'HTTPS' will work (for sure), but without detailed certificate checking.


I already have a couple of To-Do's on my list. Following a (priority ordered) list. Feel free to drop me your wishes #support.

  1. Add (non-ansi) logging to file
  2. Add date & time info to log
  3. Daemonize (run in background/as service)
  4. DB-Caching layer for huge CardDAV address books (or slow CardDAV Server)
  5. Would be cool to enter the CardDAV relevant settings directly within the phone's LDAP settings! Possible?

Support & getting help

For getting help or discussing l2cpbg, please browse the L2CPBG Forum or check/open the Tickets area.

Updated by Jörg Ebeling over 5 years ago · 5 revisions

Go to top