Readme 081 » History » Version 1
Jörg Ebeling, 12/05/2020 04:44 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 comfortable LDAP directory look-up like: |
||
8 | |||
9 | - Directory search by alphabet letters |
||
10 | - Reverse lookup for in- or out-bound calls |
||
11 | - Reverse lookup by entering parts or the phone number |
||
12 | |||
13 | Unfortunately, most of the 'smaller' companies (i guess companies beyond 100 employee) don't have an 'enterprise' LDAP directory, much less than private persons. |
||
14 | |||
15 | Most of such companies do have something like a cloud address book, often based on WebDAV / CardDAV (i.e. Nextcloud, Ownlcoud, Baïkal, Daylite, ...). |
||
16 | |||
17 | This is, where this Gateway might make your live easier. |
||
18 | |||
19 | If this program get started on some kind of hardware (Windows, macOS or Linux), it will do the following: |
||
20 | |||
21 | 1. Query your CardDAV Server for relevant entries, and cache them to a small local database |
||
22 | 2. Wait and answer for LDAP requests from your voice phone(s) |
||
23 | |||
24 | ## Features |
||
25 | |||
26 | - Query your CardDAV address book(s) by entering the alphabetic letters (or parts of the telephone number) in your (LDAP capable) phone (and dial one of the matching numbers). |
||
27 | - Reverse lookup inbound calls and display matching contact informations on the phone. |
||
28 | - Work with local formatted (non- E.164) CardDAV entered phone numbers like: '040-123456' or '001 807 1234567' as well as '+49 (0)40 1234567-8'. |
||
29 | - Supports internal (extension) phone numbers. |
||
30 | - Support dial prefix for external line. |
||
31 | |||
32 | ## Usage |
||
33 | |||
34 | You need some kind of 24/7 machine where this gateway live. Windows, Linux, macOS, (ARMx might come later if someone is interested in). |
||
35 | |||
36 | 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'. |
||
37 | |||
38 | 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. |
||
39 | |||
40 | It will look for a configuration file in the following places (in the given order): |
||
41 | |||
42 | 1. ./.l2cpbgrc (or in it's parents) |
||
43 | 2. $HOME/.l2cpbgrc |
||
44 | 3. $HOME/.config/l2cpbg |
||
45 | 4. /etc/l2cpbgrc |
||
46 | 5. and some more uncommon places |
||
47 | |||
48 | It will write to a small local database (defaults to './l2cpbg-db.json'). |
||
49 | |||
50 | ## Hotkeys |
||
51 | |||
52 | There are some hotkeys available on the console. |
||
53 | |||
54 | | Hotkey | Description | |
||
55 | | ------ | ----------------------------------------------------------------------- | |
||
56 | | H or ? | Quick hotkey help list | |
||
57 | | L | License info | |
||
58 | | S | Sync with CardDAV server (instead of waiting for the next syncinterval) | |
||
59 | | U | Uptime info | |
||
60 | | V | Version info | |
||
61 | |||
62 | ## Configfile syntax |
||
63 | |||
64 | The config file syntax is 'ini' based. Following a quick minimal sample: |
||
65 | |||
66 | ``` |
||
67 | ; Comments get started with a semicolon |
||
68 | ; |
||
69 | ; The Gateway will act/listen as LDAP Server with the following settings |
||
70 | ; |
||
71 | [ldap] |
||
72 | host = 0.0.0.0 |
||
73 | ;port = 1389 |
||
74 | base = dc=example, dc=com |
||
75 | |||
76 | [ldap.bind] |
||
77 | dn = cn=pbx |
||
78 | pass = your-password |
||
79 | |||
80 | [dav] |
||
81 | server = https://cloudserver.example.com/remote.php/dav |
||
82 | user = cloud-login-name |
||
83 | pass = cloud-login-password |
||
84 | ;addressbooks = regular-expression-of-lookup-adressbook |
||
85 | syncinterval = 5 ; Minutes |
||
86 | |||
87 | [location] |
||
88 | int = 1 |
||
89 | area = 807 |
||
90 | maxarealength = 7 |
||
91 | language = en |
||
92 | ;maxintlength = 3 |
||
93 | ;extdialprefix = 0, ; External dial prefix if called number > maxintlength |
||
94 | |||
95 | [log] |
||
96 | conslevel = verbose ; Console log level. Might be one of silly, debug, verbose, info, warn or error |
||
97 | ;filename = ./l2cpbg.<notextile>%</notextile>DATE<notextile>%</notextile>.log ; Might contain a '<notextile>%</notextile>DATE<notextile>%</notextile>' placeholder |
||
98 | ;filelevel = info ; File log level. Might be one of silly, debug, verbose, info, warn or error |
||
99 | ``` |
||
100 | |||
101 | ### Config file description |
||
102 | |||
103 | #### \[ldap\] = LDAP Server settings |
||
104 | |||
105 | `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. |
||
106 | `port` : Port to listen for LDAP requests. Defaults to port 1389. You normally don't need to change this. |
||
107 | `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'. |
||
108 | |||
109 | #### \[ldap.bind\] = LDAP auth settings |
||
110 | |||
111 | `dn` : Distinguish name. Name, how the phone has to log into/authorize to the gateway. |
||
112 | `pass` : Related 'dn' password, a phone has to use when logging in/authorize to the gateway. |
||
113 | |||
114 | #### \[dav\] = WebDav/CardDav server settings |
||
115 | |||
116 | `server` : Your WebDAV/CardDAV server address/URL. Please see 'Limitations'! |
||
117 | `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. |
||
118 | `pass` : Related user password. |
||
119 | `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). |
||
120 | `syncinterval` : Interval of CardDav sync checks. Given in minutes, has to be greater than 2. |
||
121 | `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. |
||
122 | |||
123 | #### \[dav.map\] = CardDav mapping |
||
124 | |||
125 | `tel` : CardDAV attribute which contain the phone numbers. Normally (and by default) 'TEL'. |
||
126 | |||
127 | #### \[location\] = Local area settings |
||
128 | |||
129 | `int` : International area code (1 = North America, ..., 44 = United Kingdom, 49 = Germany, ...) of your location. |
||
130 | `area` : Local area code without leading 0 (20 = London (UK), 40 = Hamburg (DE), ...). |
||
131 | `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. |
||
132 | `country` : Two-letter [ISO 3166-1 alpha-2](https://wikipedia.org/wiki/ISO_3166-1\_alpha-2) country code (i.e. US, GB, DE, ...). |
||
133 | `maxintlength` : Maximum length of internal phone numbers. These numbers don't get harmonized or E.164 converted. |
||
134 | `extdialprefix` : External dial prefix for getting an external line. Get prefixed before the phone number if target number length \> `maxintlength` |
||
135 | |||
136 | #### \[log\] = Screen & file logging |
||
137 | |||
138 | `conslevel` : Console log level. Might be one of silly, debug, verbose, info, warn or error. Defaults to verbose. |
||
139 | `filelevel` : File log level. Might be one of silly, debug, verbose, info, warn or error. Defaults to info |
||
140 | |||
141 | The log levels are organized as follows: |
||
142 | |||
143 | `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! |
||
144 | `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! |
||
145 | `verbose` : Logs everything which might be interesting during use. Not only results, also when something get started, detailed results and such things. |
||
146 | `info` : This is the most usual log level. Logs only stuff which is relevant. |
||
147 | `warn` : Logs stuff which doesn't behave as expected. Not critical (generic functionality should be okay) but should be noticed/checked. |
||
148 | `error` : Something essential/critical happened. Functionality is limited or aborted at all. |
||
149 | |||
150 | `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. |
||
151 | `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. |
||
152 | `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. |
||
153 | `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. |
||
154 | `fileziparchive` : Boolean (true|false) to define whether or not to gzip archived log files. Defaults to true. |
||
155 | |||
156 | #### \[db\] = Internal database |
||
157 | |||
158 | `filename` : Filename where to store the internal database. Defaults to './l2cpbg-db.json'. |
||
159 | |||
160 | #### \[ldap.map...\] = LDAP/CardDav mapping |
||
161 | |||
162 | Every LDAP attribute which is used within a phone(s) filter or response, need to have a corresponding CardDav mapping. |
||
163 | This get done as follows: |
||
164 | First you need to define a separate block for the LDAP attribute in the following syntax: |
||
165 | |||
166 | ``` |
||
167 | [ldap.map.<ldap attribute name (case sensitive)>] |
||
168 | ``` |
||
169 | |||
170 | |||
171 | Within such a LDAP mapping block you have to define: |
||
172 | |||
173 | `dav` : Corresponding CardDav field/attribute name. |
||
174 | |||
175 | and may define the following optional settings: |
||
176 | |||
177 | `types` : Regular expression of relevant CardDav types or Apple addressbook label (Apple Adressbook extension: X-ABLabel). |
||
178 | |||
179 | `index` : Zero based index in the case of a multi-value CardDav field. |
||
180 | |||
181 | For an overview of the predefined/default LDAP/CardDav mappings, take a look into the 'config.sample' file. |
||
182 | |||
183 | ## Phone configuration |
||
184 | |||
185 | ### Gigaset |
||
186 | |||
187 | Here's a configuration sample of a Gigaset N510 IP PRO: |
||
188 | ![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") |
||
189 | Take attention that <span style="color: #d97a3a;">Server Address</span> point to the machine where this gateway lives, as well as <span style="color: #d97a3a;">Serverport</span>, <span style="color: #d97a3a;">BaseDN</span>, <span style="color: #d97a3a;">Common User Name</span> and <span style="color: #d97a3a;">Common Password</span> get filled with the same values as defined in your L2CPG config file. |
||
190 | |||
191 | ### Yealink |
||
192 | |||
193 | Another configuration sample of a Yealink SIP-T52S: |
||
194 | ![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") |
||
195 | Take attention that <span style="color: #d97a3a;">Server Address</span> point to the machine where this gateway lives, as well as <span style="color: #d97a3a;">Port</span>, <span style="color: #d97a3a;">Base</span>, <span style="color: #d97a3a;">User Name</span> and <span style="color: #d97a3a;">Password</span> get filled with the same values as defined in your L2CPG config file. |
||
196 | |||
197 | ### Snom |
||
198 | |||
199 | The LDAP configuration of Snom phones look similar to the ones of Gigaset or Yealink. |
||
200 | But a user reported that entering |
||
201 | |||
202 | ``` |
||
203 | (|(cn=*%*)(sn=*%*)(givenName=*%*)(company=*%*)) |
||
204 | ``` |
||
205 | |||
206 | as 'LDAP name filter' did the trick for working name searches. |
||
207 | |||
208 | ## Compatibility |
||
209 | |||
210 | This early version is currently only tested with: |
||
211 | |||
212 | - CardDAV Server: |
||
213 | - [Baïkal](https://sabre.io/baikal/) version 0.7.x |
||
214 | - [Daylite](https://www.marketcircle.com/) |
||
215 | - [Nextcloud](https://nextcloud.com/) version 13, 15, 16 & 18 |
||
216 | - Phone Extensions: |
||
217 | - [Gigaset](https://www.gigasetpro.com/) N510 IP PRO, 670 IP Pro |
||
218 | - [Grandstream](http://www.grandstream.com/) GXP2170 |
||
219 | - [Snom](https://www.snom.com/) 300, D315, D335 |
||
220 | - [Yealink](https://www.yealink.com/) SIP-T52S, SIP-T54S, SIP-T54W |
||
221 | - Gateway Host OS: |
||
222 | - [Debian](https://www.debian.org/) Stretch 9.x, Buster 10.x |
||
223 | - [macOS](https://www.apple.com/macos/) ™ Sierra 10.12.6 |
||
224 | - [Ubuntu](https://ubuntu.com/) 20.04 (Focal Fossa) |
||
225 | |||
226 | ## Limitations and Known Issues |
||
227 | |||
228 | There are already some known issues!!! Not sure which will get fixed, might depend on how much people are interested in. |
||
229 | |||
230 | - The internal LDAP Server doesn't support LDAPS (encrypted LDAP communication) at the moment. Therefore <span style="color: #f00;">it should not be used in an untrusted network!</span> |
||
231 | - 'Basic Authentication' over 'HTTPS' will work (for sure), but not with self signed certificates |
||
232 | |||
233 | ## To-Do |
||
234 | |||
235 | 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]]. |
||
236 | |||
237 | 1. Persistent DB storage |
||
238 | 2. Daemonize (run in background/as service) |
||
239 | |||
240 | ## Support & getting help |
||
241 | |||
242 | 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. |