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