]> git.sur5r.net Git - openldap/blob - doc/guide/admin/slapdconfig.sdf
Formating
[openldap] / doc / guide / admin / slapdconfig.sdf
1 # $OpenLDAP$
2 # Copyright 1999-2003, The OpenLDAP Foundation, All Rights Reserved.
3 # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
4
5 H1: The slapd Configuration File
6
7 Once the software has been built and installed, you are ready
8 to configure {{slapd}}(8) for use at your site. The slapd
9 runtime configuration is primarily accomplished through the
10 {{slapd.conf}}(5) file, normally installed in the
11 {{EX:/usr/local/etc/openldap}} directory.
12
13 An alternate configuration file can be specified via a
14 command-line option to {{slapd}}(8) or {{slurpd}}(8). This chapter
15 describes the general format of the config file, followed by a
16 detailed description of commonly used config file directives.
17
18
19 H2: Configuration File Format
20
21 The {{slapd.conf}}(5) file consists of three types of configuration
22 information: global, backend specific, and database specific.  Global
23 information is specified first, followed by information associated
24 with a particular backend type, which is then followed by information
25 associated with a particular database instance.  Global directives can
26 be overridden in backend and/or database directives, and backend directives
27 can be overridden by database directives.
28
29 Blank lines and comment lines beginning with a '{{EX:#}}' character
30 are ignored.  If a line begins with white space, it is considered a
31 continuation of the previous line (even if the previous line is a
32 comment).
33
34 The general format of slapd.conf is as follows:
35
36 >       # global configuration directives
37 >       <global config directives>
38 >
39 >       # backend definition
40 >       backend <typeA>
41 >       <backend-specific directives>
42 >
43 >       # first database definition & config directives
44 >       database <typeA>
45 >       <database-specific directives>
46 >
47 >       # second database definition & config directives
48 >       database <typeB>
49 >       <database-specific directives>
50 >
51 >       # second database definition & config directives
52 >       database <typeA>
53 >       <database-specific directives>
54 >
55 >       # subsequent backend & database definitions & config directives
56 >       ...
57
58 A configuration directive may take arguments.  If so, they are
59 separated by white space.  If an argument contains white space,
60 the argument should be enclosed in double quotes {{EX:"like this"}}. If
61 an argument contains a double quote or a backslash character `{{EX:\}}',
62 the character should be preceded by a backslash character `{{EX:\}}'.
63
64 The distribution contains an example configuration file that will
65 be installed in the {{F: /usr/local/etc/openldap}} directory.
66 A number of files containing schema definitions (attribute types
67 and object classes) are also provided in the
68 {{F: /usr/local/etc/openldap/schema}} directory.
69
70
71 H2: Configuration File Directives
72
73 This section details commonly used configuration directives.  For
74 a complete list, see the {{slapd.conf}}(5) manual page.  This section
75 separates the configuration file directives into global,
76 backend-specific and data-specific categories, describing each
77 directive and its default value (if any), and giving an example of
78 its use.
79
80
81
82 H3: Global Directives
83
84 Directives described in this section apply to all backends
85 and databases unless specifically overridden in a backend or
86 database definition.  Arguments that should be replaced
87 by actual text are shown in brackets {{EX:<>}}.
88
89
90 H4: access to <what> [ by <who> <accesslevel> <control> ]+
91
92 This directive grants access (specified by <accesslevel>) to a
93 set of entries and/or attributes (specified by <what>) by one or
94 more requesters (specified by <who>).
95 See the {{SECT:Access Control}} section of this chapter for a
96 summary of basic usage.
97
98 !if 0
99 More details discussion of this directive can be found in the
100 {{SECT:Advanced Access Control}} chapter.
101 !endif
102
103 Note: If no {{EX:access}} directives are specified, the default
104 access control policy, {{EX:access to * by * read}}, allows all
105 both authenticated and anonymous users read access.
106
107
108 H4: attributetype <{{REF:RFC2252}} Attribute Type Description>
109
110 This directive defines an attribute type.
111 Please see the {{SECT:Schema Specification}} chapter
112 for information regarding how to use this directive.
113
114 H4: idletimeout <integer>
115
116 Specify the number of seconds to wait before forcibly closing
117 an idle client connection.  An idletimeout of 0, the default,
118 disables this feature.
119
120
121 H4: include <filename>
122
123 This directive specifies that slapd should read additional
124 configuration information from the given file before continuing
125 with the next line of the current file. The included file should
126 follow the normal slapd config file format.  The file is commonly
127 used to include files containing schema specifications.
128
129 Note: You should be careful when using this directive - there is
130 no small limit on the number of nested include directives, and no
131 loop detection is done.
132
133 H4: loglevel <integer>
134
135 This directive specifies the level at which debugging statements
136 and operation statistics should be syslogged (currently logged to
137 the {{syslogd}}(8) {{EX:LOG_LOCAL4}} facility). You must have
138 configured OpenLDAP {{EX:--enable-debug}} (the default) for this
139 to work (except for the two statistics levels, which are always
140 enabled).  Log levels are additive. To display what numbers
141 correspond to what kind of debugging, invoke slapd with {{EX:-?}}
142 or consult the table below. The possible values for <integer> are:
143
144 !block table; colaligns="RL"; align=Center; \
145         title="Table 5.1: Debugging Levels"
146 Level   Description
147 -1      enable all debugging
148 0       no debugging
149 1       trace function calls
150 2       debug packet handling
151 4       heavy trace debugging
152 8       connection management
153 16      print out packets sent and received
154 32      search filter processing
155 64      configuration file processing
156 128     access control list processing
157 256     stats log connections/operations/results
158 512     stats log entries sent
159 1024    print communication with shell backends
160 2048    print entry parsing debugging
161 !endblock
162
163 \Example:
164
165 E: loglevel -1
166
167 This will cause lots and lots of debugging information to be
168 logged.
169
170 \Default:
171
172 E: loglevel 256
173
174
175 H4: objectclass <{{REF:RFC2252}} Object Class Description>
176
177 This directive defines an object class.
178 Please see the {{SECT:Schema Specification}} chapter for
179 information regarding how to use this directive.
180
181
182 H4: referral <URI>
183
184 This directive specifies the referral to pass back when slapd
185 cannot find a local database to handle a request.
186
187 \Example:
188
189 >       referral ldap://root.openldap.org
190
191 This will refer non-local queries to the global root LDAP server
192 at the OpenLDAP Project. Smart LDAP clients can re-ask their
193 query at that server, but note that most of these clients are
194 only going to know how to handle simple LDAP URLs that
195 contain a host part and optionally a distinguished name part.
196
197
198 H4: sizelimit <integer>
199
200 This directive specifies the maximum number of entries to return
201 from a search operation.
202
203 \Default:
204
205 >       sizelimit 500
206
207
208 H4: timelimit <integer>
209
210 This directive specifies the maximum number of seconds (in real
211 time) slapd will spend answering a search request. If a
212 request is not finished in this time, a result indicating an
213 exceeded timelimit will be returned.
214
215 \Default:
216
217 >       timelimit 3600
218
219
220 H3: General Backend Directives
221
222 Directives in this section apply only to the backend in which
223 they are defined. They are supported by every type of backend.
224 Backend directives apply to all databases instances of the
225 same type and, depending on the directive, may be overridden
226 by database directives.
227
228 H4: backend <type>
229
230 This directive marks the beginning of a backend declaration.
231 {{EX:<type>}} should be one of the
232 supported backend types listed in Table 5.2.
233
234 !block table; align=Center; coltags="EX,N"; \
235         title="Table 5.2: Database Backends"
236 Types   Description
237 bdb     Berkeley DB transactional backend
238 dnssrv  DNS SRV backend
239 ldap    Lightweight Directory Access Protocol (Proxy) backend
240 ldbm    Lightweight DBM backend
241 meta    Meta Directory backend
242 monitor Monitor backend
243 passwd  Provides read-only access to {{passwd}}(5)
244 perl    Perl Programmable backend
245 shell   Shell (extern program) backend
246 sql     SQL Programmable backend
247 !endblock
248
249 \Example:
250
251 >       backend bdb
252
253 This marks the beginning of a new {{TERM:BDB}} backend
254 definition.
255
256
257 H3: General Database Directives
258
259 Directives in this section apply only to the database in which
260 they are defined. They are supported by every type of database.
261
262 H4: database <type>
263
264 This directive marks the beginning of a database instance
265 declaration.
266 {{EX:<type>}} should be one of the
267 supported backend types listed in Table 5.2.
268
269 \Example:
270
271 >       database bdb
272
273 This marks the beginning of a new {{TERM:BDB}} database instance
274 declaration.
275
276
277 H4: readonly { on | off }
278
279 This directive puts the database into "read-only" mode. Any
280 attempts to modify the database will return an "unwilling to
281 perform" error.
282
283 \Default:
284
285 >       readonly off
286
287 H4: replica
288
289 >       replica uri=ldap[s]://<hostname>[:<port>] | host=<hostname>[:<port>]
290 >               [bindmethod={simple|kerberos|sasl}]
291 >               ["binddn=<DN>"]
292 >               [saslmech=<mech>]
293 >               [authcid=<identity>]
294 >               [authzid=<identity>]
295 >               [credentials=<password>]
296 >               [srvtab=<filename>]
297
298 This directive specifies a replication site for this database. The
299 {{EX:uri=}} parameter specifies a scheme, a host and optionally a port where
300 the slave slapd instance can be found. Either a domain name
301 or IP address may be used for <hostname>. If <port> is not
302 given, the standard LDAP port number (389 or 636) is used.
303
304 {{EX:host}} is deprecated in favor of the {{EX:uri}} parameter.
305
306 {{EX:uri}} allows the replica LDAP server to be specified as an LDAP 
307 URI such as {{EX:ldap://slave.example.com:389}} or
308 {{EX:ldaps://slave.example.com:636}}.
309
310 The {{EX:binddn=}} parameter gives the DN to bind as for updates
311 to the slave slapd. It should be a DN which has read/write access
312 to the slave slapd's database.  It must also match the {{EX:updatedn}}
313 directive in the slave slapd's config file.  Generally, this DN
314 {{should not}} be the same as the {{EX:rootdn}}.  Since DNs are
315 likely to contain embedded spaces, the entire {{EX:"binddn=<DN>"}}
316 string should be enclosed in double quotes.
317
318 The {{EX:bindmethod}} is {{EX:simple}} or {{EX:kerberos}} or {{EX:sasl}},
319 depending on whether simple password-based authentication or Kerberos
320 authentication or {{TERM:SASL}} authentication is to be used when connecting
321 to the slave slapd.
322
323 Simple authentication should not be used unless adequate integrity
324 and privacy protections are in place (e.g. TLS or IPSEC).  Simple
325 authentication requires specification of {{EX:binddn}} and
326 {{EX:credentials}} parameters.
327
328 Kerberos authentication is deprecated in favor of SASL authentication
329 mechanisms, in particular the {{EX:KERBEROS_V4}} and {{EX:GSSAPI}}
330 mechanisms.  Kerberos authentication requires {{EX:binddn}} and
331 {{EX:srvtab}} parameters.
332
333 SASL authentication is generally recommended.  SASL authentication
334 requires specification of a mechanism using the {{EX:saslmech}} parameter.
335 Depending on the mechanism, an authentication identity and/or
336 credentials can be specified using {{EX:authcid}} and {{EX:credentials}}
337 respectively.  The {{EX:authzid}} parameter may be used to specify
338 an authorization identity.
339
340 See the chapter entitled {{SECT:Replication with slurpd}} for more
341 information on how to use this directive.
342
343
344 H4: replogfile <filename>
345
346 This directive specifies the name of the replication log file to
347 which slapd will log changes. The replication log is typically
348 written by slapd and read by slurpd. Normally, this directive is
349 only used if slurpd is being used to replicate the database.
350 However, you can also use it to generate a transaction log, if
351 slurpd is not running. In this case, you will need to periodically
352 truncate the file, since it will grow indefinitely otherwise.
353
354 See the chapter entitled {{SECT:Replication with slurpd}} for more
355 information on how to use this directive.
356
357
358 H4: rootdn <DN>
359
360 This directive specifies the DN that is not subject to
361 access control or administrative limit restrictions for
362 operations on this database.  The DN need not refer to
363 an entry in this database or even in the directory. The
364 DN may refer to a SASL identity.
365
366 Entry-based Example:
367
368 >       rootdn "cn=Manager,dc=example,dc=com"
369
370 SASL-based Example:
371
372 >       rootdn "uid=root,cn=example.com,cn=digest-md5,cn=auth"
373
374 See the {{SECT:SASL Authentication}} section for information on
375 SASL authentication identities.
376
377
378 H4: rootpw <password>
379
380 This directive can be used to specifies a password for the DN for
381 the rootdn (when the rootdn is set to a DN within the database).
382
383 \Example:
384
385 >       rootpw secret
386
387 It is also permissible to provide hash of the password in RFC 2307
388 form.  {{slappasswd}}(8) may be used to generate the password hash.
389
390 \Example:
391
392 >       rootpw {SSHA}ZKKuqbEKJfKSXhUbHG3fG8MDn9j1v4QN
393
394 The hash was generated using the command {{EX:slappasswd -s secret}}.
395
396
397 H4: suffix <dn suffix>
398
399 This directive specifies the DN suffix of queries that will be
400 passed to this backend database. Multiple suffix lines can be
401 given, and at least one is required for each database
402 definition.
403
404 \Example:
405
406 >       suffix "dc=example,dc=com"
407
408 Queries with a DN ending in "dc=example,dc=com"
409 will be passed to this backend.
410
411 Note: When the backend to pass a query to is selected, slapd
412 looks at the suffix line(s) in each database definition in the
413 order they appear in the file. Thus, if one database suffix is a
414 prefix of another, it must appear after it in the config file.
415
416
417 H4: syncrepl
418
419 >       syncrepl rid=<replica ID>
420 >               provider=ldap[s]://<hostname>[:port]
421 >               [type=refreshOnly|refreshAndPersist]
422 >               [interval=dd:hh:mm:ss]
423 >               [searchbase=<base DN>]
424 >               [filter=<filter str>]
425 >               [scope=sub|one|base]
426 >               [attrs=<attr list>]
427 >               [attrsonly]
428 >               [sizelimit=<limit>]
429 >               [timelimit=<limit>]
430 >               [schemachecking=on|off]
431 >               [updatedn=<DN>]
432 >               [bindmethod=simple|sasl]
433 >               [binddn=<DN>]
434 >               [saslmech=<mech>]
435 >               [authcid=<identity>]
436 >               [authzid=<identity>]
437 >               [credentials=<passwd>]
438 >               [realm=<realm>]
439 >               [secprops=<properties>]
440
441
442 This directive specifies the current database as a replica of the
443 master content by establishing the current {{slapd}}(8) as a
444 replication consumer site running a syncrepl replication engine.
445 The master database is located at the replication provider site
446 specified by the {{EX:provider}} parameter. The replica database is
447 kept up-to-date with the master content using the LDAP Content
448 Synchronization protocol. See {{EX:draft-zeilenga-ldup-sync-xx.txt}}
449 ({{a work in progress}}) for more information on the protocol.
450
451 The {{EX:rid}} parameter is used for identification of the current
452 {{EX:syncrepl}} directive within the replication consumer site,
453 where {{EX:<replica ID>}} uniquely identifies the syncrepl specification
454 described by the current {{EX:syncrepl}} directive. {{EX:<replica ID>}}
455 is non-negative and is no more than three digits in length.
456
457 The {{EX:provider}} parameter specifies the replication provider site
458 containing the master content as an LDAP URI. The {{EX:provider}}
459 parameter specifies a scheme, a host and optionally a port where the
460 provider slapd instance can be found. Either a domain name or IP
461 address may be used for <hostname>. Examples are
462 {{EX:ldap://provider.example.com:389}} or {{EX:ldaps://192.168.1.1:636}}.
463 If <port> is not given, the standard LDAP port number (389 or 636) is used.
464 Note that the syncrepl uses a consumer-initiated protocol, and hence its
465 specification is located at the consumer site, whereas the {{EX:replica}}
466 specification is located at the provider site. {{EX:syncrepl}} and
467 {{EX:replica}} directives define two independent replication
468 mechanisms. They do not represent the replication peers of each other.
469
470 The content of the syncrepl replica is defined using a search
471 specification as its result set. The consumer slapd will
472 send search requests to the provider slapd according to the search
473 specification. The search specification includes {{EX:searchbase}},
474 {{EX:scope}}, {{EX:filter}}, {{EX:attrs}}, {{EX:attrsonly}},
475 {{EX:sizelimit}}, and {{EX:timelimit}} parameters as in the normal
476 search specification. The syncrepl search specification has
477 the same value syntax and the same default values as in the
478 {{ldapsearch}}(1) client search tool.
479
480 The LDAP Content Synchronization protocol has two operation
481 types: {{EX:refreshOnly}} and {{EX:refreshAndPersist}}.
482 The operation type is specified by the {{EX:type}} parameter.
483 In the {{EX:refreshOnly}} operation, the next synchronization search operation
484 is periodically rescheduled at an interval time after each
485 synchronization operation finishes. The interval is specified
486 by the {{EX:interval}} parameter. It is set to one day by default.
487 In the {{EX:refreshAndPersist}} operation, a synchronization search
488 remains persistent in the provider slapd. Further updates to the
489 master replica will generate {{EX:searchResultEntry}} to the consumer slapd
490 as the search responses to the persistent synchronization search.
491
492 The schema checking can be enforced at the LDAP Sync consumer site
493 by turning on the {{EX:schemachecking}} parameter.
494 If it is turned on, every replicated entry will be checked for its
495 schema as the entry is stored into the replica content.
496 Every entry in the replica should contain those attributes
497 required by the schema definition.
498 If it is turned off, entries will be stored without checking
499 schema conformance. The default is off.
500
501 The {{EX:updatedn}} parameter specifies the DN in the consumer site
502 which is allowed to make changes to the replica. This DN is used
503 locally by the syncrepl engine when updating the replica with the
504 entries received from the provider site by using the internal
505 operation mechanism. The update of the replica content is subject
506 to the access control privileges of the DN.  The DN should have
507 read/write access to the replica database.  Generally, this DN
508 {{should not}} be the same as {{EX:rootdn}}.
509
510 The {{EX:binddn}} parameter gives the DN to bind as for the
511 syncrepl searches to the provider slapd. It should be a DN
512 which has read access to the replication content in the
513 master database. 
514
515 The {{EX:bindmethod}} is {{EX:simple}} or {{EX:sasl}},
516 depending on whether simple password-based authentication or
517 {{TERM:SASL}} authentication is to be used when connecting
518 to the provider slapd.
519
520 Simple authentication should not be used unless adequate integrity
521 and privacy protections are in place (e.g. TLS or IPSEC). Simple
522 authentication requires specification of {{EX:binddn}} and
523 {{EX:credentials}} parameters.
524
525 SASL authentication is generally recommended.  SASL authentication
526 requires specification of a mechanism using the {{EX:saslmech}} parameter.
527 Depending on the mechanism, an authentication identity and/or
528 credentials can be specified using {{EX:authcid}} and {{EX:credentials}},
529 respectively.  The {{EX:authzid}} parameter may be used to specify
530 an authorization identity.
531
532 The {{EX:realm}} parameter specifies a realm which a certain
533 mechanisms authenticate the identity within. The {{EX:secprops}}
534 parameter specifies Cyrus SASL security properties.
535
536 The syncrepl replication mechanism is supported by the
537 three native backends: back-bdb, back-hdb, and back-ldbm.
538
539 See the {{SECT:LDAP Sync Replication}} chapter of the admin guide
540 for more information on how to use this directive.
541
542
543 H4: updatedn <DN>
544
545 This directive is only applicable in a slave slapd. It specifies
546 the DN allowed to make changes to the replica.  This may be the DN
547 {{slurpd}}(8) binds as when making changes to the replica or the DN
548 associated with a SASL identity.
549
550 Entry-based Example:
551
552 >       updatedn "cn=Update Daemon,dc=example,dc=com"
553
554 SASL-based Example:
555
556 >       updatedn "uid=slurpd,cn=example.com,cn=digest-md5,cn=auth"
557
558 See the {{SECT:Replication with slurpd}} chapter for more information
559 on how to use this directive.
560
561 H4: updateref <URL>
562
563 This directive is only applicable in a slave slapd. It
564 specifies the URL to return to clients which submit update
565 requests upon the replica.
566 If specified multiple times, each {{TERM:URL}} is provided.
567
568 \Example:
569
570 >       updateref       ldap://master.example.net
571
572
573 H3: BDB Database Directives
574
575 Directives in this category only apply to a {{TERM:BDB}} database.
576 That is, they must follow a "database bdb" line and come before any
577 subsequent "backend" or "database" line.  For a complete reference
578 of BDB configuration directives, see {{slapd-bdb}}(5).
579
580
581 H4: directory <directory>
582
583 This directive specifies the directory where the BDB files
584 containing the database and associated indices live.
585
586 \Default:
587
588 >       directory /usr/local/var/openldap-data
589
590
591 H4: sessionlog <sid> <limit>
592
593 This directive specifies a session log store in the syncrepl 
594 replication provider site which contains information on
595 the entries that have been scoped out of the content of the
596 replication session identified by {{EX:<sid>}}.
597 The first syncrepl search request having the same sid value in the
598 cookie establishes the session log store in the provider site.
599 The number of the entries in the session log store is limited
600 by {{EX:<limit>}}. Excessive entries are removed from the store
601 in the FIFO order. Both {{EX:<sid>}} and {{EX:<limit>}} are
602 non-negative integers. {{EX:<sid>}} has no more than three digits.
603
604 The LDAP Content Synchronization operation that falls into a pre-existing
605 session uses the session log store in order to reduce the amount
606 of synchronization traffic. If the replica is not so outdated that
607 it can be made up-to-date by the information in the session store,
608 the provider slapd will send the consumer slapd the identities of the
609 scoped-out entries together with the in-scope entries added to or
610 modified within the replication content. If the replica status is
611 beyond the coverage of the history store, then the provider slapd will
612 send the identities of the unchanged in-scope entries along with the
613 changed in-scope entries. The consumer slapd will then remove those
614 entries in the replica which are not identified as present in the
615 master content.
616
617 An access control mechanism is to be further provided to
618 make the session joining controllable.
619
620
621 H3: LDBM Database Directives
622
623 Directives in this category only apply to a {{TERM:LDBM}} database.
624 That is, they must follow a "database ldbm" line and come before
625 any subsequent "backend" or "database" line.  For a complete reference
626 of LDBM configuration directives, see {{slapd-ldbm}}(5).
627
628 H4: cachesize <integer>
629
630 This directive specifies the size in entries of the in-memory
631 cache maintained by the LDBM backend database instance.
632
633 \Default:
634
635 >       cachesize 1000
636
637
638 H4: dbcachesize <integer>
639
640 This directive specifies the size in bytes of the in-memory cache
641 associated with each open index file. If not supported by the
642 underlying database method, this directive is ignored without
643 comment. Increasing this number uses more memory but can
644 cause a dramatic performance increase, especially during
645 modifies or when building indices.
646
647 \Default:
648
649 >       dbcachesize 100000
650
651
652 H4: dbnolocking
653
654 This option, if present, disables database locking.
655 Enabling this option may improve performance at the expense
656 of data security.
657
658
659 H4: dbnosync
660
661 This option causes on-disk database contents to not be immediately
662 synchronized with in memory changes upon change.  Enabling this option
663 may improve performance at the expense of data integrity.
664
665
666 H4: directory <directory>
667
668 This directive specifies the directory where the LDBM files
669 containing the database and associated indices live.
670
671 \Default:
672
673 >       directory /usr/local/var/openldap-data
674
675
676 H4: index {<attrlist> | default} [pres,eq,approx,sub,none]
677
678 This directive specifies the indices to maintain for the given
679 attribute. If only an {{EX:<attrlist>}} is given, the default
680 indices are maintained.
681
682 \Example:
683
684 >       index default pres,eq
685 >       index uid
686 >       index cn,sn pres,eq,sub
687 >       index objectClass eq
688
689 The first line sets the default set of indices to maintain to
690 present and equality.  The second line causes the default (pres,eq)
691 set of indices to be maintained for the {{EX:uid}} attribute type.
692 The third line causes present, equality, and substring indices to
693 be maintained for {{EX:cn}} and {{EX:sn}} attribute types.  The
694 fourth line causes an equality index for the {{EX:objectClass}}
695 attribute type.
696
697 By default, no indices are maintained.  It is generally advised
698 that minimally an equality index upon objectClass be maintained.
699
700 >       index objectClass eq
701
702
703
704 H4: mode <integer>
705
706 This directive specifies the file protection mode that newly
707 created database index files should have.
708
709 \Default:
710
711 >       mode 0600
712
713
714 H2: Access Control
715
716 Access to slapd entries and attributes is controlled by the
717 access configuration file directive. The general form of an
718 access line is:
719
720 >       <access directive> ::= access to <what>
721 >               [by <who> <access> <control>]+
722 >       <what> ::= * |
723 >               [dn[.<basic-style>]=<regex> | dn.<scope-style>=<DN>]
724 >               [filter=<ldapfilter>] [attrs=<attrlist>]
725 >       <basic-style> ::= regex | exact
726 >       <scope-style> ::= base | one | subtree | children
727 >       <attrlist> ::= <attr> [val[.<basic-style>]=<regex>] | <attr> , <attrlist>
728 >       <attr> ::= <attrname> | entry | children
729 >       <who> ::= * | [anonymous | users | self
730 >                       | dn[.<basic-style>]=<regex> | dn.<scope-style>=<DN>] 
731 >               [dnattr=<attrname>]
732 >               [group[/<objectclass>[/<attrname>][.<basic-style>]]=<regex>]
733 >               [peername[.<basic-style>]=<regex>]
734 >               [sockname[.<basic-style>]=<regex>]
735 >               [domain[.<basic-style>]=<regex>]
736 >               [sockurl[.<basic-style>]=<regex>]
737 >               [set=<setspec>]
738 >               [aci=<attrname>]
739 >       <access> ::= [self]{<level>|<priv>}
740 >       <level> ::= none | auth | compare | search | read | write
741 >       <priv> ::= {=|+|-}{w|r|s|c|x}+
742 >       <control> ::= [stop | continue | break]
743
744 where the <what> part selects the entries and/or attributes to which
745 the access applies, the {{EX:<who>}} part specifies which entities
746 are granted access, and the {{EX:<access>}} part specifies the
747 access granted. Multiple {{EX:<who> <access> <control>}} triplets
748 are supported, allowing many entities to be granted different access
749 to the same set of entries and attributes. Not all of these access
750 control options are described here; for more details see the
751 {{slapd.access}}(5) man page.
752
753
754 H3: What to control access to
755
756 The <what> part of an access specification determines the entries
757 and attributes to which the access control applies.  Entries are
758 commonly selected in two ways: by DN and by filter.  The following
759 qualifiers select entries by DN:
760
761 >       to *
762 >       to dn[.<basic-style>]=<regex>
763 >       to dn.<scope-style>=<DN>
764
765 The first form is used to select all entries.  The second form may
766 be used to select entries by matching a regular expression against
767 the target entry's {{normalized DN}}.   (The second form is not
768 discussed further in this document.)  The third form is used to
769 select entries which are within the requested scope of DN.  The
770 <DN> is a string representation of the Distinguished Name, as
771 described in {{REF:RFC2253}}.
772
773 The scope can be either {{EX:base}}, {{EX:one}}, {{EX:subtree}},
774 or {{EX:children}}.  Where {{EX:base}} matches only the entry with
775 provided DN, {{EX:one}} matches the entries whose parent is the
776 provided DN, {{EX:subtree}} matches all entries in the subtree whose
777 root is the provided DN, and {{EX:children}} matches all entries
778 under the DN (but not the entry named by the DN).
779
780 For example, if the directory contained entries named:
781
782 >       0: o=suffix
783 >       1: cn=Manager,o=suffix
784 >       2: ou=people,o=suffix
785 >       3: uid=kdz,ou=people,o=suffix
786 >       4: cn=addresses,uid=kdz,ou=people,o=suffix
787 >       5: uid=hyc,ou=people,o=suffix
788
789 \Then:
790 . {{EX:dn.base="ou=people,o=suffix"}} match 2;
791 . {{EX:dn.one="ou=people,o=suffix"}} match 3, and 5;
792 . {{EX:dn.subtree="ou=people,o=suffix"}} match 2, 3, 4, and 5; and
793 . {{EX:dn.children="ou=people,o=suffix"}} match 3, 4, and 5.
794
795
796 Entries may also be selected using a filter:
797
798 >       to filter=<ldap filter>
799
800 where <ldap filter> is a string representation of an LDAP
801 search filter, as described in {{REF:RFC2254}}.  For example:
802
803 >       to filter=(objectClass=person)
804
805 Note that entries may be selected by both DN and filter by
806 including both qualifiers in the <what> clause.
807
808 >       to dn.one="ou=people,o=suffix" filter=(objectClass=person)
809
810 Attributes within an entry are selected by including a comma-separated
811 list of attribute names in the <what> selector:
812
813 >       attrs=<attribute list>
814
815 A specific value of an attribute is selected by using a single
816 attribute name and also using a value selector:
817
818 >       attrs=<attribute> val[.<style>]=<regex>
819
820 There are two special {{pseudo}} attributes {{EX:entry}} and
821 {{EX:children}}.  To read (and hence return) a target entry, the
822 subject must have {{EX:read}} access to the target's {{entry}}
823 attribute.  To add or delete an entry, the subject must have
824 {{EX:write}} access to the entry's {{EX:entry}} attribute AND must
825 have {{EX:write}} access to the entry's parent's {{EX:children}}
826 attribute.  To rename an entry, the subject must have {{EX:write}}
827 access to entry's {{EX:entry}} attribute AND have {{EX:write}}
828 access to both the old parent's and new parent's {{EX:children}}
829 attributes.  The complete examples at the end of this section should
830 help clear things up.
831
832 Lastly, there is a special entry selector {{EX:"*"}} that is used to
833 select any entry.  It is used when no other {{EX:<what>}}
834 selector has been provided.  It's equivalent to "{{EX:dn=.*}}"
835
836
837 H3: Who to grant access to
838
839 The <who> part identifies the entity or entities being granted
840 access. Note that access is granted to "entities" not "entries."
841 The following table summarizes entity specifiers:
842
843 !block table; align=Center; coltags="EX,N"; \
844         title="Table 5.3: Access Entity Specifiers"
845 Specifier|Entities
846 *|All, including anonymous and authenticated users
847 anonymous|Anonymous (non-authenticated) users
848 users|Authenticated users
849 self|User associated with target entry
850 dn[.<basic-style>]=<regex>|Users matching a regular expression
851 dn.<scope-style>=<DN>|Users within scope of a DN
852 !endblock
853
854 The DN specifier behaves much like <what> clause DN specifiers.
855
856 Other control factors are also supported.  For example, a {{EX:<who>}}
857 can be restricted by an entry listed in a DN-valued attribute in
858 the entry to which the access applies:
859
860 >       dnattr=<dn-valued attribute name>
861
862 The dnattr specification is used to give access to an entry
863 whose DN is listed in an attribute of the entry (e.g., give
864 access to a group entry to whoever is listed as the owner of
865 the group entry).
866
867 Some factors may not be appropriate in all environments (or any).
868 For example, the domain factor relies on IP to domain name lookups.
869 As these can easily spoofed, the domain factor should not be avoided.
870
871
872 H3: The access to grant
873
874
875 The kind of <access> granted can be one of the following:
876
877
878 !block table; colaligns="LRL"; coltags="EX,EX,N"; align=Center; \
879         title="Table 5.4: Access Levels"
880 Level   Privileges      Description
881 none                    no access
882 auth    =x              needed to bind
883 compare =cx             needed to compare
884 search  =scx            needed to apply search filters
885 read    =rscx           needed to read search results
886 write   =wrscx          needed to modify/rename
887 !endblock
888
889 Each level implies all lower levels of access. So, for
890 example, granting someone {{EX:write}} access to an entry also
891 grants them {{EX:read}}, {{EX:search}}, {{EX:compare}}, and 
892 {{EX:auth}} access.  However, one may use the privileges specifier
893 to grant specific permissions.
894
895
896 H3: Access Control Evaluation
897
898 When evaluating whether some requester should be given access to
899 an entry and/or attribute, slapd compares the entry and/or attribute
900 to the {{EX:<what>}} selectors given in the configuration file.
901 For each entry, access controls provided in the database which holds
902 the entry (or the first database if not held in any database) apply
903 first, followed by the global access directives.  Within this
904 priority, access directives are examined in the order in which they
905 appear in the config file.  Slapd stops with the first {{EX:<what>}}
906 selector that matches the entry and/or attribute. The corresponding
907 access directive is the one slapd will use to evaluate access.
908
909 Next, slapd compares the entity requesting access to the {{EX:<who>}}
910 selectors within the access directive selected above in the order
911 in which they appear. It stops with the first {{EX:<who>}} selector
912 that matches the requester. This determines the access the entity
913 requesting access has to the entry and/or attribute.
914
915 Finally, slapd compares the access granted in the selected
916 {{EX:<access>}} clause to the access requested by the client. If
917 it allows greater or equal access, access is granted. Otherwise,
918 access is denied.
919
920 The order of evaluation of access directives makes their placement
921 in the configuration file important. If one access directive is
922 more specific than another in terms of the entries it selects, it
923 should appear first in the config file. Similarly, if one {{EX:<who>}}
924 selector is more specific than another it should come first in the
925 access directive. The access control examples given below should
926 help make this clear.
927
928
929
930 H3: Access Control Examples
931
932 The access control facility described above is quite powerful.
933 This section shows some examples of its use. First, some
934 simple examples:
935
936 >       access to * by * read
937
938 This access directive grants read access to everyone.
939
940 >       access to *
941 >               by self write
942 >               by anonymous auth
943 >               by * read
944
945 This directive allows the user to modify their entry, allows anonymous
946 to authentication against these entries, and allows all others to
947 read these entries.  Note that only the first {{EX:by <who>}} clause
948 which matches applies.  Hence, the anonymous users are granted
949 {{EX:auth}}, not {{EX:read}}.  The last clause could just as well
950 have been "{{EX:by users read}}".
951
952 It is often desirable to restrict operations based upon the level
953 of protection in place.  The following shows how security strength
954 factors (SSF) can be used.
955
956 >       access to *
957 >               by ssf=128 self write
958 >               by ssf=64 anonymous auth
959 >               by ssf=64 users read
960
961 This directive allows users to modify their own entries if security
962 protections have of strength 128 or better have been established,
963 allows authentication access to anonymous users, and read access
964 when 64 or better security protections have been established.  If
965 client has not establish sufficient security protections, the
966 implicit {{EX:by * none}} clause would be applied.
967
968 The following example shows the use of a style specifiers
969 to select the entries by DN in two access directives where
970 ordering is significant.
971
972 >       access to dn.children="dc=example,dc=com"
973 >               by * search
974 >       access to dn.children="dc=com"
975 >               by * read
976
977 Read access is granted to entries under the {{EX:dc=com}} subtree,
978 except for those entries under the {{EX:dc=example,dc=com}} subtree,
979 to which search access is granted.  No access is granted to
980 {{EX:dc=com}} as neither access directive matches this DN.  If the
981 order of these access directives was reversed, the trailing directive
982 would never be reached, since all entries under {{EX:dc=example,dc=com}}
983 are also under {{EX:dc=com}} entries.
984
985 Also note that if no {{EX:access to}} directive matches or no {{EX:by
986 <who>}} clause, {{B:access is denied}}.  That is, every {{EX:access
987 to}} directive ends with an implicit {{EX:by * none}} clause and
988 every access list ends with an implicit {{EX:access to * by * none}}
989 directive.
990
991 The next example again shows the importance of ordering, both of
992 the access directives and the {{EX:by <who>}} clauses.  It also
993 shows the use of an attribute selector to grant access to a specific
994 attribute and various {{EX:<who>}} selectors.
995
996 >       access to dn.subtree="dc=example,dc=com" attr=homePhone
997 >               by self write
998 >               by dn.children=dc=example,dc=com" search
999 >               by peername=IP:10\..+ read
1000 >       access to dn.subtree="dc=example,dc=com"
1001 >               by self write
1002 >               by dn.children="dc=example,dc=com" search
1003 >               by anonymous auth
1004
1005 This example applies to entries in the "{{EX:dc=example,dc=com}}"
1006 subtree. To all attributes except {{EX:homePhone}}, an entry can
1007 write to itself, entries under {{EX:example.com}} entries can search
1008 by them, anybody else has no access (implicit {{EX:by * none}})
1009 excepting for authentication/authorization (which is always done
1010 anonymously).  The {{EX:homePhone}} attribute is writable by the
1011 entry, searchable by entries under {{EX:example.com}}, readable by
1012 clients connecting from network 10, and otherwise not readable
1013 (implicit {{EX:by * none}}).  All other access is denied by the
1014 implicit {{EX:access to * by * none}}.
1015
1016 Sometimes it is useful to permit a particular DN to add or
1017 remove itself from an attribute. For example, if you would like to
1018 create a group and allow people to add and remove only
1019 their own DN from the member attribute, you could accomplish
1020 it with an access directive like this:
1021
1022 >       access to attr=member,entry
1023 >               by dnattr=member selfwrite
1024
1025 The dnattr {{EX:<who>}} selector says that the access applies to
1026 entries listed in the {{EX:member}} attribute. The {{EX:selfwrite}} access
1027 selector says that such members can only add or delete their
1028 own DN from the attribute, not other values. The addition of
1029 the entry attribute is required because access to the entry is
1030 required to access any of the entry's attributes.
1031
1032 !if 0
1033 For more details on how to use the {{EX:access}} directive,
1034 consult the {{Advanced Access Control}} chapter.
1035 !endif
1036
1037
1038 H2: Configuration File Example
1039
1040 The following is an example configuration file, interspersed
1041 with explanatory text. It defines two databases to handle
1042 different parts of the {{TERM:X.500}} tree; both are {{TERM:BDB}}
1043 database instances. The line numbers shown are provided for
1044 reference only and are not included in the actual file. First, the
1045 global configuration section:
1046
1047 E:  1.  # example config file - global configuration section
1048 E:  2.  include /usr/local/etc/schema/core.schema
1049 E:  3.  referral ldap://root.openldap.org
1050 E:  4.  access to * by * read
1051  
1052 Line 1 is a comment. Line 2 includes another config file
1053 which contains {{core}} schema definitions.
1054 The {{EX:referral}} directive on line 3
1055 means that queries not local to one of the databases defined
1056 below will be referred to the LDAP server running on the
1057 standard port (389) at the host {{EX:root.openldap.org}}.
1058
1059 Line 4 is a global access control.  It applies to all
1060 entries (after any applicable database-specific access
1061 controls).
1062
1063 The next section of the configuration file defines a BDB
1064 backend that will handle queries for things in the
1065 "dc=example,dc=com" portion of the tree. The
1066 database is to be replicated to two slave slapds, one on
1067 truelies, the other on judgmentday. Indices are to be
1068 maintained for several attributes, and the {{EX:userPassword}}
1069 attribute is to be protected from unauthorized access.
1070
1071 E:  5.  # BDB definition for the example.com
1072 E:  6.  database bdb
1073 E:  7.  suffix "dc=example,dc=com"
1074 E:  8.  directory /usr/local/var/openldap-data
1075 E:  9.  rootdn "cn=Manager,dc=example,dc=com"
1076 E: 10.  rootpw secret
1077 E: 11.  # replication directives
1078 E: 12.  replogfile /usr/local/var/openldap/slapd.replog
1079 E: 13.  replica uri=ldap://slave1.example.com:389
1080 E: 14.          binddn="cn=Replicator,dc=example,dc=com"
1081 E: 15.          bindmethod=simple credentials=secret
1082 E: 16.  replica uri=ldaps://slave2.example.com:636
1083 E: 17.          binddn="cn=Replicator,dc=example,dc=com"
1084 E: 18.          bindmethod=simple credentials=secret
1085 E: 19.  # indexed attribute definitions
1086 E: 20.  index uid pres,eq
1087 E: 21.  index cn,sn,uid pres,eq,approx,sub
1088 E: 22.  index objectClass eq
1089 E: 23.  # database access control definitions
1090 E: 24.  access to attr=userPassword
1091 E: 25.          by self write
1092 E: 26.          by anonymous auth
1093 E: 27.          by dn.base="cn=Admin,dc=example,dc=com" write
1094 E: 28.          by * none
1095 E: 29.  access to *
1096 E: 30.          by self write
1097 E: 31.          by dn.base="cn=Admin,dc=example,dc=com" write
1098 E: 32.          by * read
1099
1100 Line 5 is a comment. The start of the database definition is marked
1101 by the database keyword on line 6. Line 7 specifies the DN suffix
1102 for queries to pass to this database. Line 8 specifies the directory
1103 in which the database files will live.
1104
1105 Lines 9 and 10 identify the database {{super-user}} entry and associated
1106 password. This entry is not subject to access control or size or
1107 time limit restrictions.
1108
1109 Lines 11 through 18 are for replication. Line 12 specifies the
1110 replication log file (where changes to the database are logged -
1111 this file is written by slapd and read by slurpd). Lines 13 through
1112 15 specify the hostname and port for a replicated host, the DN to
1113 bind as when performing updates, the bind method (simple) and the
1114 credentials (password) for the binddn. Lines 16 through 18 specify
1115 a second replication site.  See the {{SECT:Replication with slurpd}}
1116 chapter for more information on these directives.
1117
1118 Lines 20 through 22 indicate the indices to maintain for various
1119 attributes.
1120
1121 Lines 24 through 32 specify access control for entries in this
1122 database.  As this is the first database, the controls also apply
1123 to entries not held in any database (such as the Root DSE).  For
1124 all applicable entries, the {{EX:userPassword}} attribute is writable
1125 by the entry itself and by the "admin" entry.  It may be used for
1126 authentication/authorization purposes, but is otherwise not readable.
1127 All other attributes are writable by the entry and the "admin"
1128 entry, but may be read by all users (authenticated or not).
1129
1130 The next section of the example configuration file defines another
1131 BDB database. This one handles queries involving the
1132 {{EX:dc=example,dc=net}} subtree but is managed by the same entity
1133 as the first database.  Note that without line 39, the read access
1134 would be allowed due to the global access rule at line 4.
1135
1136 E: 33.  # BDB definition for example.net
1137 E: 34.  database bdb
1138 E: 35.  suffix "dc=example,dc=net"
1139 E: 36.  directory /usr/local/var/openldap-data-net
1140 E: 37.  rootdn "cn=Manager,dc=example,dc=com"
1141 E: 38.  index objectClass eq
1142 E: 39.  access to * by users read