Project

General

Profile

Readme 091 » History » Version 1

Jörg Ebeling, 04/02/2021 08:28 PM

1 1 Jörg Ebeling
# LDAP-2-CardDAV Phone Book Gateway (l2cpbg)
2
3
An LDAP to CardDav (1 way read) Phone Book Gateway.
4
5
## Use case
6
7
Most modern (business) voice phones have the capability to do
8
comfortable LDAP directory look-up like:
9
10
-   Directory search by alphabet letters
11
-   Reverse lookup for in- or out-bound calls
12
-   Reverse lookup by entering parts or the phone number
13
14
Unfortunately, most of the 'smaller' companies (i guess companies beyond
15
100 employee) don't have an 'enterprise' LDAP directory, much less than
16
private persons.
17
18
Most of such companies do have something like a cloud address book,
19
often based on WebDAV / CardDAV (i.e. Nextcloud, Ownlcoud, Baïkal,
20
Daylite, ...).
21
22
This is, where this Gateway might make your live easier.
23
24
If this program get started on some kind of hardware (Windows, macOS or Linux), it will do the following:
25
26
1.  Query your CardDAV Server for relevant entries, and cache them to a
27
    small local database
28
2.  Wait and answer for LDAP requests from your voice phone(s)
29
30
## Features
31
32
-   Query your CardDAV address book(s) by entering the alphabetic
33
    letters (or parts of the telephone number) in your (LDAP capable)
34
    phone (and dial one of the matching numbers).
35
-   Reverse lookup inbound calls and display matching contact
36
    informations on the phone.
37
-   Work with local formatted (non- E.164) CardDAV entered phone numbers
38
    like: '040-123456' or '001 807 1234567' as well as '+49 (0)40
39
    1234567-8' = no need to enter your phone numbers within your CardDAV server in a special notation.
