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