]> git.sur5r.net Git - openldap/blob - doc/guide/admin/slapdconfig.sdf
de6e8798df2e4ff7769324c2584c85e0adf3e458
[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. 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 {{EX:entry}} attribute AND must
654 have {{EX:write}} access to the entry's parent's {{EX:children}}
655 attribute.  To rename an entry, the subject must have {{EX:write}}
656 access to entry's {{EX:entry}} attribute AND have {{EX:write}}
657 access to both the old parent's and new parent's {{EX:children}}
658 attributes.  The complete examples at the end of this section should
659 help clear things up.
660
661 Lastly, there is a special entry selector {{EX:"*"}} that is used to
662 select any entry.  It is used when no other {{EX:<what>}}
663 selector has been provided.  It's equivalent to "{{EX:dn=.*}}"
664
665
666 H3: Who to grant access to
667
668 The <who> part identifies the entity or entities being granted
669 access. Note that access is granted to "entities" not "entries."
670 The following table summarizes entity specifiers:
671
672 !block table; align=Center; coltags="EX,N"; \
673         title="Table 5.3: Access Entity Specifiers"
674 Specifier|Entities
675 *|All, including anonymous and authenticated users
676 anonymous|Anonymous (non-authenticated) users
677 users|Authenticated users
678 self|User associated with target entry
679 dn[.<basic-style>]=<regex>|Users matching a regular expression
680 dn.<scope-style>=<DN>|Users within scope of a DN
681 !endblock
682
683 The DN specifier behaves much like <what> clause DN specifiers.
684
685 Other control factors are also supported.
686 For example, a {{EX:<who>}} can be restricted by a
687 regular expression matching the client's domain name:
688
689 >       domain=<regular expression>
690
691 or by an entry listed in a DN-valued attribute in the entry to
692 which the access applies:
693
694 >       dnattr=<dn-valued attribute name>
695
696 The dnattr specification is used to give access to an entry
697 whose DN is listed in an attribute of the entry (e.g., give
698 access to a group entry to whoever is listed as the owner of
699 the group entry).
700
701
702 H3: The access to grant
703
704
705 The kind of <access> granted can be one of the following:
706
707
708 !block table; colaligns="LRL"; coltags="EX,EX,N"; align=Center; \
709         title="Table 5.4: Access Levels"
710 Level   Privileges      Description
711 none                    no access
712 auth    =x              needed to bind
713 compare =cx             needed to compare
714 search  =scx            needed to apply search filters
715 read    =rscx           needed to read search results
716 write   =wrscx          needed to modify/rename
717 !endblock
718
719 Each level implies all lower levels of access. So, for
720 example, granting someone {{EX:write}} access to an entry also
721 grants them {{EX:read}}, {{EX:search}}, {{EX:compare}}, and 
722 {{EX:auth}} access.  However, one may use the privileges specifier
723 to grant specific permissions.
724
725
726 H3: Access Control Evaluation
727
728 When evaluating whether some requester should be given access to
729 an entry and/or attribute, slapd compares the entry and/or attribute
730 to the {{EX:<what>}} selectors given in the configuration file.
731 For each entry, access controls provided in the database which holds
732 the entry (or the first database if not held in any database) apply
733 first, followed by the global access directives.  Within this
734 priority, access directives are examined in the order in which they
735 appear in the config file.  Slapd stops with the first {{EX:<what>}}
736 selector that matches the entry and/or attribute. The corresponding
737 access directive is the one slapd will use to evaluate access.
738
739 Next, slapd compares the entity requesting access to the {{EX:<who>}}
740 selectors within the access directive selected above in the order
741 in which they appear. It stops with the first {{EX:<who>}} selector
742 that matches the requester. This determines the access the entity
743 requesting access has to the entry and/or attribute.
744
745 Finally, slapd compares the access granted in the selected
746 {{EX:<access>}} clause to the access requested by the client. If
747 it allows greater or equal access, access is granted. Otherwise,
748 access is denied.
749
750 The order of evaluation of access directives makes their placement
751 in the configuration file important. If one access directive is
752 more specific than another in terms of the entries it selects, it
753 should appear first in the config file. Similarly, if one {{EX:<who>}}
754 selector is more specific than another it should come first in the
755 access directive. The access control examples given below should
756 help make this clear.
757
758
759
760 H3: Access Control Examples
761
762 The access control facility described above is quite powerful.
763 This section shows some examples of its use. First, some
764 simple examples:
765
766 >       access to * by * read
767
768 This access directive grants read access to everyone.
769
770 >       access to *
771 >               by self write
772 >               by anonymous auth
773 >               by * read
774
775 This directive allows users to modify their own entries, allows
776 authenticate, and allows all others to read.  Note that only the
777 first {{EX:by <who>}} clause which matches applies.  Hence, the
778 anonymous users are granted {{EX:auth}}, not {{EX:read}}.  The last
779 clause could just as well have been "{{EX:by users read}}".
780
781 It is often desirable to restrict operations based upon the level
782 of protection in place.  The following shows how security strength
783 factors (SSF) can be used.
784
785 >       access to *
786 >               by ssf=128 self write
787 >               by ssf=64 anonymous auth
788 >               by ssf=64 users read
789
790 This directive allows users to modify their own entries if security
791 protections have of strength 128 or better have been established,
792 allows simple authentication and read access when 64 or better
793 security protections have been established.
794
795 The following example shows the use of a regular expression
796 to select the entries by DN in two access directives where
797 ordering is significant.
798
799 >       access to dn.children="dc=example,dc=com"
800 >               by * search
801 >       access to dn.children="dc=com"
802 >               by * read
803
804 Read access is granted to entries under the {{EX:dc=com}} subtree,
805 except for those entries under the {{EX:dc=example,dc=com}} subtree,
806 to which search access is granted.  No access is granted to
807 {{EX:dc=com}} as neither access directive matches this DN.  If the
808 order of these access directives was reversed, the trailing directive
809 would never be reached, since all entries under {{EX:dc=example,dc=com}}
810 are also under {{EX:dc=com}} entries.
811
812 Also note that if no {{EX:access to}} directive matches or no {{EX:by
813 <who>}} clause, {{B:access is denied}}.  That is, every {{EX:access
814 to}} directive ends with an implicit {{EX:by * none}} clause and
815 every access list ends with an implicit {{EX:access to * by * none}}
816 directive.
817
818 The next example again shows the importance of ordering, both of
819 the access directives and the {{EX:by <who>}} clauses.  It also
820 shows the use of an attribute selector to grant access to a specific
821 attribute and various {{EX:<who>}} selectors.
822
823 >       access to dn.subtree="dc=example,dc=com" attr=homePhone
824 >               by self write
825 >               by dn.children=dc=example,dc=com" search
826 >               by domain=.*\.example\.com read
827 >       access to dn.subtree="dc=example,dc=com"
828 >               by self write
829 >               by dn.children="dc=example,dc=com" search
830 >               by anonymous auth
831
832 This example applies to entries in the "{{EX:dc=example,dc=com}}"
833 subtree. To all attributes except {{EX:homePhone}}, an entry can
834 write to itself, entries under {{EX:example.com}} entries can search
835 by them, anybody else has no access (implicit {{EX:by * none}})
836 excepting for authentication/authorization (which is always done
837 anonymously).  The {{EX:homePhone}} attribute is writable by the
838 entry, searchable by entries under {{EX:example.com}}, readable by
839 clients connecting from somewhere in the {{EX:example.com}} domain,
840 and otherwise not readable (implicit {{EX:by * none}}).  All other
841 access is denied by the implicit {{EX:access to * by * none}}.
842
843 Sometimes it is useful to permit a particular DN to add or
844 remove itself from an attribute. For example, if you would like to
845 create a group and allow people to add and remove only
846 their own DN from the member attribute, you could accomplish
847 it with an access directive like this:
848
849 >       access to attr=member,entry
850 >               by dnattr=member selfwrite
851
852 The dnattr {{EX:<who>}} selector says that the access applies to
853 entries listed in the {{EX:member}} attribute. The {{EX:selfwrite}} access
854 selector says that such members can only add or delete their
855 own DN from the attribute, not other values. The addition of
856 the entry attribute is required because access to the entry is
857 required to access any of the entry's attributes.
858
859 !if 0
860 For more details on how to use the {{EX:access}} directive,
861 consult the {{Advanced Access Control}} chapter.
862 !endif
863
864
865 H2: Configuration File Example
866
867 The following is an example configuration file, interspersed
868 with explanatory text. It defines two databases to handle
869 different parts of the {{TERM:X.500}} tree; both are {{TERM:BDB}}
870 database instances. The line numbers shown are provided for
871 reference only and are not included in the actual file. First, the
872 global configuration section:
873
874 E:  1.  # example config file - global configuration section
875 E:  2.  include /usr/local/etc/schema/core.schema
876 E:  3.  referral ldap://root.openldap.org
877 E:  4.  access to * by * read
878  
879 Line 1 is a comment. Line 2 includes another config file
880 which contains {{core}} schema definitions.
881 The {{EX:referral}} directive on line 3
882 means that queries not local to one of the databases defined
883 below will be referred to the LDAP server running on the
884 standard port (389) at the host {{EX:root.openldap.org}}.
885
886 Line 4 is a global access control.  It applies to all
887 entries (after any applicable database-specific access
888 controls).
889
890 The next section of the configuration file defines a BDB
891 backend that will handle queries for things in the
892 "dc=example,dc=com" portion of the tree. The
893 database is to be replicated to two slave slapds, one on
894 truelies, the other on judgmentday. Indices are to be
895 maintained for several attributes, and the {{EX:userPassword}}
896 attribute is to be protected from unauthorized access.
897
898 E:  5.  # BDB definition for the example.com
899 E:  6.  database bdb
900 E:  7.  suffix "dc=example,dc=com"
901 E:  8.  directory /usr/local/var/openldap-data
902 E:  9.  rootdn "cn=Manager,dc=example,dc=com"
903 E: 10.  rootpw secret
904 E: 11.  # replication directives
905 E: 12.  replogfile /usr/local/var/openldap/slapd.replog
906 E: 13.  replica host=slave1.example.com:389
907 E: 14.          binddn="cn=Replicator,dc=example,dc=com"
908 E: 15.          bindmethod=simple credentials=secret
909 E: 16.  replica host=slave2.example.com
910 E: 17.          binddn="cn=Replicator,dc=example,dc=com"
911 E: 18.          bindmethod=simple credentials=secret
912 E: 19.  # indexed attribute definitions
913 E: 20.  index uid pres,eq
914 E: 21.  index cn,sn,uid pres,eq,approx,sub
915 E: 22.  index objectClass eq
916 E: 23.  # database access control definitions
917 E: 24.  access to attr=userPassword
918 E: 25.          by self write
919 E: 26.          by anonymous auth
920 E: 27.          by dn.base="cn=Admin,dc=example,dc=com" write
921 E: 28.          by * none
922 E: 29.  access to *
923 E: 30.          by self write
924 E: 31.          by dn.base="cn=Admin,dc=example,dc=com" write
925 E: 32.          by * read
926
927 Line 5 is a comment. The start of the database definition is marked
928 by the database keyword on line 6. Line 7 specifies the DN suffix
929 for queries to pass to this database. Line 8 specifies the directory
930 in which the database files will live.
931
932 Lines 9 and 10 identify the database {{super-user}} entry and associated
933 password. This entry is not subject to access control or size or
934 time limit restrictions.
935
936 Lines 11 through 18 are for replication. Line 12 specifies the
937 replication log file (where changes to the database are logged -
938 this file is written by slapd and read by slurpd). Lines 13 through
939 15 specify the hostname and port for a replicated host, the DN to
940 bind as when performing updates, the bind method (simple) and the
941 credentials (password) for the binddn. Lines 16 through 18 specify
942 a second replication site.  See the {{SECT:Replication with slurpd}}
943 chapter for more information on these directives.
944
945 Lines 20 through 22 indicate the indices to maintain for various
946 attributes.
947
948 Lines 24 through 32 specify access control for entries in this
949 database.  As this is the first database, the controls also apply
950 to entries not held in any database (such as the Root DSE).  For
951 all applicable entries, the {{EX:userPassword}} attribute is writable
952 by the entry itself and by the "admin" entry.  It may be used for
953 authentication/authorization purposes, but is otherwise not readable.
954 All other attributes are writable by the entry and the "admin"
955 entry, but may be read by all users (authenticated or not).
956
957 The next section of the example configuration file defines another
958 BDB database. This one handles queries involving the
959 {{EX:dc=example,dc=net}} subtree but is managed by the same entity
960 as the first database.  Note that without line 39, the read access
961 would be allowed due to the global access rule at line 4.
962
963 E: 33.  # BDB definition for example.net
964 E: 34.  database bdb
965 E: 35.  suffix "dc=example,dc=net"
966 E: 36.  directory /usr/local/var/openldap-data-net
967 E: 37.  rootdn "cn=Manager,dc=example,dc=com"
968 E: 38.  index objectClass eq
969 E: 39.  access to * by users read