40
-   Supports internal (extension) phone numbers.
41
-   Support dial prefix for external line.
42
43
## Usage
44
45
You need some kind of 24/7 machine where this gateway live. Windows PC,
46
Linux, macOS, Raspberry or the like.
47
48
By default it will look for a configuration file in the following places (in the
49
given order):
50
51
1.  ./l2cpbg.conf
52
2.  /etc/l2cpbg.conf
53
54
It will write to a small local database directory (defaults to '/tmp/l2cpbg.db').
55
56
At the moment there's no "Admin GUI" or something like it. But for miminimal infos like "uptime", "license", "number of search requests" as well as "number of sent result records" you might send the l2cpbg process a `SIGHUP` signal and check the logs afterwards.
57
58
## Installaton
59
60
### Linux Debian ".deb" packages
61
62
`dpkg -i l2cpbg-<version>_<architecture>.deb` to install the package.
63
64
A sample configuration get places at `/etc/l2cpbg.conf`.
65
Initial startup will fail due to wrong/missing settings in config section `[dav]`!
66
Adapt at least `[ldap]`, `[ldap.bind]`, `[dav]` as well as `[location]` sections (in /etc/l2cpbg.conf) to your need.
67
Once done, restart l2cpbg by `systemctrl restart l2cpbg` and check startup by `systemctrl status l2cpbg`.
68
The full log can be read by `journalctl -u l2cpbg`.
69
To watch the actual/live logging, use `journalctl -fu l2cpbg`.
70
71
If l2cpbg started up, adapt your phone(s) to point their "LDAP Directory" lookup requests to l2cpbg with the settings you defined in /etc/l2cpbg.conf.
72
73
### Binary only "tar.gz" or ".zip" packages
74
75
No installation required. Only a simple executable and a configuration file.
76
77
Copy the binary `l2cpbg` wherever your like. For Linux, a common/good place would be `/usr/local/bin`.
78
Same with the `l2cpbg.conf` file. For Linux, a common/good place would be `/etc`.
79
80
The l2cpbg binary doesn't has a "daemonize" option, so it always runs in foreground. If you require to log off out of your machine, run it i.e. via 'screen' or check/adapt the systemd script from one of my ".deb" packages, to your needs.
81
82
## ~~Hotkeys~~
83
84
~~There are some hotkeys available on the console.~~
85
86
~~Hotkey  Description~~
87
88
## Configfile syntax
89
90
Since version 0.9.0 the config file syntax has changed from 'ini' to 'toml'. Not a big deal, but you need to adapt some entries. Mainly strings have to be entered within quotes!
91
92
Following a quick minimal sample:
93
```
94
# Comments get started with a hash character
95
96
#
97
# The Gateway will act as LDAP Server, listening
98
# for requests from your phone(s).
99
#
100
[ldap]
101
  host      = "0.0.0.0"
102
  #port     = 1389
103
  base      = "dc=example, dc=com"
104
105
[ldap.bind]
106
  dn   = "cn=pbx"
107
  pass = "your-password"
108
109
#
110
# Your CardDAV server where this Gateway get the contacts from
111
#
112
[dav]
113
  server       = "https://cloudserver.example.com/remote.php/dav"
114
  user         = "cloud-login-name"
115
  pass         = "cloud-login-password"
116
117
[location]
118
  int           = 1     # Your international code. 1 = US, 49 = Germany, ...
119
  area          = 807   # Your local area code (without a leading 0)
120
  maxarealength = 7
121
  country       = "EN"
122
```
123
124
### Config file description (by section)
125
126
#### \[ldap\] = LDAP Server settings
127
128
`host` : Which IP to listen for LDAP requests. Defaults to "0.0.0.0" = 'Listen on all interfaces'. You've to point your LDAP phone settings to this machines IP/hostname.
129
130
`port` : Which port to listen for LDAP requests. Defaults to port 1389. The standard LDAP port is 389, so you need to change your phone to the port you configure here.
131
132
`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'.
133
134
#### \[ldap.bind\] = LDAP bind/auth settings
135
136
`dn` : Distinguish name. Name, how the phone has to log into/authorize
137
to the gateway.
138
139
`pass` : Related 'dn' password, a phone has to use when logging in/authorize to the gateway.
140
141
#### \[dav\] = WebDav/CardDav server settings
142
143
`server` : Your WebDAV/CardDAV server address/URL. Please see 'Limitations'!
144
145
`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.
146
147
`pass` : Related user password.
148
149
`addressbooks` : Optional regular expression string of matchable addressbook(s)
150
used for phone book lookups. If unsure, enter something. l2cpbg will log
151
all found address books of the logged in CardDav user during startup and
152
log them as 'Non-matching' or 'Matching' address book(s).
153
154
`syncinterval` : Interval of CardDav sync checks. Given as string with suffix 'm' for minutes, or 'h' as hours. Has to be greater than "2m".
155
156
`chunksize` : If an address book get loaded the first time, 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" error or similar, you need to lower this value. Default to 200. This option was added in L2CPBG version 0.8.1.
157
158
`insecurecert` controls whether a client verifies the server's certificate
159
chain and host name. If insecurecert is true, crypto/tls accepts any
160
certificate presented by the server and any host name in that certificate.
161
In this mode, TLS is susceptible to machine-in-the-middle attacks unless
162
custom verification is used. This should be used only for testing or in
163
trusted environments. Defaults to *false*. This option was added in L2CPBG version 0.9.1.
164
165
#### \[dav.map\] = CardDav mapping
166
167
`tel` : CardDAV attribute which contain phone numbers. Normally (and
168
by default) 'TEL'. Don't change this, except your really know what you're doing.
169
170
#### \[location\] = Local area settings
171
172
`int` : International area code (1 = North America, ..., 44 = United
173
Kingdom, 49 = Germany, ...) of your location.
174
175
~~`intPrefix` : Dial prefix for international calls. Mostly "00". Defaults to "00".
176
ATTENTION: Has to be entered as string like "00".~~
177
178
`area` : Local area code without leading 0 (20 = London (UK), 40 =
179
Hamburg (DE), ...).
180
181
`areaPrefix` : Dial prefix for national calls. Mostly "0". Defaults to "0".
182
ATTENTION: Has to be entered as string like "0". 
183
184
`maxarealength` : Longest possible length of a telephone number within
185
your local area. If a found or received number is shorter or equal, it's
186
identified as a number without local area code.
187
188
`country` : Two-letter [ISO 3166-1 alpha-2](https://wikipedia.org/wiki/ISO_3166-1_alpha-2) country code (i.e. US, GB, DE, ...).
189
190
`maxintlength` : Maximum length of internal phone numbers. These numbers
191
don't get harmonized or E.164 converted.
192
193
`prettifyNums` : By default phone numbers loaded from CardDAV get
194
prettified in two ways:\
195
At first, if a CardDAV number is stored in international format,
196
but you live in the same country, the international part get removed.\
197
At second, the number get formatted in (spaced or braced) number groups
198
as it's common in your country.\
199
You can disable this prettifying by setting the value to false.
200
201
`extdialprefix` : Optional external dial prefix for getting an external line. Get prefixed before the phone number if outgoing number length \> `maxintlength`
202
203
#### \[log\] = Logging
204
205
`level` : Log level. Might be one of "trace", "debug", "info", "warn", "error" or "panic". Defaults to "info".
206
207
The log levels are organized as follows:
208
209
`trace` : This is the most verbose log level. It logs simply everything.
210
Never use it in production environment as it might produce an awful amount of log entries!
211
212
`debug` : Logs a lot internal stuff, probably interesting when searching
213
a solution for an issue. Should not be used in production environment as
214
it produce also a lot log entries!
215
216
`info` : This is the most usual log level. Logs only stuff which is relevant.
217
218
`warn` : Logs stuff which doesn't behave as expected. Not critical (generic functionality should be okay) but should be noticed/checked.
219
220
`error` : Something essential/critical happened. Functionality is limited or aborted at all.
221
222
`panic` : Game over.
223
224
#### \[db\] = Internal database
225
226
`directory` : An own directory where to store the internal database. Defaults to
227
'/tmp/l2cpbg.db' which is not very usefull on Linux based systems as it normally get cleaned after each reboot.
228
229
Choose yourself where to store the database.
230
If you've a small CardDAV server with <= 200 contacts, let the DB in /tmp.
231
An initial sync of 200 contacts (after a reboot) will be quickly done.
232
Not much storage space is needed. An CardDAV server with approx. 4 thousand contacts, take about 10 MByte storage.
233
234
ATTENTION: If you use one of the .deb packages, the binary get started as user=l2cpbg.
235
Thus, the given directory here, manually need to made owned by l2cpbg via
236
`chown -R l2cpbg:l2cpbg /your/db/directory`! Otherwise the DB process miss
237
read/write permissions and will fail!
238
239
#### \[ldap.map...\] = LDAP/CardDav mapping
240
241
Every LDAP attribute which is used within a phone(s) filter or response,
242
need to have a corresponding CardDav mapping which get done as follows:
243
244
First you need to define a separate block for the LDAP attribute in the
245
following syntax: `[ldap.map.<ldap attribute name (case sensitive)>]`
246
Within such a LDAP mapping block you have to define:
247
248
`dav` : Corresponding CardDav field/attribute name.
249
250
and optional define the following settings:
251
252
`itypes` : Regular expression (RE2 syntax) of including relevant CardDav types or *Apple addressbook label* (Apple Adressbook extension: X-ABLabel).
253
254
`etypes` : Regular expression (RE2 syntax) of **excluding** relevant CardDav types or *Apple addressbook label* (Apple Adressbook extension: X-ABLabel).
255
256
`index` : Zero based index in the case of a multi-value CardDav field.
257
258
For an overview of the predefined/default LDAP/CardDav mappings, take a
259
look into 'l2cpbg.sample.conf' file.
260
261
## Phone configuration
262
263
### Gigaset
264
265
Here's a configuration sample of a Gigaset N510 IP PRO:
266
![Gigaset N510 IP PRO settings sample for L2CPBG 0.7.0](https://projects.shbe.net/attachments/download/19/config_gigaset-n510-ip-pro_v070_de.jpg "Gigaset N510 IP PRO settings sample for L2CPBG 0.7.0")
267
Take attention that 'Server Address' point to the machine where this gateway lives (as well as 'Serverport')
268
269
'BaseDN', 'Common User Name' and 'Common Password' get filled with the same values as defined in your L2CPG config file.
270
271
### Yealink
272
273
Another configuration sample of a Yealink SIP-T52S:
274
![Yealink SIP-T52S settings sample for L2CPBG 0.7.0](https://projects.shbe.net/attachments/download/18/config_yealink-t52s_fw7084_v070_en.jpg "Yealink SIP-T52S settings sample for L2CPBG 0.7.0")
275
Take attention that 'Server Address' point to the machine where this gateway lives (as well as 'Port').
276
277
'Base', 'User Name' and 'Password' get filled with the same values as defined in your L2CPG config file.
278
279
### Snom
280
281
The LDAP configuration of Snom phones look similar to the ones of
282
Gigaset or Yealink.
283
But a user reported that entering `(|(cn=*%*)(sn=*%*)(givenName=*%*)(company=*%*))` within 'LDAP name filter' did the trick for working name searches.
284
285
## Compatibility
286
287
This version is tested with:
288
289
-   CardDAV Server:
290
    -   [Baïkal](https://sabre.io/baikal/) version 0.7.x
291
    -   [Daylite](https://www.marketcircle.com/)
292
    -   [Nextcloud](https://nextcloud.com/) version 13, 15, 16, 18 & 20
293
-   Phone Extensions:
294
    -   [Gigaset](https://www.gigasetpro.com/) N510 IP PRO, 670 IP Pro
295
    -   [Grandstream](http://www.grandstream.com/) GXP2170
296
    -   [Snom](https://www.snom.com/) 300, D315, D335
297
    -   [Yealink](https://www.yealink.com/) SIP-T52S, SIP-T54S, SIP-T54W
298
-   Gateway Host OS:
299
    -   [Debian](https://www.debian.org/) Stretch 9.x, Buster 10.x (running at amd64 as well as ARMv7)
300
    -   [macOS](https://www.apple.com/macos/) ™ Sierra 10.12.6
301
    -   [Ubuntu](https://ubuntu.com/) 20.04 (Focal Fossa)
302
303
## Limitations and Known Issues
304
305
There are already some known issues!!! Not sure which will get fixed, might depend on how much people are interested in.
306
307
-   The internal LDAP Server doesn't support LDAPS (encrypted LDAP
308
    communication) at the moment. Therefore 
309
    **it should not be used in an untrusted network!**
310
-   'Basic Authentication' over 'HTTPS' will work (for sure), but probably not
311
    with self signed certificates
312
313
## Support & getting help
314
315
For getting help or discussing l2cpbg, please browse the [L2CPBG
316
Forum](https://projects.shbe.net/projects/l2cpbg/boards) or check/open
317
the [Tickets](https://projects.shbe.net/projects/l2cpbg/issues) area.
Go to top