An LDAP to CardDav (1 way read) Phone Book Gateway.
Most modern (business) voice phones have the capability to do comfortable LDAP directory look-up like:
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:
You need some kind of 24/7 machine where this gateway live. Windows, Linux, Mac, (ARMx might come later if someone is interested).
In this early ‘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 a 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):
It will write to a small local database (defaults to ‘./l2cpbg-db.json’).
There are some hotkeys available on the console.
Hotkey | Description |
---|---|
h or ? | Quick hotkey help list |
s | Sync with CardDAV server (instead of waiting for the next syncinterval) |
The config file syntax is ‘ini’ based. Following a quick minimal sample:
; Comments get started with a semicolon
;
; The Gateway will act/listen as LDAP Server with the following settings
;
[ldap]
host = 0.0.0.0
;port = 1389
base = dc=example, dc=com
[ldap.bind]
dn = cn=pbx
pass = your-password
[dav]
server = https://cloudserver.example.com/remote.php/dav
user = cloud-login-name
pass = cloud-login-password
;addressbooks = regular-expression-of-lookup-adressbook
syncinterval = 5 ; Minutes
;[dav.map]
; tel = TEL
[location]
int = 1
area = 807
maxarealength = 7
language = en
;maxintlength = 3
;extdialprefix = 0, ; External dial prefix if called number > maxintlength
[log]
conslevel = verbose ; Console log level. Might be one of silly, debug, verbose, info, warn or error
;filename = ./l2cpbg.<notextile>%</notextile>DATE<notextile>%</notextile>.log ; Might contain a '<notextile>%</notextile>DATE<notextile>%</notextile>' placeholder
;filelevel = info ; File log level. Might be one of silly, debug, verbose, info, warn or error
host
: Which IP to listen for LDAP requests. Defaults to ‘127.0.0.1’ (=localhost). ‘0.0.0.0’ means: ‘Listen on all interfaces’. You’ve to point your LDAP phone settings to this machines IP/hostname.
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’.
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.
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 CardDav user during startup and log them as ‘Non-matching’ or ‘Matching’ address book(s).
syncinterval
: Interval of CardDav sync checks. Given in minutes, has to be greater than 2.
chunksize
: If an address book get loaded the first time (after L2CPBG start), it get loaded in “chunks of contacts” in this given size. You may increase this value for quicker initial load, but if your CardDAV server answer with an “507 Insufficient Storage” or similar, you need to lower this value. Default to 200. This option was added in L2CPBG version 0.8.1.
tel
: CardDAV attribute which contain the phone numbers. Normally (and by default) ‘TEL’.
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, …).
maxintlength
: Maximum length of internal phone numbers. These numbers don’t get harmonized or E.164 converted.
extdialprefix
: External dial prefix for getting an external line. Get prefixed before the phone number if target number length > maxintlength
conslevel
: Console log level. Might be one of silly, debug, verbose, info, warn or error. Defaults to verbose.
filelevel
: File log level. Might be one of silly, debug, verbose, info, warn or error. Defaults to info
The log levels are organized as follows:
silly
: This is the most verbose log level. It logs simply everything. Never use it in production environment as it might produce an awful amount of log entries!
debug
: Logs a lot internal stuff, probably interesting when searching a solution for an issue. Should not be used in production environment as it produce also a lot log entries!
verbose
: Logs everything which might be interesting during use. Not only results, also when something get started, detailed results and such things.
info
: This is the most usual log level. Logs only stuff which is relevant.
warn
: Logs stuff which doesn’t behave as expected. Not critical (generic functionality should be okay) but should be noticed/checked.
error
: Something essential/critical happened. Functionality is limited or aborted at all.
filename
: Log messages to this file. Might contain a ‘%DATE%’ placeholder which get replaced by the current date in ‘YYYYMMDD’ format. Defaults to empty = no log file.
filemaxsize
: Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add ‘k’, ‘m’, or ‘g’ as the suffix. The units need to directly follow the number. Defaults to 10m.
filedatepattern
: A string representing the date format to be used for rotating (and the %DATE% placeholder. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your filedatepattern is simply ‘HH’ you will end up with 24 log files that are picked up and appended to every day. Defaults to YYYYMMDD.
filemaxarchive
: Maximum number of archived logs to keep. This can be a number (>1) of files or number of days. If using days, add ‘d’ as the suffix. Defaults to 10.
fileziparchive
: Boolean (true|false) to define whether or not to gzip archived log files. Defaults to true.
filename
: Filename where to store the internal database. Defaults to ‘./l2cpbg-db.json’.
Every LDAP attribute which is used within a phone(s) filter or response, need to have a corresponding CardDav mapping.
This get done as follows:
First you need to define a separate block for the LDAP attribute in the following syntax:
[ldap.map.<ldap attribute name (case sensitive)>]
Within such a LDAP mapping block you have to define:
dav
: Corresponding CardDav field/attribute name.
and may define the following optional settings:
types
: Regular expression of relevant CardDav types or Apple addressbook label (Apple Adressbook extension: X-ABLabel).
index
: Zero based index in the case of a multi-value CardDav field.
For an overview of the predefined/default LDAP/CardDav mappings, take a look into the ‘config.sample’ file.
Here’s a configuration sample of a Gigaset N510 IP PRO:
Take attention that Server Address point to the machine where this gateway lives, as well as Serverport, BaseDN, Common User Name and Common Password get filled with the same values as defined in your L2CPG config file.
Another configuration sample of a Yealink SIP-T52S:
Take attention that Server Address point to the machine where this gateway lives, as well as Port, Base, User Name and Password get filled with the same values as defined in your L2CPG config file.
The LDAP configuration of Snom phones look similar to the ones of Gigaset or Yealink.
But a user reported that entering
(|(cn=*%*)(sn=*%*)(givenName=*%*)(company=*%*))
as ‘LDAP name filter’ did the trick for working name searches.
This early version is currently only tested with:
There are already some known issues!!! Not sure which will get fixed, might depend on how much people are interested in.
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]].
For getting help or discussing l2cpbg, please browse the L2CPBG Forum or check/open the Tickets area.