]> git.sur5r.net Git - openldap/blob - doc/guide/admin/backends.sdf
Update copyright for next release
[openldap] / doc / guide / admin / backends.sdf
1 # $OpenLDAP$
2 # Copyright 2007-2009 The OpenLDAP Foundation, All Rights Reserved.
3 # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
4
5 H1: Backends
6
7
8 H2: Berkeley DB Backends
9
10
11 H3: Overview
12
13 The {{bdb}} backend to {{slapd}}(8) is the recommended primary backend for a 
14 normal {{slapd}} database.  It uses the Oracle Berkeley DB ({{TERM:BDB}}) 
15 package to store data. It makes extensive use of indexing and caching 
16 (see the {{SECT:Tuning}} section) to speed data access.
17
18 {{hdb}} is a variant of the {{bdb}} backend that uses a hierarchical database 
19 layout which supports subtree renames. It is otherwise identical to the {{bdb}}
20  behavior, and all the same configuration options apply.
21
22 Note: An {{hdb}} database needs a large {{idlcachesize}} for good search performance, 
23 typically three times the {{cachesize}} (entry cache size) or larger.
24
25 H3: back-bdb/back-hdb Configuration
26
27 MORE LATER
28
29 H3: Further Information
30
31 {{slapd-bdb}}(5)
32
33 H2: LDAP
34
35
36 H3: Overview
37
38 The LDAP backend to {{slapd}}(8) is not an actual database; instead it acts 
39 as a proxy to forward incoming requests to another LDAP server. While 
40 processing requests it will also chase referrals, so that referrals are fully
41 processed instead of being returned to the {{slapd}} client.
42
43 Sessions that explicitly {{Bind}} to the {{back-ldap}} database always create 
44 their own private connection to the remote LDAP server. Anonymous sessions 
45 will share a single anonymous connection to the remote server. For sessions 
46 bound through other mechanisms, all sessions with the same DN will share the 
47 same connection. This connection pooling strategy can enhance the proxy's 
48 efficiency by reducing the overhead of repeatedly making/breaking multiple 
49 connections.
50
51 The ldap database can also act as an information service, i.e. the identity 
52 of locally authenticated clients is asserted to the remote server, possibly 
53 in some modified form. For this purpose, the proxy binds to the remote server 
54 with some administrative identity, and, if required, authorizes the asserted 
55 identity. 
56
57 It is heavily used by a lot of other {{SECT: Backends}} and {{SECT: Overlays}}.
58
59 H3: back-ldap Configuration
60
61 As previously mentioned, {{slapd-ldap(5)}} is used behind the scenes by many 
62 other {{SECT: Backends}} and {{SECT: Overlays}}. Some of them merely provide a 
63 few configuration directive themselves, but have available to the administrator
64 the whole of the {{slapd-ldap(5)}} options. 
65
66 For example, the {{SECT: Translucent Proxy}}, which retrieves entries from a 
67 remote LDAP server that can be partially overridden by the defined database, has
68 only four specific {{translucent-}} directives, but can be configured using any 
69 of the normal {{slapd-ldap(5)}} options. See {[slapo-translucent(5)}} for details.
70
71 Other {{SECT: Overlays}} allow you to tag directives in front of a normal 
72 {{slapd-ldap(5)}} directive. For example, the {{slapo-chain(5)}} overlay does 
73 this:
74
75 {{"There are very few chain overlay specific directives; however, directives 
76 related to the instances of the ldap backend that may be implicitly instantiated 
77 by the overlay may assume a special meaning when used in conjunction with this 
78 overlay.  They are described in slapd-ldap(5), and they also need to be prefixed 
79 by chain-."}}
80
81 You may have also seen the {{slapd-ldap(5)}} backend used and described in the
82 {{SECT: Push Based}} {{SECT: Replication}} section of the guide.
83
84 It should therefore be obvious that the {{slapd-ldap(5)}} backend is extremely
85 flexible and heavily used throughout the OpenLDAP Suite.
86
87 The following is a very simple example, but already the power of the {{slapd-ldap(5)}}
88 backend is seen by use of a {{uri list}}:
89
90 >       database        ldap
91 >       suffix          "dc=suretecsystems,dc=com"
92 >       rootdn          "cn=slapd-ldap"
93 >       uri             ldap://localhost/ ldap://remotehost ldap://remotehost2
94
95 The URI list is space or comma-separated. Whenever the server that responds 
96 is not the first one in the list, the list is rearranged and the responsive 
97 server is moved to the head, so that it will be first contacted the next time 
98 a connection needs be created.
99
100 This feature can be used to provide a form of load balancing when using 
101 {{SECT: MirrorMode replication}}.
102
103 H3: Further Information
104
105 {{slapd-ldap}}(5)
106
107 H2: LDIF
108
109
110 H3: Overview
111
112 The LDIF backend to {{slapd}}(8) is a basic storage backend that stores 
113 entries in text files in LDIF format, and exploits the filesystem to create 
114 the tree structure of the database. It is intended as a cheap, low performance 
115 easy to use backend.
116
117 When using the {{cn=config}} dynamic configuration database with persistent
118 storage, the configuration data is stored using this backend. See {{slapd-config}}(5)
119 for more information
120
121 H3: back-ldif Configuration
122
123 Like many other backends, the LDIF backend can be instantiated with very few
124 configuration lines:
125
126 >       include ./schema/core.schema
127 >       
128 >       database  ldif
129 >       directory "./ldif"
130 >       suffix    "dc=suretecsystems,dc=com"
131 >       rootdn    "cn=LDIF,dc=suretecsystems,dc=com"
132 >       rootpw    LDIF
133
134 You'll notice that when compared to examples below, there is no:
135
136 >   moduleload  back_ldif.la
137
138 directive. This is because {{back_ldif}} is always built in by default as it is
139 used by {{slapd-config(5)}}, which again is built in by default.
140
141 If we add the {{dcObject}} for {{dc=suretecsystems,dc=com}}, you can see how this
142 is added behind the scenes on the file system:
143
144 >   dn: dc=suretecsystems,dc=com
145 >   objectClass: dcObject
146 >   objectClass: organization
147 >   dc: suretecsystems
148 >   o: Suretec Systems Ltd
149
150 Now we add it to the directory:
151
152 >   ldapadd -x -H ldap://localhost:9011 -f suretec.ldif -D "cn=LDIF,dc=suretecsystems,dc=com" -w LDIF
153 >   adding new entry "dc=suretecsystems,dc=com"
154
155 And inside {{F: ./ldif}} we have:
156
157 >   ls ./ldif
158 >   dc=suretecsystems,dc=com.ldif
159
160 which again contains:
161
162 >   cat ldif/dc\=suretecsystems\,dc\=com.ldif 
163 >   
164 >   dn: dc=suretecsystems
165 >   objectClass: dcObject
166 >   objectClass: organization
167 >   dc: suretecsystems
168 >   o: Suretec Systems Ltd.
169 >   structuralObjectClass: organization
170 >   entryUUID: 2134b714-e3a1-102c-9a15-f96ee263886d
171 >   creatorsName: cn=LDIF,dc=suretecsystems,dc=com
172 >   createTimestamp: 20080711142643Z
173 >   entryCSN: 20080711142643.661124Z#000000#000#000000
174 >   modifiersName: cn=LDIF,dc=suretecsystems,dc=com
175 >   modifyTimestamp: 20080711142643Z
176
177 This is the complete format you would get when exporting your directory using
178 {{F: slapcat}} etc.
179
180 H3: Further Information
181
182 {{slapd-ldif}}(5)
183
184 H2: Metadirectory
185
186
187 H3: Overview
188
189 The meta backend to {{slapd}}(8) performs basic LDAP proxying with respect 
190 to a set of remote LDAP servers, called "targets". The information contained 
191 in these servers can be presented as belonging to a single Directory Information 
192 Tree ({{TERM:DIT}}).
193
194 A basic knowledge of the functionality of the {{slapd-ldap}}(5) backend is 
195 recommended. This backend has been designed as an enhancement of the ldap 
196 backend. The two backends share many features (actually they also share portions
197  of code). While the ldap backend is intended to proxy operations directed 
198  to a single server, the meta backend is mainly intended for proxying of 
199  multiple servers and possibly naming context  masquerading.
200
201 These features, although useful in many scenarios, may result in excessive 
202 overhead for some applications, so its use should be carefully considered.
203
204
205 H3: back-meta Configuration
206
207 LATER
208
209 H3: Further Information
210
211 {{slapd-meta}}(5)
212
213 H2: Monitor
214
215
216 H3: Overview
217
218 The monitor backend to {{slapd}}(8) is not an actual database; if enabled, 
219 it is automatically generated and dynamically maintained by slapd with 
220 information about the running status of the daemon.
221
222 To inspect all monitor information, issue a subtree search with base {{cn=Monitor}}, 
223 requesting that attributes "+" and "*" are returned. The monitor backend produces 
224 mostly operational attributes, and LDAP only returns operational attributes 
225 that are explicitly requested.  Requesting attribute "+" is an extension which 
226 requests all operational attributes.
227
228 See the {{SECT:Monitoring}} section.
229
230 H3: back-monitor Configuration
231
232 The monitor database can be instantiated only once, i.e. only one occurrence 
233 of "database monitor" can occur in the {{slapd.conf(5)}} file.  Also the suffix 
234 is automatically set to {{"cn=Monitor"}}.
235
236 You can however set a {{rootdn}} and {{rootpw}}. The following is all that is
237 needed to instantiate a monitor backend:
238
239 >       include ./schema/core.schema
240 >
241 >       modulepath  /usr/local/libexec/openldap
242 >       moduleload  back_monitor.la
243 >       
244 >       database monitor
245 >       rootdn "cn=monitoring,cn=Monitor"
246 >       rootpw monitoring
247
248 You can also apply Access Control to this database like any other database, for 
249 example:
250
251 >       access to dn.subtree="cn=Monitor"
252 >            by dn.exact="uid=Admin,dc=my,dc=org" write
253 >            by users read
254 >            by * none
255
256 Note: The {{F: core.schema}} must be loaded for the monitor database to work. 
257
258 A small example of the data returned via {{ldapsearch}} would be:
259
260 >       ldapsearch -x -H ldap://localhost:9011 -b 'cn=Monitor'
261 >       # extended LDIF
262 >       #
263 >       # LDAPv3
264 >       # base <cn=Monitor> with scope subtree
265 >       # filter: (objectclass=*)
266 >       # requesting: ALL
267 >       #
268 >       
269 >       # Monitor
270 >       dn: cn=Monitor
271 >       objectClass: monitorServer
272 >       cn: Monitor
273 >       description: This subtree contains monitoring/managing objects.
274 >       description: This object contains information about this server.
275 >       description: Most of the information is held in operational attributes, which 
276 >        must be explicitly requested.
277 >       
278 >       # Backends, Monitor
279 >       dn: cn=Backends,cn=Monitor
280 >       objectClass: monitorContainer
281 >       cn: Backends
282 >       description: This subsystem contains information about available backends.
283
284 Please see the {{SECT: Monitoring}} section for complete examples of information
285 available via this backend.
286
287 H3: Further Information
288
289 {{slapd-monitor}}(5)
290
291 H2: Null
292
293
294 H3: Overview
295
296 The Null backend to {{slapd}}(8) is surely the most useful part of slapd:
297
298 * Searches return success but no entries.
299 * Compares return compareFalse.
300 * Updates return success (unless readonly is on) but do nothing.
301 * Binds other than as the rootdn fail unless the database option "bind on" is given.
302 * The slapadd(8) and slapcat(8) tools are equally exciting.
303
304 Inspired by the {{F:/dev/null}} device.
305
306 H3: back-null Configuration
307
308 This has to be one of the shortest configurations you'll ever do. In order to 
309 test this, your {{F: slapd.conf}} file would look like:
310
311 >       modulepath  /usr/local/libexec/openldap
312 >       moduleload  back_null.la
313
314 >       database null
315 >       suffix "cn=Nothing"
316 >       bind on
317
318 The first two directives are only applicable if you've enabled module support and
319 haven't "built-in" {{slapd-null(5)}} support (why would you?).
320
321 {{bind on}} means:
322
323 {{"Allow binds as any DN in this backend's suffix, with any password. The default is "off"."}}
324
325 To test this backend with {{ldapsearch}}:
326
327 >       ldapsearch -x -H ldap://localhost:9011 -D "uid=none,cn=Nothing" -w testing -b 'cn=Nothing'
328 >       # extended LDIF
329 >       #
330 >       # LDAPv3
331 >       # base <cn=Nothing> with scope subtree
332 >       # filter: (objectclass=*)
333 >       # requesting: ALL
334 >       #
335 >       
336 >       # search result
337 >       search: 2
338 >       result: 0 Success
339 >       
340 >       # numResponses: 1
341
342
343 H3: Further Information
344
345 {{slapd-null}}(5)
346
347 H2: Passwd
348
349
350 H3: Overview
351
352 The PASSWD backend to {{slapd}}(8) serves up the user account information 
353 listed in the system {{passwd}}(5) file (defaulting to {{F: /etc/passwd}}).
354
355 This backend is provided for demonstration purposes only. The DN of each entry 
356 is "uid=<username>,<suffix>".
357
358 H3: back-passwd Configuration
359
360 The configuration using {{F: slapd.conf}} a slightly longer, but not much. For 
361 example:
362
363 >       include ./schema/core.schema
364 >       
365 >       modulepath  /usr/local/libexec/openldap
366 >       moduleload  back_passwd.la
367 >       
368 >       database passwd
369 >       suffix "cn=passwd"
370
371 Again, testing this with {{ldapsearch}} would result in something like:
372
373 >       ldapsearch -x -H ldap://localhost:9011 -b 'cn=passwd'
374 >       # extended LDIF
375 >       #
376 >       # LDAPv3
377 >       # base <cn=passwd> with scope subtree
378 >       # filter: (objectclass=*)
379 >       # requesting: ALL
380 >       #
381 >       
382 >       # passwd
383 >       dn: cn=passwd
384 >       cn: passwd
385 >       objectClass: organizationalUnit
386 >       
387 >       # root, passwd
388 >       dn: uid=root,cn=passwd
389 >       objectClass: person
390 >       objectClass: uidObject
391 >       uid: root
392 >       cn: root
393 >       sn: root
394 >       description: root
395
396
397 H3: Further Information
398
399 {{slapd-passwd}}(5)
400
401 H2: Perl/Shell
402
403 H3: Overview
404
405 The Perl backend to {{slapd}}(8) works by embedding a {{perl}}(1) interpreter 
406 into {{slapd}}(8). Any perl database section of the configuration file 
407 {{slapd.conf}}(5) must then specify what Perl module to use. Slapd then creates 
408 a new Perl object that handles all the requests for that particular instance of the backend.
409
410 The Shell backend to {{slapd}}(8) executes external programs to implement 
411 operations, and is designed to make it easy to tie an existing database to the 
412 slapd front-end. This backend is is primarily intended to be used in prototypes.
413
414 H3: back-perl/back-shell Configuration
415
416 LATER
417
418 H3: Further Information
419
420 {{slapd-shell}}(5) and {{slapd-perl}}(5)
421
422 H2: Relay
423
424
425 H3: Overview
426
427 The primary purpose of this {{slapd}}(8) backend is to map a naming context 
428 defined in a database running in the same {{slapd}}(8) instance into a 
429 virtual naming context, with attributeType and objectClass manipulation, if
430 required. It requires the rwm overlay.
431
432 This backend and the above mentioned overlay are experimental.
433
434 H3: back-relay Configuration
435
436 LATER
437
438 H3: Further Information
439
440 {{slapd-relay}}(5)
441
442 H2: SQL
443
444
445 H3: Overview
446
447 The primary purpose of this {{slapd}}(8) backend is to PRESENT information 
448 stored in some RDBMS as an LDAP subtree without any programming (some SQL and 
449 maybe stored procedures can't be considered programming, anyway ;).
450
451 That is, for example, when you (some ISP) have account information you use in 
452 an RDBMS, and want to use modern solutions that expect such information in LDAP 
453 (to authenticate users, make email lookups etc.). Or you want to synchronize or 
454 distribute information between different sites/applications that use RDBMSes 
455 and/or LDAP. Or whatever else...
456
457 It is {{B:NOT}} designed as a general-purpose backend that uses RDBMS instead of 
458 BerkeleyDB (as the standard BDB backend does), though it can be used as such with 
459 several limitations. Please see {{SECT: LDAP vs RDBMS}} for discussion.
460
461 The idea is to use some meta-information to translate LDAP queries to SQL queries, 
462 leaving relational schema untouched, so that old applications can continue using 
463 it without any modifications. This allows SQL and LDAP applications to interoperate 
464 without replication, and exchange data as needed.
465
466 The SQL backend is designed to be tunable to virtually any relational schema without 
467 having to change source (through that meta-information mentioned). Also, it uses 
468 ODBC to connect to RDBMSes, and is highly configurable for SQL dialects RDBMSes 
469 may use, so it may be used for integration and distribution of data on different 
470 RDBMSes, OSes, hosts etc., in other words, in highly heterogeneous environments.
471
472 This backend is experimental.
473
474 H3: back-sql Configuration
475
476 This backend has to be one of the most abused and complex backends there is. 
477 Therefore, we will go through a simple, small example that comes with the 
478 OpenLDAP source and can be found in {{F: servers/slapd/back-sql/rdbms_depend/README}}
479
480 For this example we will be using PostgreSQL.
481
482 First, we add to {{F: /etc/odbc.ini}} a block of the form:
483
484 >       [example]                        <===
485 >       Description         = Example for OpenLDAP's back-sql
486 >       Driver              = PostgreSQL
487 >       Trace               = No
488 >       Database            = example    <===
489 >       Servername          = localhost
490 >       UserName            = manager    <===
491 >       Password            = secret     <===
492 >       Port                = 5432
493 >       ;Protocol            = 6.4
494 >       ReadOnly            = No
495 >       RowVersioning       = No
496 >       ShowSystemTables    = No
497 >       ShowOidColumn       = No
498 >       FakeOidIndex        = No
499 >       ConnSettings        =
500
501 The relevant information for our test setup is highlighted with '<===' on the 
502 right above.
503
504 Next, we add to {{F: /etc/odbcinst.ini}} a block of the form:
505
506 >       [PostgreSQL]
507 >       Description     = ODBC for PostgreSQL
508 >       Driver          = /usr/lib/libodbcpsql.so
509 >       Setup           = /usr/lib/libodbcpsqlS.so
510 >       FileUsage       = 1
511
512
513 We will presume you know how to create a database and user in PostgreSQL and 
514 how to set a password. Also, we'll presume you can populate the 'example'
515 database you've just created with the following files, as found in {{F: servers/slapd/back-sql/rdbms_depend/pgsql }} 
516
517 >       backsql_create.sql, testdb_create.sql, testdb_data.sql, testdb_metadata.sql
518
519 Lastly, run the test:
520
521 >       [root@localhost]# cd $SOURCES/tests
522 >       [root@localhost]# SLAPD_USE_SQL=pgsql ./run sql-test000
523
524 Briefly, you should see something like (cut short for space):
525
526 >       Cleaning up test run directory leftover from previous run.
527 >       Running ./scripts/sql-test000-read...
528 >       running defines.sh
529 >       Starting slapd on TCP/IP port 9011...
530 >       Testing SQL backend read operations...
531 >       Waiting 5 seconds for slapd to start...
532 >       Testing correct bind... dn:cn=Mitya Kovalev,dc=example,dc=com
533 >       Testing incorrect bind (should fail)... ldap_bind: Invalid credentials (49)
534 >       
535 >       ......
536 >       
537 >       Filtering original ldif...
538 >       Comparing filter output...
539 >       >>>>> Test succeeded
540
541 The test is basically readonly; this can be performed by all RDBMSes 
542 (listed above). 
543
544 There is another test, sql-test900-write, which is currently enabled
545 only for PostgreSQL and IBM db2.
546
547 Using {{F: sql-test000}}, files in {{F: servers/slapd/back-sql/rdbms_depend/pgsql/}}
548 and the man page, you should be set.
549
550 Note: This backend is experimental.
551
552 H3: Further Information
553
554 {{slapd-sql}}(5) and {{F: servers/slapd/back-sql/rdbms_depend/README}}