Project

General

Profile

Readme 092 » History » Version 1

Jörg Ebeling, 08/04/2021 11:36 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.  Synchronize your CardDAV Server, to a small local database
27
2.  Wait and answer for LDAP requests from your voice phone(s)
28
29
## Features
30
31
-   Query your CardDAV address book(s) by entering the alphabetic
32
    letters (or parts of the telephone number) in your (LDAP capable)
33
    phone (and dial one of the matching numbers).
34
-   Reverse lookup inbound calls and display matching contact
35
    informations on the phone.
36
-   Work with local formatted (non- E.164) CardDAV entered phone numbers
37
    like: '040-123456' or '001 807 1234567' as well as '+49 (0)40
38
    1234567-8' = no need to format your phone numbers of your CardDAV contacts in a special notation.
39
-   Supports internal (extension) phone numbers.
40
-   Support dial prefix for external line.
41
-   Support short internal extension numbers.
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
3.  /usr/local/etc/l2cpbg.conf
54
55
It will write to a small local database directory (defaults to 'os.TempDir()/l2cpbg.db').
56
57
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.
58
59
## Installation
60
61
### Linux Debian ".deb" packages
62
63
`dpkg -i l2cpbg_<version>_<architecture>.deb` to install the package.
64
65
- A sample configuration get places at `/etc/l2cpbg.conf`.  
66
- Initial startup will fail due to wrong/missing settings in config section `[dav]`!  
67
- Adapt at least `[ldap]`, `[ldap.bind]`, `[dav]` as well as `[location]` sections (in /etc/l2cpbg.conf) to your need.
68
- Once done, restart l2cpbg by `systemctrl restart l2cpbg` and check startup by `systemctrl status l2cpbg`.  
69
- The full log can be read by `journalctl -u l2cpbg`.  
70
- To watch the actual/live logging, use `journalctl -fu l2cpbg`.
71
72
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.
73
74
### Linux binary "tar.gz" packages ("systemd" Systems)
75
76
1. Extract binary i.e. to /usr/local/bin: `sudo tar xvf l2cpbg_0.9.2_linux-amd64.tgz -C /usr/local/bin/ l2cpbg`
77
2. Extract config file, i.e. to /etc: `sudo tar xvf l2cpbg_0.9.2_linux-amd64.tgz -C /etc/ l2cpbg.conf`
78
3. Adapt config section `[ldap]`, `[ldap.bind]`, `[dav]` as well as `[location]` to your need.
79
4. Do a first foreground start via `l2cpbg` and check terminal output for any issues. \<Ctrl-c\>, edit config and start `l2cpbg` till terminal output is okay.
80
5. If terminal output is okay and everything work as expected. \<Ctrl-c\> to stop forground process.
81
6. Install L2CPBG as service/daemon via `sudo l2cpbg --service=install`. You should see a single "... 'install' succeed" message.
82
7. Now that L2CPBG got installed as a service/daemon you can use `sudo systemctrl start|stop|restart l2cpbg`. When booting next, L2CPBG should get started automatically and log output to systemd journal.
83
8. The full log can be read by `journalctl -u l2cpbg`.  
84
9. To watch the actual/live logging, use `journalctl -fu l2cpbg`.
85
86
Adapt your phone(s) to point their "LDAP Directory" lookup requests to l2cpbg with the settings you defined in /etc/l2cpbg.conf.
87
88
Uninstalling the service/daemon is simply done by `sudo l2cpbg --service=uninstall`
89
90
### Linux binary "tar.gz" packages ("SysV" Systems)
91
92
1. Extract binary i.e. to /usr/local/bin: `sudo tar xvf l2cpbg_0.9.2_linux-amd64.tgz -C /usr/local/bin/ l2cpbg`
93
2. Extract config file, i.e. to /etc: `sudo tar xvf l2cpbg_0.9.2_linux-amd64.tgz -C /etc/ l2cpbg.conf`
94
3. Adapt config section `[ldap]`, `[ldap.bind]`, `[dav]` as well as `[location]` to your need.
95
4. Do a first foreground start via `l2cpbg` and check terminal output for any issues. \<Ctrl-c\>, edit config and start `l2cpbg` till terminal output is okay.
96
5. If terminal output is okay and everything work as expected. \<Ctrl-c\> to stop forground process.
97
6. Install L2CPBG as service/daemon via `sudo l2cpbg --service=install`. You should see a single "... 'install' succeed" message.
98
7. Now that L2CPBG got installed as a service/daemon you can use `sudo service l2cpbg start|stop|restart`. When booting next time, L2CPBG should get started automatically and log output get send to /var/log/l2cpbg.err|log.
99
100
Adapt your phone(s) to point their "LDAP Directory" lookup requests to l2cpbg with the settings you defined in /etc/l2cpbg.conf.
101
102
Uninstalling the service/daemon is simply done by `sudo l2cpbg --service=uninstall`
103
104
### MacOS "pkg" package ("launchd" System)
105
106
The package (pkg) installer does the following:
107
108
- Extract the L2CPBG package to '/opt/l2cpbg'.
109
- Place a l2cpbg command symlink into '/usr/local/bin' (which is in PATH), so that you're able to call the gateway binary 'l2cpbg' independent of your working directory.
110
- A sample l2cpbg configuration file get places in `/usr/local/etc/l2cpbg.conf`.
111
112
After installation, initial startup would fail due to wrong/missing settings in config section `[dav]`!
113
114
1. Edit config by opening '/usr/local/etc/l2cpbg.conf' i.e. with TextEdit `open -a TextEdit /usr/local/etc/l2cpbg.conf`
115
2. Adapt at least `[ldap]`, `[ldap.bind]`, `[dav]` as well as your `[location]` sections to your need.  When done, don't forget to save!
116
3. Do a first foreground start via `l2cpbg` in Terminal, and check terminal output for any issues. \<Ctrl-c\> (abort l2cpbg), edit config and start `l2cpbg` again, till terminal output is okay.
117
4. If terminal output is okay and everything work as expected. \<Ctrl-c\> (abort l2cpbg) to stop forground process.
118
5. Install L2CPBG as service/daemon via `sudo l2cpbg --service=install`. You should see a single "... 'install' succeed" message.
119
6. Now that L2CPBG got installed as a service/daemon you can use `sudo l2cpbg --service=start|stop|restart`. When booting next time, L2CPBG should get started automatically and log output is send to /usr/local/var/log/l2cpbg.log.
120
121
Adapt your phone(s) to point their "LDAP Directory" lookup requests to l2cpbg with the settings you defined in /usr/local/etc/l2cpbg.conf.
122
123
Uninstalling the service/daemon is simply done by `sudo l2cpbg --service=uninstall`
124
125
Uninstalling the whole package is done by `sudo /opt/l2cpbg/uninstall.sh`
126
127
### Windows binary "zip" packages
128
129
1. Extract content of zip package to your preferred location, i.e. `C:\Program Files\LDAP2CardDAV-Gateway`. Take attention that the 32-bit version should be installted (by convention) somewhere under `C:\Program Files (x86)`!
130
2. Run "notepad" as Administrator, open `C:\Program Files\LDAP2CardDAV-Gateway\l2cpbg.conf` within Notepad, and adapt config section `[ldap]`, `[ldap.bind]`, `[dav]` as well as `[location]` to your need. When done, don't forget to save!
131
3. Now it's time to try a first start of the Gateway. Run a "Command" shell as Administrator and change to the installation directory, i.e. `cd C:\Program Files\LDAP2CardDAV-Gateway`, start it in foreground by `l2cpbg.exe` and check terminal output for any issues. \<Ctrl-c\>, edit config and start `l2cpbg.exe` till terminal output is okay.
132
4. If terminal output is okay and everything work as expected. \<Ctrl-c\> to stop forground process.
133
5. Install L2CPBG as service/daemon via `l2cpbg.exe --service=install`. You should see a single "... 'install' succeed" message.
134
7. Now that L2CPBG got installed as a service you can use `l2cpbg.exe --service=start|stop|restart`. After 'start'ed as service, log entries can be viewed by Windows Event Viewer (eventvwr). When booting next time, L2CPBG should get started automatically.
135
136
Uninstalling the service/daemon is simply done by `l2cpbg.exe --service=uninstall`
137
138
## Configfile syntax
139
140
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!
141
142
Following a quick minimal sample:
143
```
144
# Comments get started with a hash character
145
146
#
147
# The Gateway will act as LDAP Server, listening
148
# for requests from your phone(s).
149
#
150
[ldap]
151
  host      = "0.0.0.0"
152
  #port     = 1389
153
  base      = "dc=example, dc=com"
154
155
[ldap.bind]
156
  dn   = "cn=pbx"
157
  pass = "your-password"
158
159
#
160
# Your CardDAV server where this Gateway get the contacts from
161
#
162
[dav]
163
  server       = "https://cloudserver.example.com/remote.php/dav"
164
  user         = "cloud-login-name"
165
  pass         = "cloud-login-password"
166
167
[location]
168
  int           = 1     # Your international code. 1 = US, 49 = Germany, ...
169
  area          = 807   # Your local area code (without a leading 0)
170
  maxarealength = 7
171
  country       = "EN"
172
```
173
174
### Config file description (by section)
175
176
#### \[ldap\] = LDAP Server settings
177
178
`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.
179
180
`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.
181
182
`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'.
183
184
#### \[ldap.bind\] = LDAP bind/auth settings
185
186
`dn` : Distinguish name. Name, how the phone has to log into/authorize
187
to the gateway.
188
189
`pass` : Related 'dn' password, a phone has to use when logging in/authorize to the gateway.
190
191
#### \[dav\] = WebDav/CardDav server settings
192
193
`server` : Your WebDAV/CardDAV server address/URL. Please see 'Limitations'!
194
195
`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.
196
197
`pass` : Related user password.
198
199
`addressbooks` : Optional regular expression string of matchable addressbook(s)
200
used for phone book lookups. If unsure, enter something. l2cpbg will log
201
all found address books of the logged in CardDav user during startup and
202
log them as 'Non-matching' or 'Matching' address book(s).
203
204
`syncinterval` : Interval of CardDav sync checks. Given as string with suffix 'm' for minutes, or 'h' as hours. Has to be greater than "2m".
205
206
`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.
207
208
`insecurecert` controls whether a client verifies the server's certificate
209
chain and host name. If insecurecert is true, crypto/tls accepts any
210
certificate presented by the server and any host name in that certificate.
211
In this mode, TLS is susceptible to machine-in-the-middle attacks unless
212
custom verification is used. This should be used only for testing or in
213
trusted environments. Defaults to *false*. This option was added in L2CPBG version 0.9.1.
214
215
#### \[dav.map\] = CardDav mapping
216
217
`tel` : CardDAV attribute which contain phone numbers. Normally (and
218
by default) 'TEL'. Don't change this, except your really know what you're doing.
219
220
#### \[location\] = Local area settings
221
222
`int` : International area code (1 = North America, ..., 44 = United
223
Kingdom, 49 = Germany, ...) of your location.
224
225
~~`intPrefix` : Dial prefix for international calls. Mostly "00". Defaults to "00".
226
ATTENTION: Has to be entered as string like "00".~~
227
228
`area` : Local area code without leading 0 (20 = London (UK), 40 =
229
Hamburg (DE), ...).
230
231
`areaPrefix` : Dial prefix for national calls. Mostly "0". Defaults to "0".
232
ATTENTION: Has to be entered as string like "0". 
233
234
`maxarealength` : Longest possible length of a telephone number within
235
your local area. If a CardDAV or incoming number is shorter or equal, it's
236
identified as a number within your local area.
237
238
`country` : Two-letter [ISO 3166-1 alpha-2](https://wikipedia.org/wiki/ISO_3166-1_alpha-2) country code (i.e. US, GB, DE, ...).
239
240
`maxintlength` : Maximum length of internal phone numbers. These numbers
241
don't get harmonized or E.164 converted.
242
243
`prettifyNums` : By default phone numbers loaded from CardDAV get prettified in two ways:
244
At first, if a CardDAV number is stored in international format, but you live in the same country, the international part get removed.
245
At second, the number get formatted in (spaced or braced) number groups as it's common in your country.
246
You can disable this prettifying by setting the value to false.
247
248
`extdialprefix` : Optional external dial prefix for getting an external line. Get prefixed before the phone number if outgoing number length \> `maxintlength`
249
250
#### [log] = Logging
251
252
`level` : Log level. Might be one of "trace", "debug", "info", "warn", "error" or "fatal". Defaults to "info".
253
254
The log levels are organized as follows:
255
256
`trace` : This is the most verbose log level. It logs simply everything.
257
Never use it in production environment as it might produce an awful amount of log entries!
258
When started as Windows-Service, 'trace' messages doesn't get send to windows event console.
259
260
`debug` : Logs a lot internal stuff, probably interesting when searching
261
a solution for an issue. Should not be used in production environment as
262
it produce also a lot log entries!
263
When started as Windows-Service, 'debug' messages doesn't get send to windows event console.
264
265
`info` : This is the most usual log level. Logs only stuff which is relevant.
266
267
`warn` : Logs stuff which doesn't behave as expected. Not critical (generic functionality should be okay) but should be noticed/checked.
268
269
`error` : Something essential/critical happened. Functionality is limited or aborted at all.
270
271
`fatal` : Game over.
272
273
#### [db] = Internal database
274
275
`directory` : An own directory where to store the internal database. Defaults to
276
'os.TempDir()/l2cpbg.db' which is not very useful on Linux based systems as it normally get cleaned after each reboot.
277
278
Choose yourself where to store the database.
279
If you've a small CardDAV server with <= 200 contacts, let the DB in the default location.
280
An initial sync of 200 contacts (after a reboot) will be quickly done.
281
Not much storage space is needed. An CardDAV server with approx. 4 thousand contacts, take about 10 MByte storage.
282
283
ATTENTION: If you use one of the .deb packages, the binary get started as user=l2cpbg.
284
Thus, the given directory, manually need to made owned by l2cpbg via
285
`chown -R l2cpbg:l2cpbg /your/db/directory`! Otherwise the DB process will fail on missing read/write permissions!
286
287
#### [ldap.map...] = LDAP/CardDav mapping
288
289
Every LDAP attribute which is used within a phone(s) filter or response, need to have a corresponding CardDav mapping which get done as follows:
290
291
First you need to define a separate block for the LDAP attribute in the following syntax: `[ldap.map.<ldap attribute name (case sensitive)>]`
292
Within such a LDAP mapping block you have to define:
293
294
`dav` : Corresponding CardDav field/attribute name.
295
296
and optional define the following settings:
297
298
`itypes` : Regular expression (RE2 syntax) of including relevant CardDav types or *Apple addressbook label* (Apple Adressbook extension: X-ABLabel).
299
300
`etypes` : Regular expression (RE2 syntax) of **excluding** relevant CardDav types or *Apple addressbook label* (Apple Adressbook extension: X-ABLabel).
301
302
`index` : Zero based index in the case of a multi-value CardDav field.
303
304
For an overview of the predefined/default LDAP/CardDav mappings, take a
305
look into 'l2cpbg.sample.conf' file.
306
307
## Phone configuration
308
309
### Gigaset
310
311
Here's a configuration sample of a Gigaset N510 IP PRO:
312
![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")
313
Take attention that 'Server Address' point to the machine where this gateway lives (as well as 'Serverport')
314
315
'BaseDN', 'Common User Name' and 'Common Password' get filled with the same values as defined in your L2CPG config file.
316
317
### Yealink
318
319
Another configuration sample of a Yealink SIP-T52S:
320
![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")
321
Take attention that 'Server Address' point to the machine where this gateway lives (as well as 'Port').
322
323
'Base', 'User Name' and 'Password' get filled with the same values as defined in your L2CPG config file.
324
325
### Snom
326
327
The LDAP configuration of Snom phones look similar to the ones of
328
Gigaset or Yealink.
329
But a user reported that entering `(|(cn=*%*)(sn=*%*)(givenName=*%*)(company=*%*))` within 'LDAP name filter' did the trick for working name searches.
330
331
## Compatibility
332
333
L2CPBG is tested with:
334
335
-   CardDAV Server:
336
    -   [Baïkal](https://sabre.io/baikal/) version 0.7.x
337
    -   [Daylite](https://www.marketcircle.com/)
338
    -   [Nextcloud](https://nextcloud.com/) version 13, 15, 16, 18 & 20
339
    -   [Synology Contacts](https://www.synology.com/dsm/packages/Contacts)
340
-   Desktop & Mobile Phones:
341
    -   [Gigaset](https://www.gigasetpro.com/) N510 IP PRO, 670 IP Pro
342
    -   [Grandstream](http://www.grandstream.com/) GXP2170
343
    -   [Snom](https://www.snom.com/) 300, D315, D335
344
    -   [Yealink](https://www.yealink.com/) SIP-T52S, SIP-T54S, SIP-T54W
345
    -   [Fanvil](https://fanvil.com/) X3U
346
-   Gateway Host OS:
347
    -   [Debian](https://www.debian.org/) Stretch 9.x, Buster 10.x (running at amd64 as well as ARMv7)
348
    -   [Gentoo](https://www.gentoo.org) amd64
349
    -   [macOS](https://www.apple.com/macos/) ™ Sierra 10.12.6
350
    -   [Ubuntu](https://ubuntu.com/) 20.04 (Focal Fossa)
351
    -   [Windows](https://www.microsoft.com/windows) Server 2016, 10
352
353
## Limitations and Known Issues
354
355
-   The internal LDAP Server doesn't support LDAPS (encrypted LDAP
356
    communication) at the moment. Therefore 
357
    **it should not be used in an untrusted network!**
358
    If you're interested to run it in an untrusted network,
359
    please drop me a short note.
360
361
## Support & getting help
362
363
For getting help or discussing l2cpbg, please browse the [L2CPBG Forum](https://projects.shbe.net/projects/l2cpbg/boards) or check/open the [Tickets](https://projects.shbe.net/projects/l2cpbg/issues) area.
Go to top