]> git.sur5r.net Git - openldap/blob - doc/guide/admin/slapdconf2.sdf
FWIW, SIGBREAK on Windows should only be ignored when running as a Service.
[openldap] / doc / guide / admin / slapdconf2.sdf
1 # $OpenLDAP$
2 # Copyright 2005-2006 The OpenLDAP Foundation, All Rights Reserved.
3 # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
4
5 H1: Configuring slapd
6
7 Once the software has been built and installed, you are ready
8 to configure {{slapd}}(8) for use at your site. Unlike previous
9 OpenLDAP releases, the slapd(8) runtime configuration in 2.3 (and later)
10 is fully LDAP-enabled and can be managed using the standard LDAP
11 operations with data in {{TERM:LDIF}}. The LDAP configuration engine
12 allows all of slapd's configuration options to be changed on the fly,
13 generally without requiring a server restart for the changes
14 to take effect. The old style {{slapd.conf}}(5) file is still
15 supported, but must be converted to the new {{slapd-config}}(5) format
16 to allow runtime changes to be saved. While the old style
17 configuration uses a single file, normally installed as
18 {{F:/usr/local/etc/openldap/slapd.conf}}, the new style
19 uses a slapd backend database to store the configuration. The
20 configuration database normally resides in the
21 {{F:/usr/local/etc/openldap/slapd.d}} directory.
22
23 An alternate configuration directory (or file) can be specified via
24 a command-line option to {{slapd}}(8). This chapter describes the
25 general format of the configuration system, followed by a detailed
26 description of commonly used config settings.
27
28 Note: some of the backends and of the distributed overlays
29 do not support runtime configuration yet.  In those cases,
30 the old style {{slapd.conf}}(5) file must be used.
31
32 Note: the current version of {{slurpd}} has not been updated for
33 compatibility with this new configuration engine. If you must use
34 slurpd for replication at your site, you will have to maintain an
35 old-style {{slapd.conf}} file for slurpd to use.
36
37
38 H2: Configuration Layout
39
40 The slapd configuration is stored as a special LDAP directory with
41 a predefined schema and DIT. There are specific objectClasses used to
42 carry global configuration options, schema definitions, backend and
43 database definitions, and assorted other items. A sample config tree
44 is shown in Figure 5.1.
45
46 !import "config_dit.gif"; align="center"; title="Sample configuration tree"
47 FT[align="Center"] Figure 5.1: Sample configuration tree.
48
49 Other objects may be part of the configuration but were omitted from
50 the illustration for clarity.
51
52 The {{slapd-config}} configuration tree has a very specific structure. The
53 root of the tree is named {{EX:cn=config}} and contains global configuration
54 settings. Additional settings are contained in separate child entries:
55 * Include files
56 .. Usually these are just pathnames left over from a converted
57 {{EX:slapd.conf}} file.
58 .. Otherwise use of Include files is deprecated.
59 * Dynamically loaded modules
60 .. These may only be used if the {{EX:--enable-modules}} option was
61 used to configure the software.
62 * Schema definitions
63 .. The {{EX:cn=schema,cn=config}} entry contains the system schema (all
64 the schema that is hard-coded in slapd).
65 .. Child entries of {{EX:cn=schema,cn=config}} contain user schema as
66 loaded from config files or added at runtime.
67 * Backend-specific configuration 
68 * Database-specific configuration
69 .. Overlays are defined in children of the Database entry.
70 .. Databases and Overlays may also have other miscellaneous children.
71
72 The usual rules for LDIF files apply to the configuration information:
73 Comment lines beginning with a '{{EX:#}}' character
74 are ignored.  If a line begins with a single space, it is considered a
75 continuation of the previous line (even if the previous line is a
76 comment) and the single leading space is removed. Entries are separated by blank lines.
77
78 The general layout of the config LDIF is as follows:
79
80 >       # global configuration settings
81 >       dn: cn=config
82 >       objectClass: olcGlobal
83 >       cn: config
84 >       <global config settings>
85 >
86 >       # schema definitions
87 >       dn: cn=schema,cn=config
88 >       objectClass: olcSchemaConfig
89 >       cn: schema
90 >       <system schema>
91 >
92 >       dn: cn={X}core,cn=schema,cn=config
93 >       objectClass: olcSchemaConfig
94 >       cn: {X}core
95 >       <core schema>
96 >
97 >       # additional user-specified schema
98 >       ...
99 >
100 >       # backend definitions
101 >       dn: olcBackend=<typeA>,cn=config
102 >       objectClass: olcBackendConfig
103 >       olcBackend: <typeA>
104 >       <backend-specific settings>
105 >
106 >       # database definitions
107 >       dn: olcDatabase={X}<typeA>,cn=config
108 >       objectClass: olcDatabaseConfig
109 >       olcDatabase: {X}<typeA>
110 >       <database-specific settings>
111 >
112 >       # subsequent definitions and settings
113 >       ...
114
115 Some of the entries listed above have a numeric index {{EX:"{X}"}} in
116 their names. While most configuration settings have an inherent ordering
117 dependency (i.e., one setting must take effect before a subsequent one
118 may be set), LDAP databases are inherently unordered. The numeric index
119 is used to enforce a consistent ordering in the configuration database,
120 so that all ordering dependencies are preserved. In most cases the index
121 does not have to be provided; it will be automatically generated based
122 on the order in which entries are created.
123
124 Configuration directives are specified as values of individual
125 attributes.
126 Most of the attributes and objectClasses used in the slapd
127 configuration have a prefix of {{EX:"olc"}} (OpenLDAP Configuration)
128 in their names. Generally there is a one-to-one correspondence
129 between the attributes and the old-style {{EX:slapd.conf}} configuration
130 keywords, using the keyword as the attribute name, with the "olc"
131 prefix attached.
132
133 A configuration directive may take arguments.  If so, the arguments are
134 separated by white space.  If an argument contains white space,
135 the argument should be enclosed in double quotes {{EX:"like this"}}.
136 In the descriptions that follow, arguments that should be replaced
137 by actual text are shown in brackets {{EX:<>}}.
138
139 The distribution contains an example configuration file that will
140 be installed in the {{F: /usr/local/etc/openldap}} directory.
141 A number of files containing schema definitions (attribute types
142 and object classes) are also provided in the
143 {{F: /usr/local/etc/openldap/schema}} directory.
144
145
146 H2: Configuration Directives
147
148 This section details commonly used configuration directives.  For
149 a complete list, see the {{slapd-config}}(5) manual page.  This section
150 will treat the configuration directives in a top-down order, starting
151 with the global directives in the {{EX:cn=config}} entry. Each
152 directive will be described along with its default value (if any) and
153 an example of its use.
154
155
156 H3: cn=config
157
158 Directives contained in this entry generally apply to the server as a whole.
159 Most of them are system or connection oriented, not database related. This
160 entry must have the {{EX:olcGlobal}} objectClass.
161
162
163 H4: olcIdleTimeout: <integer>
164
165 Specify the number of seconds to wait before forcibly closing
166 an idle client connection.  A value of 0, the default,
167 disables this feature.
168
169
170 H4: olcLogLevel: <level>
171
172 This directive specifies the level at which debugging statements
173 and operation statistics should be syslogged (currently logged to
174 the {{syslogd}}(8) {{EX:LOG_LOCAL4}} facility). You must have
175 configured OpenLDAP {{EX:--enable-debug}} (the default) for this
176 to work (except for the two statistics levels, which are always
177 enabled). Log levels may be specified as integers or by keyword.
178 Multiple log levels may be used and the levels are additive.
179 To display what levels
180 correspond to what kind of debugging, invoke slapd with {{EX:-?}}
181 or consult the table below. The possible values for <level> are:
182
183 !block table; colaligns="RL"; align=Center; \
184         title="Table 5.1: Debugging Levels"
185 Level   Keyword Description
186 -1      Any     enable all debugging
187 0               no debugging
188 1       Trace   trace function calls
189 2       Packets debug packet handling
190 4       Args    heavy trace debugging
191 8       Conns   connection management
192 16      BER     print out packets sent and received
193 32      Filter  search filter processing
194 64      Config  configuration processing
195 128     ACL     access control list processing
196 256     Stats   stats log connections/operations/results
197 512     Stats2  stats log entries sent
198 1024    Shell   print communication with shell backends
199 2048    Parse   print entry parsing debugging
200 4096    Cache   database cache processing
201 8192    Index   database indexing
202 16384   Sync    syncrepl consumer processing
203 !endblock
204
205 \Example:
206
207 E: olcLogLevel: -1
208
209 This will cause lots and lots of debugging information to be
210 logged.
211
212 E: olcLogLevel: Conns Filter
213
214 Just log the connection and search filter processing.
215
216 \Default:
217
218 E: olcLogLevel: Stats
219
220
221 H4: olcReferral <URI>
222
223 This directive specifies the referral to pass back when slapd
224 cannot find a local database to handle a request.
225
226 \Example:
227
228 >       olcReferral: ldap://root.openldap.org
229
230 This will refer non-local queries to the global root LDAP server
231 at the OpenLDAP Project. Smart LDAP clients can re-ask their
232 query at that server, but note that most of these clients are
233 only going to know how to handle simple LDAP URLs that
234 contain a host part and optionally a distinguished name part.
235
236
237 H4: Sample Entry
238
239 >dn: cn=config
240 >objectClass: olcGlobal
241 >cn: config
242 >olcIdleTimeout: 30
243 >olcLogLevel: Stats
244 >olcReferral: ldap://root.openldap.org
245
246
247
248 H3: cn=include
249
250 An include entry holds the pathname of one include file. Include files
251 are part of the old style slapd.conf configuration system and must be in
252 slapd.conf format. Include files were commonly used to load schema
253 specifications. While they are still supported, their use is deprecated.
254 Include entries must have the {{EX:olcIncludeFile}} objectClass.
255
256
257 H4: olcInclude: <filename>
258
259 This directive specifies that slapd should read additional
260 configuration information from the given file. 
261
262 Note: You should be careful when using this directive - there is
263 no small limit on the number of nested include directives, and no
264 loop detection is done.
265
266
267 H4: Sample Entries
268
269 >dn: cn=include{0},cn=config
270 >objectClass: olcIncludeFile
271 >cn: include{0}
272 >olcInclude: ./schema/core.schema
273 >
274 >dn: cn=include{1},cn=config
275 >objectClass: olcIncludeFile
276 >cn: include{1}
277 >olcInclude: ./schema/cosine.schema
278
279
280 H3: cn=module
281
282 If support for dynamically loaded modules was enabled when configuring
283 slapd, {{EX:cn=module}} entries may be used to specify sets of modules to load.
284 Module entries must have the {{EX:olcModuleList}} objectClass.
285
286
287 H4: olcModuleLoad: <filename>
288
289 Specify the name of a dynamically loadable module to load. The filename
290 may be an absolute path name or a simple filename. Non-absolute names
291 are searched for in the directories specified by the {{EX:olcModulePath}}
292 directive.
293
294
295 H4: olcModulePath: <pathspec>
296
297 Specify a list of directories to search for loadable modules. Typically the
298 path is colon-separated but this depends on the operating system.
299
300
301 H4: Sample Entries
302
303 >dn: cn=module{0},cn=config
304 >objectClass: olcModuleList
305 >cn: module{0}
306 >olcModuleLoad: /usr/local/lib/smbk5pwd.la
307 >
308 >dn: cn=module{1},cn=config
309 >objectClass: olcModuleList
310 >cn: module{1}
311 >olcModulePath: /usr/local/lib:/usr/local/lib/slapd
312 >olcModuleLoad: accesslog.la
313 >olcModuleLoad: pcache.la
314
315
316 H3: cn=schema
317
318 The cn=schema entry holds all of the schema definitions that are hard-coded
319 in slapd. As such, the values in this entry are generated by slapd so no
320 schema values need to be provided in the config file. The entry must still
321 be defined though, to serve as a base for the user-defined schema to add
322 in underneath. Schema entries must have the {{EX:olcSchemaConfig}}
323 objectClass.
324
325
326 H4: olcAttributeTypes: <{{REF:RFC4512}} Attribute Type Description>
327
328 This directive defines an attribute type.
329 Please see the {{SECT:Schema Specification}} chapter
330 for information regarding how to use this directive.
331
332
333 H4: olcObjectClasses: <{{REF:RFC4512}} Object Class Description>
334
335 This directive defines an object class.
336 Please see the {{SECT:Schema Specification}} chapter for
337 information regarding how to use this directive.
338
339
340 H4: Sample Entries
341
342 >dn: cn=schema,cn=config
343 >objectClass: olcSchemaConfig
344 >cn: schema
345 >
346 >dn: cn=test,cn=schema,cn=config
347 >objectClass: olcSchemaConfig
348 >cn: test
349 >olcAttributeTypes: ( 1.1.1
350 >  NAME 'testAttr'
351 >  EQUALITY integerMatch
352 >  SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
353 >olcAttributeTypes: ( 1.1.2 NAME 'testTwo' EQUALITY caseIgnoreMatch
354 >  SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 )
355 >olcObjectClasses: ( 1.1.3 NAME 'testObject'
356 >  MAY ( testAttr $ testTwo ) AUXILIARY )
357
358
359 H3: Backend-specific Directives
360
361 Backend directives apply to all database instances of the
362 same type and, depending on the directive, may be overridden
363 by database directives. Backend entries must have the
364 {{EX:olcBackendConfig}} objectClass.
365
366 H4: olcBackend: <type>
367
368 This directive names a backend-specific configuration entry.
369 {{EX:<type>}} should be one of the
370 supported backend types listed in Table 5.2.
371
372 !block table; align=Center; coltags="EX,N"; \
373         title="Table 5.2: Database Backends"
374 Types   Description
375 bdb     Berkeley DB transactional backend
376 config  Slapd configuration backend
377 dnssrv  DNS SRV backend
378 hdb     Hierarchical variant of bdb backend
379 ldap    Lightweight Directory Access Protocol (Proxy) backend
380 ldif    Lightweight Data Interchange Format backend
381 meta    Meta Directory backend
382 monitor Monitor backend
383 passwd  Provides read-only access to {{passwd}}(5)
384 perl    Perl Programmable backend
385 shell   Shell (extern program) backend
386 sql     SQL Programmable backend
387 !endblock
388
389 \Example:
390
391 >       olcBackend: bdb
392
393 There are no other directives defined for this entry.  Specific backend
394 types may define additional attributes for their particular use but so
395 far none have ever been defined.  As such, these directives usually do
396 not appear in any actual configurations.
397
398
399 H4: Sample Entry
400
401 > dn: olcBackend=bdb,cn=config
402 > objectClass: olcBackendConfig
403 > olcBackend: bdb
404
405
406 H3: Database-specific Directives
407
408 Directives in this section are supported by every type of database.
409 Database entries must have the {{EX:olcDatabaseConfig}} objectClass.
410
411 H4: olcDatabase: [{<index>}]<type>
412
413 This directive names a specific database instance. The numeric {<index>} may
414 be provided to distinguish multiple databases of the same type. Usually the
415 index can be omitted, and slapd will generate it automatically.
416 {{EX:<type>}} should be one of the
417 supported backend types listed in Table 5.2 or the {{EX:frontend}} type.
418
419 The {{EX:frontend}} is a special database that is used to hold
420 database-level options that should be applied to all the other
421 databases. Subsequent database definitions may also override some
422 frontend settings.
423
424 The {{EX:config}} database is also special; both the {{EX:config}} and
425 the {{EX:frontend}} databases are always created implicitly even if they
426 are not explicitly configured, and they are created before any other
427 databases.
428
429 \Example:
430
431 >       olcDatabase: bdb
432
433 This marks the beginning of a new {{TERM:BDB}} database instance.
434
435
436 H4: olcAccess: to <what> [ by <who> [<accesslevel>] [<control>] ]+
437
438 This directive grants access (specified by <accesslevel>) to a
439 set of entries and/or attributes (specified by <what>) by one or
440 more requesters (specified by <who>).
441 See the {{SECT:Access Control}} section of this chapter for a
442 summary of basic usage.
443
444 !if 0
445 More detailed discussion of this directive can be found in the
446 {{SECT:Advanced Access Control}} chapter.
447 !endif
448
449 Note: If no {{EX:olcAccess}} directives are specified, the default
450 access control policy, {{EX:to * by * read}}, allows all
451 users (both authenticated and anonymous) read access.
452
453 Note: Access controls defined in the frontend are appended to all
454 other databases' controls.
455
456
457 H4: olcReadonly { TRUE | FALSE }
458
459 This directive puts the database into "read-only" mode. Any
460 attempts to modify the database will return an "unwilling to
461 perform" error.
462
463 \Default:
464
465 >       olcReadonly: FALSE
466
467
468 H4: olcReplica
469
470 >       olcReplica: uri=ldap[s]://<hostname>[:<port>] | host=<hostname>[:<port>]
471 >               [bindmethod={simple|sasl}]
472 >               ["binddn=<DN>"]
473 >               [saslmech=<mech>]
474 >               [authcid=<identity>]
475 >               [authzid=<identity>]
476 >               [credentials=<password>]
477
478 This directive specifies a replication site for this database for
479 use with slurpd. The
480 {{EX:uri=}} parameter specifies a scheme, a host and optionally a port where
481 the slave slapd instance can be found. Either a domain name
482 or IP address may be used for <hostname>. If <port> is not
483 given, the standard LDAP port number (389 or 636) is used.
484
485 {{EX:host}} is deprecated in favor of the {{EX:uri}} parameter.
486
487 {{EX:uri}} allows the replica LDAP server to be specified as an LDAP 
488 URI such as {{EX:ldap://slave.example.com:389}} or
489 {{EX:ldaps://slave.example.com:636}}.
490
491 The {{EX:binddn=}} parameter gives the DN to bind as for updates
492 to the slave slapd. It should be a DN which has read/write access
493 to the slave slapd's database.  It must also match the {{EX:updatedn}}
494 directive in the slave slapd's config file.  Generally, this DN
495 {{should not}} be the same as the {{EX:rootdn}} of the master
496 database.  Since DNs are likely to contain embedded spaces, the
497 entire {{EX:"binddn=<DN>"}} string should be enclosed in double
498 quotes.
499
500 The {{EX:bindmethod}} is {{EX:simple}} or {{EX:sasl}},
501 depending on whether simple password-based authentication
502 or {{TERM:SASL}} authentication is to be used when connecting
503 to the slave slapd.
504
505 Simple authentication should not be used unless adequate data
506 integrity and confidentiality protections are in place (e.g. TLS
507 or {{TERM:IPsec}}).  Simple authentication requires specification
508 of {{EX:binddn}} and {{EX:credentials}} parameters.
509
510 SASL authentication is generally recommended.  SASL authentication
511 requires specification of a mechanism using the {{EX:saslmech}} parameter.
512 Depending on the mechanism, an authentication identity and/or
513 credentials can be specified using {{EX:authcid}} and {{EX:credentials}}
514 respectively.  The {{EX:authzid}} parameter may be used to specify
515 an authorization identity.
516
517 See the chapter entitled {{SECT:Replication with slurpd}} for more
518 information on how to use this directive.
519
520
521 H4: olcReplogfile: <filename>
522
523 This directive specifies the name of the replication log file to
524 which slapd will log changes. The replication log is typically
525 written by {{slapd}}(8) and read by {{slurpd}}(8). Normally, this
526 directive is only used if {{slurpd}}(8) is being used to replicate
527 the database.  However, you can also use it to generate a transaction
528 log, if {{slurpd}}(8) is not running. In this case, you will need to
529 periodically truncate the file, since it will grow indefinitely
530 otherwise.
531
532 See the chapter entitled {{SECT:Replication with slurpd}} for more
533 information on how to use this directive.
534
535
536 H4: olcRootDN: <DN>
537
538 This directive specifies the DN that is not subject to
539 access control or administrative limit restrictions for
540 operations on this database.  The DN need not refer to
541 an entry in this database or even in the directory. The
542 DN may refer to a SASL identity.
543
544 Entry-based Example:
545
546 >       olcRootDN: "cn=Manager,dc=example,dc=com"
547
548 SASL-based Example:
549
550 >       olcRootDN: "uid=root,cn=example.com,cn=digest-md5,cn=auth"
551
552 See the {{SECT:SASL Authentication}} section for information on
553 SASL authentication identities.
554
555
556 H4: olcRootPW: <password>
557
558 This directive can be used to specify a password for the DN for
559 the rootdn (when the rootdn is set to a DN within the database).
560
561 \Example:
562
563 >       olcRootPW: secret
564
565 It is also permissible to provide a hash of the password in
566 {{REF:RFC2307}} form.  {{slappasswd}}(8) may be used to generate
567 the password hash.
568
569 \Example:
570
571 >       olcRootPW: {SSHA}ZKKuqbEKJfKSXhUbHG3fG8MDn9j1v4QN
572
573 The hash was generated using the command {{EX:slappasswd -s secret}}.
574
575
576 H4: olcSizeLimit: <integer>
577
578 This directive specifies the maximum number of entries to return
579 from a search operation.
580
581 \Default:
582
583 >       olcSizeLimit: 500
584
585
586
587 H4: olcSuffix: <dn suffix>
588
589 This directive specifies the DN suffix of queries that will be
590 passed to this backend database. Multiple suffix lines can be
591 given, and usually at least one is required for each database
592 definition. (Some backend types, such as {{EX:frontend}} and
593 {{EX:monitor}} use a hard-coded suffix which may not be overridden
594 in the configuration.)
595
596 \Example:
597
598 >       olcSuffix: "dc=example,dc=com"
599
600 Queries with a DN ending in "dc=example,dc=com"
601 will be passed to this backend.
602
603 Note: When the backend to pass a query to is selected, slapd
604 looks at the suffix value(s) in each database definition in the
605 order in which they were configured. Thus, if one database suffix is a
606 prefix of another, it must appear after it in the configuration.
607
608
609 H4: olcSyncrepl
610
611 >       olcSyncrepl: rid=<replica ID>
612 >               provider=ldap[s]://<hostname>[:port]
613 >               [type=refreshOnly|refreshAndPersist]
614 >               [interval=dd:hh:mm:ss]
615 >               [retry=[<retry interval> <# of retries>]+]
616 >               searchbase=<base DN>
617 >               [filter=<filter str>]
618 >               [scope=sub|one|base]
619 >               [attrs=<attr list>]
620 >               [attrsonly]
621 >               [sizelimit=<limit>]
622 >               [timelimit=<limit>]
623 >               [schemachecking=on|off]
624 >               [bindmethod=simple|sasl]
625 >               [binddn=<DN>]
626 >               [saslmech=<mech>]
627 >               [authcid=<identity>]
628 >               [authzid=<identity>]
629 >               [credentials=<passwd>]
630 >               [realm=<realm>]
631 >               [secprops=<properties>]
632 >               [starttls=yes|critical]
633 >               [tls_cert=<file>]
634 >               [tls_key=<file>]
635 >               [tls_cacert=<file>]
636 >               [tls_cacertdir=<path>]
637 >               [tls_reqcert=never|allow|try|demand]
638 >               [tls_ciphersuite=<ciphers>]
639 >               [tls_crlcheck=none|peer|all]
640 >               [logbase=<base DN>]
641 >               [logfilter=<filter str>]
642 >               [syncdata=default|accesslog|changelog]
643
644
645 This directive specifies the current database as a replica of the
646 master content by establishing the current {{slapd}}(8) as a
647 replication consumer site running a syncrepl replication engine.
648 The master database is located at the replication provider site
649 specified by the {{EX:provider}} parameter. The replica database is
650 kept up-to-date with the master content using the LDAP Content
651 Synchronization protocol. See {{REF:RFC4533}}
652 for more information on the protocol.
653
654 The {{EX:rid}} parameter is used for identification of the current
655 {{EX:syncrepl}} directive within the replication consumer server,
656 where {{EX:<replica ID>}} uniquely identifies the syncrepl specification
657 described by the current {{EX:syncrepl}} directive. {{EX:<replica ID>}}
658 is non-negative and is no more than three decimal digits in length.
659
660 The {{EX:provider}} parameter specifies the replication provider site
661 containing the master content as an LDAP URI. The {{EX:provider}}
662 parameter specifies a scheme, a host and optionally a port where the
663 provider slapd instance can be found. Either a domain name or IP
664 address may be used for <hostname>. Examples are
665 {{EX:ldap://provider.example.com:389}} or {{EX:ldaps://192.168.1.1:636}}.
666 If <port> is not given, the standard LDAP port number (389 or 636) is used.
667 Note that the syncrepl uses a consumer-initiated protocol, and hence its
668 specification is located at the consumer site, whereas the {{EX:replica}}
669 specification is located at the provider site. {{EX:syncrepl}} and
670 {{EX:replica}} directives define two independent replication
671 mechanisms. They do not represent the replication peers of each other.
672
673 The content of the syncrepl replica is defined using a search
674 specification as its result set. The consumer slapd will
675 send search requests to the provider slapd according to the search
676 specification. The search specification includes {{EX:searchbase}},
677 {{EX:scope}}, {{EX:filter}}, {{EX:attrs}}, {{EX:attrsonly}},
678 {{EX:sizelimit}}, and {{EX:timelimit}} parameters as in the normal
679 search specification. The {{EX:searchbase}} parameter has no
680 default value and must always be specified. The {{EX:scope}} defaults
681 to {{EX:sub}}, the {{EX:filter}} defaults to {{EX:(objectclass=*)}},
682 {{EX:attrs}} defaults to {{EX:"*,+"}} to replicate all user and operational
683 attributes, and {{EX:attrsonly}} is unset by default. Both {{EX:sizelimit}}
684 and {{EX:timelimit}} default to "unlimited", and only positive integers
685 or "unlimited" may be specified.
686
687 The {{TERM[expand]LDAP Sync}} protocol has two operation
688 types: {{EX:refreshOnly}} and {{EX:refreshAndPersist}}.
689 The operation type is specified by the {{EX:type}} parameter.
690 In the {{EX:refreshOnly}} operation, the next synchronization search operation
691 is periodically rescheduled at an interval time after each
692 synchronization operation finishes. The interval is specified
693 by the {{EX:interval}} parameter. It is set to one day by default.
694 In the {{EX:refreshAndPersist}} operation, a synchronization search
695 remains persistent in the provider {{slapd}} instance. Further updates to the
696 master replica will generate {{EX:searchResultEntry}} to the consumer slapd
697 as the search responses to the persistent synchronization search.
698
699 If an error occurs during replication, the consumer will attempt to reconnect
700 according to the retry parameter which is a list of the <retry interval>
701 and <# of retries> pairs. For example, retry="60 10 300 3" lets the consumer
702 retry every 60 seconds for the first 10 times and then retry every 300 seconds
703 for the next three times before stop retrying. + in <#  of retries> means
704 indefinite number of retries until success.
705
706 The schema checking can be enforced at the LDAP Sync consumer site
707 by turning on the {{EX:schemachecking}} parameter.
708 If it is turned on, every replicated entry will be checked for its
709 schema as the entry is stored into the replica content.
710 Every entry in the replica should contain those attributes
711 required by the schema definition.
712 If it is turned off, entries will be stored without checking
713 schema conformance. The default is off.
714
715 The {{EX:binddn}} parameter gives the DN to bind as for the
716 syncrepl searches to the provider slapd. It should be a DN
717 which has read access to the replication content in the
718 master database. 
719
720 The {{EX:bindmethod}} is {{EX:simple}} or {{EX:sasl}},
721 depending on whether simple password-based authentication or
722 {{TERM:SASL}} authentication is to be used when connecting
723 to the provider {{slapd}} instance.
724
725 Simple authentication should not be used unless adequate data
726 integrity and confidentiality protections are in place (e.g. TLS
727 or IPsec). Simple authentication requires specification of {{EX:binddn}}
728 and {{EX:credentials}} parameters.
729
730 SASL authentication is generally recommended.  SASL authentication
731 requires specification of a mechanism using the {{EX:saslmech}} parameter.
732 Depending on the mechanism, an authentication identity and/or
733 credentials can be specified using {{EX:authcid}} and {{EX:credentials}},
734 respectively.  The {{EX:authzid}} parameter may be used to specify
735 an authorization identity.
736
737 The {{EX:realm}} parameter specifies a realm which a certain
738 mechanisms authenticate the identity within. The {{EX:secprops}}
739 parameter specifies Cyrus SASL security properties.
740
741 The {{EX:starttls}} parameter specifies use of the StartTLS extended
742 operation to establish a TLS session before authenticating to the provider.
743 If the {{EX:critical}} argument is supplied, the session will be aborted
744 if the StartTLS request fails.  Otherwise the syncrepl session continues
745 without TLS.  Note that the main slapd TLS settings are not used by the
746 syncrepl engine; by default the TLS parameters from a {{ldap.conf}}(5)
747 configuration file will be used.  TLS settings may be specified here,
748 in which case any {{ldap.conf}}(5) settings will be completely ignored.
749
750 Rather than replicating whole entries, the consumer can query logs
751 of data modifications.  This mode of operation is referred to as
752 {{delta syncrepl}}.  In addition to the above parameters, the
753 {{EX:logbase}} and {{EX:logfilter}} parameters must be set appropriately
754 for the log that will be used. The {{EX:syncdata}} parameter must
755 be set to either {{EX:"accesslog"}} if the log conforms to the
756 {{slapo-accesslog}}(5) log format, or {{EX:"changelog"}} if the log
757 conforms to the obsolete {{changelog}} format. If the {{EX:syncdata}}
758 parameter is omitted or set to {{EX:"default"}} then the log
759 parameters are ignored.
760
761 The {{syncrepl}} replication mechanism is supported by the {{bdb}} and
762 {{hdb}} backends.
763
764 See the {{SECT:LDAP Sync Replication}} chapter of this guide for
765 more information on how to use this directive.
766
767
768 H4: olcTimeLimit: <integer>
769
770 This directive specifies the maximum number of seconds (in real
771 time) slapd will spend answering a search request. If a
772 request is not finished in this time, a result indicating an
773 exceeded timelimit will be returned.
774
775 \Default:
776
777 >       olcTimeLimit: 3600
778
779
780 H4: olcUpdateDN: <DN>
781
782 This directive is only applicable in a slave slapd. It specifies
783 the DN allowed to make changes to the replica.  This may be the DN
784 {{slurpd}}(8) binds as when making changes to the replica or the DN
785 associated with a SASL identity.
786
787 Entry-based Example:
788
789 >       olcUpdateDN: "cn=Update Daemon,dc=example,dc=com"
790
791 SASL-based Example:
792
793 >       olcUpdateDN: "uid=slurpd,cn=example.com,cn=digest-md5,cn=auth"
794
795 See the {{SECT:Replication with slurpd}} chapter for more information
796 on how to use this directive.
797
798 H4: olcUpdateref: <URL>
799
800 This directive is only applicable in a slave slapd. It
801 specifies the URL to return to clients which submit update
802 requests upon the replica.
803 If specified multiple times, each {{TERM:URL}} is provided.
804
805 \Example:
806
807 >       olcUpdateref:   ldap://master.example.net
808
809
810 H4: Sample Entries
811
812 >dn: olcDatabase=frontend,cn=config
813 >objectClass: olcDatabaseConfig
814 >objectClass: olcFrontendConfig
815 >olcDatabase: frontend
816 >olcReadOnly: FALSE
817 >
818 >dn: olcDatabase=config,cn=config
819 >objectClass: olcDatabaseConfig
820 >olcDatabase: config
821 >olcRootDN: cn=Manager,dc=example,dc=com
822
823
824 H3: BDB and HDB Database Directives
825
826 Directives in this category apply to both the {{TERM:BDB}}
827 and the {{TERM:HDB}} database.
828 They are used in an olcDatabase entry in addition to the generic
829 database directives defined above.  For a complete reference
830 of BDB/HDB configuration directives, see {{slapd-bdb}}(5). In
831 addition to the {{EX:olcDatabaseConfig}} objectClass, BDB and HDB
832 database entries must have the {{EX:olcBdbConfig}} and
833 {{EX:olcHdbConfig}} objectClass, respectively.
834
835
836 H4: olcDbDirectory: <directory>
837
838 This directive specifies the directory where the BDB files
839 containing the database and associated indices live.
840
841 \Default:
842
843 >       olcDbDirectory: /usr/local/var/openldap-data
844
845
846 H4: olcDbCachesize: <integer>
847
848 This directive specifies the size in entries of the in-memory
849 cache maintained by the BDB backend database instance.
850
851 \Default:
852
853 >       olcDbCachesize: 1000
854
855
856 H4: olcDbCheckpoint: <kbyte> <min>
857
858 This directive specifies how often to checkpoint the BDB transaction log.
859 A checkpoint operation flushes the database buffers to disk and writes a
860 checkpoint record in the log.
861 The checkpoint will occur if either <kbyte> data has been written or
862 <min> minutes have passed since the last checkpont. Both arguments default
863 to zero, in which case they are ignored. When the <min> argument is
864 non-zero, an internal task will run every <min> minutes to perform the
865 checkpoint. See the Berkeley DB reference guide for more details.
866
867 \Example:
868
869 >       olcDbCheckpoint: 1024 10
870
871
872 H4: olcDbConfig: <DB_CONFIG setting>
873
874 This attribute specifies a configuration directive to be placed in the
875 {{EX:DB_CONFIG}} file of the database directory. At server startup time, if
876 no such file exists yet, the {{EX:DB_CONFIG}} file will be created and the
877 settings in this attribute will be written to it. If the file exists,
878 its contents will be read and displayed in this attribute. The attribute
879 is multi-valued, to accomodate multiple configuration directives. No default
880 is provided, but it is essential to use proper settings here to get the
881 best server performance.
882
883 \Example:
884
885 >       olcDbConfig: set_cachesize 0 10485760 0
886 >       olcDbConfig: set_lg_bsize 2097512
887 >       olcDbConfig: set_lg_dir /var/tmp/bdb-log
888 >       olcDbConfig: set_flags DB_LOG_AUTOREMOVE
889
890 In this example, the BDB cache is set to 10MB, the BDB transaction log
891 buffer size is set to 2MB, and the transaction log files are to be stored
892 in the /var/tmp/bdb-log directory. Also a flag is set to tell BDB to
893 delete transaction log files as soon as their contents have been
894 checkpointed and they are no longer needed. Without this setting the
895 transaction log files will continue to accumulate until some other
896 cleanup procedure removes them. See the SleepyCat documentation for the
897 {{EX:db_archive}} command for details.
898
899 Ideally the BDB cache must be
900 at least as large as the working set of the database, the log buffer size
901 should be large enough to accomodate most transactions without overflowing,
902 and the log directory must be on a separate physical disk from the main
903 database files. And both the database directory and the log directory
904 should be separate from disks used for regular system activities such as
905 the root, boot, or swap filesystems. See the FAQ-o-Matic and the SleepyCat
906 documentation for more details.
907
908
909 H4: olcDbNosync: { TRUE | FALSE }
910
911 This option causes on-disk database contents to not be immediately
912 synchronized with in memory changes upon change.  Setting this option
913 to {{EX:TRUE}} may improve performance at the expense of data integrity. This
914 directive has the same effect as using
915 >       olcDbConfig: set_flags DB_TXN_NOSYNC
916
917
918 H4: olcDbIDLcacheSize: <integer>
919
920 Specify the size of the in-memory index cache, in index slots. The
921 default is zero. A larger value will speed up frequent searches of
922 indexed entries. The optimal size will depend on the data and search
923 characteristics of the database, but using a number three times
924 the entry cache size is a good starting point.
925
926 \Example:
927
928 >       olcDbIDLcacheSize: 3000
929
930
931 H4: olcDbIndex: {<attrlist> | default} [pres,eq,approx,sub,none]
932
933 This directive specifies the indices to maintain for the given
934 attribute. If only an {{EX:<attrlist>}} is given, the default
935 indices are maintained.
936
937 \Example:
938
939 >       olcDbIndex: default pres,eq
940 >       olcDbIndex: uid
941 >       olcDbIndex: cn,sn pres,eq,sub
942 >       olcDbIndex: objectClass eq
943
944 The first line sets the default set of indices to maintain to
945 present and equality.  The second line causes the default (pres,eq)
946 set of indices to be maintained for the {{EX:uid}} attribute type.
947 The third line causes present, equality, and substring indices to
948 be maintained for {{EX:cn}} and {{EX:sn}} attribute types.  The
949 fourth line causes an equality index for the {{EX:objectClass}}
950 attribute type.
951
952 By default, no indices are maintained.  It is generally advised
953 that minimally an equality index upon objectClass be maintained.
954
955 >       olcDbindex: objectClass eq
956
957 If this setting is changed while slapd is running, an internal task
958 will be run to generate the changed index data. All server operations
959 can continue as normal while the indexer does its work.  If slapd is
960 stopped before the index task completes, indexing will have to be
961 manually completed using the slapindex tool.
962
963
964 H4: olcDbLinearIndex: { TRUE | FALSE }
965
966 If this setting is {{EX:TRUE}} slapindex will index one attribute
967 at a time. The default settings is {{EX:FALSE}} in which case all
968 indexed attributes of an entry are processed at the same time. When
969 enabled, each indexed attribute is processed individually, using
970 multiple passes through the entire database. This option improves
971 slapindex performance when the database size exceeds the BDB cache
972 size. When the BDB cache is large enough, this option is not needed
973 and will decrease performance. Also by default, slapadd performs
974 full indexing and so a separate slapindex run is not needed. With
975 this option, slapadd does no indexing and slapindex must be used.
976
977
978 H4: olcDbMode: <integer>
979
980 This directive specifies the file protection mode that newly
981 created database index files should have.
982
983 \Default:
984
985 >       olcDbMode: 0600
986
987
988 H4: olcDbSearchStack: <integer>
989
990 Specify the depth of the stack used for search filter evaluation.
991 Search filters are evaluated on a stack to accomodate nested {{EX:AND}} /
992 {{EX:OR}} clauses. An individual stack is allocated for each server thread.
993 The depth of the stack determines how complex a filter can be evaluated
994 without requiring any additional memory allocation. Filters that are
995 nested deeper than the search stack depth will cause a separate stack to
996 be allocated for that particular search operation. These separate allocations
997 can have a major negative impact on server performance, but specifying
998 too much stack will also consume a great deal of memory. Each search
999 uses 512K bytes per level on a 32-bit machine, or 1024K bytes per level
1000 on a 64-bit machine. The default stack depth is 16, thus 8MB or 16MB
1001 per thread is used on 32 and 64 bit machines, respectively. Also the
1002 512KB size of a single stack slot is set by a compile-time constant which
1003 may be changed if needed; the code must be recompiled for the change
1004 to take effect.
1005
1006 \Default:
1007
1008 >       olcDbSearchStack: 16
1009
1010
1011 H4: olcDbShmKey: <integer>
1012
1013 Specify a key for a shared memory BDB environment. By default the BDB
1014 environment uses memory mapped files. If a non-zero value is specified,
1015 it will be used as the key to identify a shared memory region that will
1016 house the environment.
1017
1018 \Example:
1019
1020 >       olcDbShmKey: 42
1021
1022
1023 H4: Sample Entry
1024
1025 >dn: olcDatabase=hdb,cn=config
1026 >objectClass: olcDatabaseConfig
1027 >objectClass: olcHdbConfig
1028 >olcDatabase: hdb
1029 >olcSuffix: "dc=example,dc=com"
1030 >olcDbDirectory: /usr/local/var/openldap-data
1031 >olcDbCacheSize: 1000
1032 >olcDbCheckpoint: 1024 10
1033 >olcDbConfig: set_cachesize 0 10485760 0
1034 >olcDbConfig: set_lg_bsize 2097152
1035 >olcDbConfig: set_lg_dir /var/tmp/bdb-log
1036 >olcDbConfig: set_flags DB_LOG_AUTOREMOVE
1037 >olcDbIDLcacheSize: 3000
1038 >olcDbIndex: objectClass eq
1039
1040
1041 H2: Access Control
1042
1043 Access to slapd entries and attributes is controlled by the
1044 olcAccess attribute, whose values are a sequence of access directives.
1045 The general form of the olcAccess configuration is:
1046
1047 >       olcAccess: <access directive>
1048 >       <access directive> ::= to <what>
1049 >               [by <who> [<access>] [<control>] ]+
1050 >       <what> ::= * |
1051 >               [dn[.<basic-style>]=<regex> | dn.<scope-style>=<DN>]
1052 >               [filter=<ldapfilter>] [attrs=<attrlist>]
1053 >       <basic-style> ::= regex | exact
1054 >       <scope-style> ::= base | one | subtree | children
1055 >       <attrlist> ::= <attr> [val[.<basic-style>]=<regex>] | <attr> , <attrlist>
1056 >       <attr> ::= <attrname> | entry | children
1057 >       <who> ::= * | [anonymous | users | self
1058 >                       | dn[.<basic-style>]=<regex> | dn.<scope-style>=<DN>] 
1059 >               [dnattr=<attrname>]
1060 >               [group[/<objectclass>[/<attrname>][.<basic-style>]]=<regex>]
1061 >               [peername[.<basic-style>]=<regex>]
1062 >               [sockname[.<basic-style>]=<regex>]
1063 >               [domain[.<basic-style>]=<regex>]
1064 >               [sockurl[.<basic-style>]=<regex>]
1065 >               [set=<setspec>]
1066 >               [aci=<attrname>]
1067 >       <access> ::= [self]{<level>|<priv>}
1068 >       <level> ::= none | disclose | auth | compare | search | read | write | manage
1069 >       <priv> ::= {=|+|-}{m|w|r|s|c|x|d|0}+
1070 >       <control> ::= [stop | continue | break]
1071
1072 where the <what> part selects the entries and/or attributes to which
1073 the access applies, the {{EX:<who>}} part specifies which entities
1074 are granted access, and the {{EX:<access>}} part specifies the
1075 access granted. Multiple {{EX:<who> <access> <control>}} triplets
1076 are supported, allowing many entities to be granted different access
1077 to the same set of entries and attributes. Not all of these access
1078 control options are described here; for more details see the
1079 {{slapd.access}}(5) man page.
1080
1081
1082 H3: What to control access to
1083
1084 The <what> part of an access specification determines the entries
1085 and attributes to which the access control applies.  Entries are
1086 commonly selected in two ways: by DN and by filter.  The following
1087 qualifiers select entries by DN:
1088
1089 >       to *
1090 >       to dn[.<basic-style>]=<regex>
1091 >       to dn.<scope-style>=<DN>
1092
1093 The first form is used to select all entries.  The second form may
1094 be used to select entries by matching a regular expression against
1095 the target entry's {{normalized DN}}.   (The second form is not
1096 discussed further in this document.)  The third form is used to
1097 select entries which are within the requested scope of DN.  The
1098 <DN> is a string representation of the Distinguished Name, as
1099 described in {{REF:RFC4514}}.
1100
1101 The scope can be either {{EX:base}}, {{EX:one}}, {{EX:subtree}},
1102 or {{EX:children}}.  Where {{EX:base}} matches only the entry with
1103 provided DN, {{EX:one}} matches the entries whose parent is the
1104 provided DN, {{EX:subtree}} matches all entries in the subtree whose
1105 root is the provided DN, and {{EX:children}} matches all entries
1106 under the DN (but not the entry named by the DN).
1107
1108 For example, if the directory contained entries named:
1109
1110 >       0: o=suffix
1111 >       1: cn=Manager,o=suffix
1112 >       2: ou=people,o=suffix
1113 >       3: uid=kdz,ou=people,o=suffix
1114 >       4: cn=addresses,uid=kdz,ou=people,o=suffix
1115 >       5: uid=hyc,ou=people,o=suffix
1116
1117 \Then:
1118 . {{EX:dn.base="ou=people,o=suffix"}} match 2;
1119 . {{EX:dn.one="ou=people,o=suffix"}} match 3, and 5;
1120 . {{EX:dn.subtree="ou=people,o=suffix"}} match 2, 3, 4, and 5; and
1121 . {{EX:dn.children="ou=people,o=suffix"}} match 3, 4, and 5.
1122
1123
1124 Entries may also be selected using a filter:
1125
1126 >       to filter=<ldap filter>
1127
1128 where <ldap filter> is a string representation of an LDAP
1129 search filter, as described in {{REF:RFC4515}}.  For example:
1130
1131 >       to filter=(objectClass=person)
1132
1133 Note that entries may be selected by both DN and filter by
1134 including both qualifiers in the <what> clause.
1135
1136 >       to dn.one="ou=people,o=suffix" filter=(objectClass=person)
1137
1138 Attributes within an entry are selected by including a comma-separated
1139 list of attribute names in the <what> selector:
1140
1141 >       attrs=<attribute list>
1142
1143 A specific value of an attribute is selected by using a single
1144 attribute name and also using a value selector:
1145
1146 >       attrs=<attribute> val[.<style>]=<regex>
1147
1148 There are two special {{pseudo}} attributes {{EX:entry}} and
1149 {{EX:children}}.  To read (and hence return) a target entry, the
1150 subject must have {{EX:read}} access to the target's {{entry}}
1151 attribute.  To add or delete an entry, the subject must have
1152 {{EX:write}} access to the entry's {{EX:entry}} attribute AND must
1153 have {{EX:write}} access to the entry's parent's {{EX:children}}
1154 attribute.  To rename an entry, the subject must have {{EX:write}}
1155 access to entry's {{EX:entry}} attribute AND have {{EX:write}}
1156 access to both the old parent's and new parent's {{EX:children}}
1157 attributes.  The complete examples at the end of this section should
1158 help clear things up.
1159
1160 Lastly, there is a special entry selector {{EX:"*"}} that is used to
1161 select any entry.  It is used when no other {{EX:<what>}}
1162 selector has been provided.  It's equivalent to "{{EX:dn=.*}}"
1163
1164
1165 H3: Who to grant access to
1166
1167 The <who> part identifies the entity or entities being granted
1168 access. Note that access is granted to "entities" not "entries."
1169 The following table summarizes entity specifiers:
1170
1171 !block table; align=Center; coltags="EX,N"; \
1172         title="Table 5.3: Access Entity Specifiers"
1173 Specifier|Entities
1174 *|All, including anonymous and authenticated users
1175 anonymous|Anonymous (non-authenticated) users
1176 users|Authenticated users
1177 self|User associated with target entry
1178 dn[.<basic-style>]=<regex>|Users matching a regular expression
1179 dn.<scope-style>=<DN>|Users within scope of a DN
1180 !endblock
1181
1182 The DN specifier behaves much like <what> clause DN specifiers.
1183
1184 Other control factors are also supported.  For example, a {{EX:<who>}}
1185 can be restricted by an entry listed in a DN-valued attribute in
1186 the entry to which the access applies:
1187
1188 >       dnattr=<dn-valued attribute name>
1189
1190 The dnattr specification is used to give access to an entry
1191 whose DN is listed in an attribute of the entry (e.g., give
1192 access to a group entry to whoever is listed as the owner of
1193 the group entry).
1194
1195 Some factors may not be appropriate in all environments (or any).
1196 For example, the domain factor relies on IP to domain name lookups.
1197 As these can easily spoofed, the domain factor should not be avoided.
1198
1199
1200 H3: The access to grant
1201
1202 The kind of <access> granted can be one of the following:
1203
1204 !block table; colaligns="LRL"; coltags="EX,EX,N"; align=Center; \
1205         title="Table 5.4: Access Levels"
1206 Level           Privileges      Description
1207 none            =0                      no access
1208 disclose        =d                      needed for information disclosure on error
1209 auth            =dx                     needed to authenticate (bind)
1210 compare         =cdx            needed to compare
1211 search          =scdx           needed to apply search filters
1212 read            =rscdx          needed to read search results
1213 write           =wrscdx         needed to modify/rename
1214 manage          =mwrscdx        needed to manage
1215 !endblock
1216
1217 Each level implies all lower levels of access. So, for example,
1218 granting someone {{EX:write}} access to an entry also grants them
1219 {{EX:read}}, {{EX:search}}, {{EX:compare}}, {{EX:auth}} and
1220 {{EX:disclose}} access.  However, one may use the privileges specifier
1221 to grant specific permissions.
1222
1223
1224 H3: Access Control Evaluation
1225
1226 When evaluating whether some requester should be given access to
1227 an entry and/or attribute, slapd compares the entry and/or attribute
1228 to the {{EX:<what>}} selectors given in the configuration.  For
1229 each entry, access controls provided in the database which holds
1230 the entry (or the first database if not held in any database) apply
1231 first, followed by the global access directives (which are held in
1232 the {{EX:frontend}} database definition).  Within this priority,
1233 access directives are examined in the order in which they appear
1234 in the configuration attribute.  Slapd stops with the first
1235 {{EX:<what>}} selector that matches the entry and/or attribute. The
1236 corresponding access directive is the one slapd will use to evaluate
1237 access.
1238
1239 Next, slapd compares the entity requesting access to the {{EX:<who>}}
1240 selectors within the access directive selected above in the order
1241 in which they appear. It stops with the first {{EX:<who>}} selector
1242 that matches the requester. This determines the access the entity
1243 requesting access has to the entry and/or attribute.
1244
1245 Finally, slapd compares the access granted in the selected
1246 {{EX:<access>}} clause to the access requested by the client. If
1247 it allows greater or equal access, access is granted. Otherwise,
1248 access is denied.
1249
1250 The order of evaluation of access directives makes their placement
1251 in the configuration file important. If one access directive is
1252 more specific than another in terms of the entries it selects, it
1253 should appear first in the configuration. Similarly, if one {{EX:<who>}}
1254 selector is more specific than another it should come first in the
1255 access directive. The access control examples given below should
1256 help make this clear.
1257
1258
1259
1260 H3: Access Control Examples
1261
1262 The access control facility described above is quite powerful.  This
1263 section shows some examples of its use for descriptive purposes.
1264
1265 A simple example:
1266
1267 >       olcAccess: to * by * read
1268
1269 This access directive grants read access to everyone.
1270
1271 >       olcAccess: to *
1272 >               by self write
1273 >               by anonymous auth
1274 >               by * read
1275
1276 This directive allows the user to modify their entry, allows anonymous
1277 to authenticate against these entries, and allows all others to
1278 read these entries.  Note that only the first {{EX:by <who>}} clause
1279 which matches applies.  Hence, the anonymous users are granted
1280 {{EX:auth}}, not {{EX:read}}.  The last clause could just as well
1281 have been "{{EX:by users read}}".
1282
1283 It is often desirable to restrict operations based upon the level
1284 of protection in place.  The following shows how security strength
1285 factors (SSF) can be used.
1286
1287 >       olcAccess: to *
1288 >               by ssf=128 self write
1289 >               by ssf=64 anonymous auth
1290 >               by ssf=64 users read
1291
1292 This directive allows users to modify their own entries if security
1293 protections of strength 128 or better have been established,
1294 allows authentication access to anonymous users, and read access
1295 when strength 64 or better security protections have been established.  If
1296 the client has not establish sufficient security protections, the
1297 implicit {{EX:by * none}} clause would be applied.
1298
1299 The following example shows the use of style specifiers to select
1300 the entries by DN in two access directives where ordering is
1301 significant.
1302
1303 >       olcAccess: to dn.children="dc=example,dc=com"
1304 >               by * search
1305 >       olcAccess: to dn.children="dc=com"
1306 >               by * read
1307
1308 Read access is granted to entries under the {{EX:dc=com}} subtree,
1309 except for those entries under the {{EX:dc=example,dc=com}} subtree,
1310 to which search access is granted.  No access is granted to
1311 {{EX:dc=com}} as neither access directive matches this DN.  If the
1312 order of these access directives was reversed, the trailing directive
1313 would never be reached, since all entries under {{EX:dc=example,dc=com}}
1314 are also under {{EX:dc=com}} entries.
1315
1316 Also note that if no {{EX:olcAccess: to}} directive matches or no {{EX:by
1317 <who>}} clause, {{B:access is denied}}.  That is, every {{EX:olcAccess:
1318 to}} directive ends with an implicit {{EX:by * none}} clause and
1319 every access list ends with an implicit {{EX:olcAccess: to * by * none}}
1320 directive.
1321
1322 The next example again shows the importance of ordering, both of
1323 the access directives and the {{EX:by <who>}} clauses.  It also
1324 shows the use of an attribute selector to grant access to a specific
1325 attribute and various {{EX:<who>}} selectors.
1326
1327 >       olcAccess: to dn.subtree="dc=example,dc=com" attr=homePhone
1328 >               by self write
1329 >               by dn.children=dc=example,dc=com" search
1330 >               by peername.regex=IP:10\..+ read
1331 >       olcAccess: to dn.subtree="dc=example,dc=com"
1332 >               by self write
1333 >               by dn.children="dc=example,dc=com" search
1334 >               by anonymous auth
1335
1336 This example applies to entries in the "{{EX:dc=example,dc=com}}"
1337 subtree. To all attributes except {{EX:homePhone}}, an entry can
1338 write to itself, entries under {{EX:example.com}} entries can search
1339 by them, anybody else has no access (implicit {{EX:by * none}})
1340 excepting for authentication/authorization (which is always done
1341 anonymously).  The {{EX:homePhone}} attribute is writable by the
1342 entry, searchable by entries under {{EX:example.com}}, readable by
1343 clients connecting from network 10, and otherwise not readable
1344 (implicit {{EX:by * none}}).  All other access is denied by the
1345 implicit {{EX:access to * by * none}}.
1346
1347 Sometimes it is useful to permit a particular DN to add or
1348 remove itself from an attribute. For example, if you would like to
1349 create a group and allow people to add and remove only
1350 their own DN from the member attribute, you could accomplish
1351 it with an access directive like this:
1352
1353 >       olcAccess: to attr=member,entry
1354 >               by dnattr=member selfwrite
1355
1356 The dnattr {{EX:<who>}} selector says that the access applies to
1357 entries listed in the {{EX:member}} attribute. The {{EX:selfwrite}} access
1358 selector says that such members can only add or delete their
1359 own DN from the attribute, not other values. The addition of
1360 the entry attribute is required because access to the entry is
1361 required to access any of the entry's attributes.
1362
1363
1364
1365 H3: Access Control Ordering
1366
1367 Since the ordering of {{EX:olcAccess}} directives is essential to their
1368 proper evaluation, but LDAP attributes normally do not preserve the
1369 ordering of their values, OpenLDAP uses a custom schema extension to
1370 maintain a fixed ordering of these values. This ordering is maintained
1371 by prepending a {{EX:"{X}"}} numeric index to each value, similarly to
1372 the approach used for ordering the configuration entries. These index
1373 tags are maintained automatically by slapd and do not need to be specified
1374 when originally defining the values. For example, when you create the
1375 settings
1376
1377 >       olcAccess: to attr=member,entry
1378 >               by dnattr=member selfwrite
1379 >       olcAccess: to dn.children="dc=example,dc=com"
1380 >               by * search
1381 >       olcAccess: to dn.children="dc=com"
1382 >               by * read
1383
1384 when you read them back using slapcat or ldapsearch they will contain
1385
1386 >       olcAccess: {0}to attr=member,entry
1387 >               by dnattr=member selfwrite
1388 >       olcAccess: {1}to dn.children="dc=example,dc=com"
1389 >               by * search
1390 >       olcAccess: {2}to dn.children="dc=com"
1391 >               by * read
1392
1393 The numeric index may be used to specify a particular value to change
1394 when using ldapmodify to edit the access rules. This index can be used
1395 instead of (or in addition to) the actual access value. Using this 
1396 numeric index is very helpful when multiple access rules are being managed.
1397
1398 For example, if we needed to change the second rule above to grant
1399 write access instead of search, we could try this LDIF:
1400
1401 >       changetype: modify
1402 >       delete: olcAccess
1403 >       olcAccess: to dn.children="dc=example,dc=com" by * search
1404 >       -
1405 >       add: olcAccess
1406 >       olcAccess: to dn.children="dc=example,dc=com" by * write
1407 >       -
1408
1409 But this example {{B:will not}} guarantee that the existing values remain in
1410 their original order, so it will most likely yield a broken security
1411 configuration. Instead, the numeric index should be used:
1412
1413 >       changetype: modify
1414 >       delete: olcAccess
1415 >       olcAccess: {1}
1416 >       -
1417 >       add: olcAccess
1418 >       olcAccess: {1}to dn.children="dc=example,dc=com" by * write
1419 >       -
1420
1421 This example deletes whatever rule is in value #1 of the {{EX:olcAccess}}
1422 attribute (regardless of its value) and adds a new value that is
1423 explicitly inserted as value #1. The result will be
1424
1425 >       olcAccess: {0}to attr=member,entry
1426 >               by dnattr=member selfwrite
1427 >       olcAccess: {1}to dn.children="dc=example,dc=com"
1428 >               by * write
1429 >       olcAccess: {2}to dn.children="dc=com"
1430 >               by * read
1431
1432 which is exactly what was intended.
1433
1434 !if 0
1435 For more details on how to use the {{EX:access}} directive,
1436 consult the {{Advanced Access Control}} chapter.
1437 !endif
1438
1439
1440 H2: Configuration Example
1441
1442 The following is an example configuration, interspersed
1443 with explanatory text. It defines two databases to handle
1444 different parts of the {{TERM:X.500}} tree; both are {{TERM:BDB}}
1445 database instances. The line numbers shown are provided for
1446 reference only and are not included in the actual file. First, the
1447 global configuration section:
1448
1449 E:  1.  # example config file - global configuration entry
1450 E:  2.  dn: cn=config
1451 E:  3.  objectClass: olcGlobal
1452 E:  4.  cn: config
1453 E:  5.  olcReferral: ldap://root.openldap.org
1454 E:  6.  
1455
1456 Line 1 is a comment. Lines 2-4 identify this as the global
1457 configuration entry.
1458 The {{EX:olcReferral:}} directive on line 5
1459 means that queries not local to one of the databases defined
1460 below will be referred to the LDAP server running on the
1461 standard port (389) at the host {{EX:root.openldap.org}}.
1462 Line 6 is a blank line, indicating the end of this entry.
1463
1464 E:  7.  # internal schema
1465 E:  8.  dn: cn=schema,cn=config
1466 E:  9.  objectClass: olcSchemaConfig
1467 E: 10.  cn: schema
1468 E: 11.  
1469
1470 Line 7 is a comment. Lines 8-10 identify this as the root of
1471 the schema subtree. The actual schema definitions in this entry
1472 are hardcoded into slapd so no additional attributes are specified here.
1473 Line 11 is a blank line, indicating the end of this entry.
1474
1475 E: 12.  # include the core schema
1476 E: 13.  include: file:///usr/local/etc/openldap/schema/core.ldif
1477 E: 14.  
1478
1479 Line 12 is a comment. Line 13 is an LDIF include directive which
1480 accesses the {{core}} schema definitions in LDIF format. Line 14
1481 is a blank line.
1482
1483 Next comes the database definitions. The first database is the
1484 special {{EX:frontend}} database whose settings are applied globally
1485 to all the other databases.
1486
1487 E: 15.  # global database parameters
1488 E: 16.  dn: olcDatabase=frontend,cn=config
1489 E: 17.  objectClass: olcDatabaseConfig
1490 E: 18.  olcDatabase: frontend
1491 E: 19.  olcAccess: to * by * read
1492 E: 20.  
1493
1494 Line 15 is a comment. Lines 16-18 identify this entry as the global
1495 database entry. Line 19 is a global access control. It applies to all
1496 entries (after any applicable database-specific access controls).
1497
1498 The next entry defines a BDB backend that will handle queries for things
1499 in the "dc=example,dc=com" portion of the tree. Indices are to be maintained
1500 for several attributes, and the {{EX:userPassword}} attribute is to be
1501 protected from unauthorized access.
1502
1503 E: 21.  # BDB definition for example.com
1504 E: 22.  dn: olcDatabase=bdb,cn=config
1505 E: 23.  objectClass: olcDatabaseConfig
1506 E: 24.  objectClass: olcBdbConfig
1507 E: 25.  olcDatabase: bdb
1508 E: 26.  olcSuffix: "dc=example,dc=com"
1509 E: 27.  olcDbDirectory: /usr/local/var/openldap-data
1510 E: 28.  olcRootDN: "cn=Manager,dc=example,dc=com"
1511 E: 29.  olcRootPW: secret
1512 E: 30.  olcDbIndex: uid pres,eq
1513 E: 31.  olcDbIndex: cn,sn,uid pres,eq,approx,sub
1514 E: 32.  olcDbIndex: objectClass eq
1515 E: 33.  olcAccess: to attr=userPassword
1516 E: 34.    by self write
1517 E: 35.    by anonymous auth
1518 E: 36.    by dn.base="cn=Admin,dc=example,dc=com" write
1519 E: 37.    by * none
1520 E: 38.  olcAccess: to *
1521 E: 39.    by self write
1522 E: 40.    by dn.base="cn=Admin,dc=example,dc=com" write
1523 E: 41.    by * read
1524 E: 42.  
1525
1526 Line 21 is a comment. Lines 22-25 identify this entry as a BDB database
1527 configuration entry.  Line 26 specifies the DN suffix
1528 for queries to pass to this database. Line 27 specifies the directory
1529 in which the database files will live.
1530
1531 Lines 28 and 29 identify the database {{super-user}} entry and associated
1532 password. This entry is not subject to access control or size or
1533 time limit restrictions.
1534
1535 Lines 30 through 32 indicate the indices to maintain for various
1536 attributes.
1537
1538 Lines 33 through 41 specify access control for entries in this
1539 database.  As this is the first database, the controls also apply
1540 to entries not held in any database (such as the Root DSE).  For
1541 all applicable entries, the {{EX:userPassword}} attribute is writable
1542 by the entry itself and by the "admin" entry.  It may be used for
1543 authentication/authorization purposes, but is otherwise not readable.
1544 All other attributes are writable by the entry and the "admin"
1545 entry, but may be read by all users (authenticated or not).
1546
1547 Line 42 is a blank line, indicating the end of this entry.
1548
1549 The next section of the example configuration file defines another
1550 BDB database. This one handles queries involving the
1551 {{EX:dc=example,dc=net}} subtree but is managed by the same entity
1552 as the first database.  Note that without line 51, the read access
1553 would be allowed due to the global access rule at line 19.
1554
1555 E: 42.  # BDB definition for example.net
1556 E: 43.  dn: olcDatabase=bdb,cn=config
1557 E: 44.  objectClass: olcDatabaseConfig
1558 E: 45.  objectClass: olcBdbConfig
1559 E: 46.  olcDatabase: bdb
1560 E: 47.  olcSuffix: "dc=example,dc=net"
1561 E: 48.  olcDbDirectory: /usr/local/var/openldap-data-net
1562 E: 49.  olcRootDN: "cn=Manager,dc=example,dc=com"
1563 E: 50.  olcDbIndex: objectClass eq
1564 E: 51.  olcAccess: to * by users read