]> git.sur5r.net Git - openldap/blob - doc/guide/admin/slapdconfig.sdf
Sync with HEAD
[openldap] / doc / guide / admin / slapdconfig.sdf
1 # $OpenLDAP$
2 # Copyright 1999-2005, 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 hdb     Hierarchical variant of bdb backend
240 ldap    Lightweight Directory Access Protocol (Proxy) backend
241 ldbm    Lightweight DBM backend
242 meta    Meta Directory backend
243 monitor Monitor backend
244 passwd  Provides read-only access to {{passwd}}(5)
245 perl    Perl Programmable backend
246 shell   Shell (extern program) backend
247 sql     SQL Programmable backend
248 !endblock
249
250 \Example:
251
252 >       backend bdb
253
254 This marks the beginning of a new {{TERM:BDB}} backend
255 definition.
256
257
258 H3: General Database Directives
259
260 Directives in this section apply only to the database in which
261 they are defined. They are supported by every type of database.
262
263 H4: database <type>
264
265 This directive marks the beginning of a database instance
266 declaration.
267 {{EX:<type>}} should be one of the
268 supported backend types listed in Table 5.2.
269
270 \Example:
271
272 >       database bdb
273
274 This marks the beginning of a new {{TERM:BDB}} database instance
275 declaration.
276
277
278 H4: readonly { on | off }
279
280 This directive puts the database into "read-only" mode. Any
281 attempts to modify the database will return an "unwilling to
282 perform" error.
283
284 \Default:
285
286 >       readonly off
287
288 H4: replica
289
290 >       replica uri=ldap[s]://<hostname>[:<port>] | host=<hostname>[:<port>]
291 >               [bindmethod={simple|sasl}]
292 >               ["binddn=<DN>"]
293 >               [saslmech=<mech>]
294 >               [authcid=<identity>]
295 >               [authzid=<identity>]
296 >               [credentials=<password>]
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}} of the master
315 database.  Since DNs are likely to contain embedded spaces, the
316 entire {{EX:"binddn=<DN>"}} string should be enclosed in double
317 quotes.
318
319 The {{EX:bindmethod}} is {{EX:simple}} or {{EX:sasl}}, depending
320 on whether simple password-based authentication or {{TERM:SASL}}
321 authentication is to be used when connecting to the slave slapd.
322
323 Simple authentication should not be used unless adequate data
324 integrity and confidentiality protections are in place (e.g. TLS
325 or IPSEC).  Simple authentication requires specification of
326 {{EX:binddn}} and {{EX:credentials}} parameters.
327
328 SASL authentication is generally recommended.  SASL authentication
329 requires specification of a mechanism using the {{EX:saslmech}} parameter.
330 Depending on the mechanism, an authentication identity and/or
331 credentials can be specified using {{EX:authcid}} and {{EX:credentials}}
332 respectively.  The {{EX:authzid}} parameter may be used to specify
333 an authorization identity.
334
335 See the chapter entitled {{SECT:Replication with slurpd}} for more
336 information on how to use this directive.
337
338
339 H4: replogfile <filename>
340
341 This directive specifies the name of the replication log file to
342 which slapd will log changes. The replication log is typically
343 written by slapd and read by slurpd. Normally, this directive is
344 only used if slurpd is being used to replicate the database.
345 However, you can also use it to generate a transaction log, if
346 slurpd is not running. In this case, you will need to periodically
347 truncate the file, since it will grow indefinitely otherwise.
348
349 See the chapter entitled {{SECT:Replication with slurpd}} for more
350 information on how to use this directive.
351
352
353 H4: rootdn <DN>
354
355 This directive specifies the DN that is not subject to
356 access control or administrative limit restrictions for
357 operations on this database.  The DN need not refer to
358 an entry in this database or even in the directory. The
359 DN may refer to a SASL identity.
360
361 Entry-based Example:
362
363 >       rootdn "cn=Manager,dc=example,dc=com"
364
365 SASL-based Example:
366
367 >       rootdn "uid=root,cn=example.com,cn=digest-md5,cn=auth"
368
369 See the {{SECT:SASL Authentication}} section for information on
370 SASL authentication identities.
371
372
373 H4: rootpw <password>
374
375 This directive can be used to specifies a password for the DN for
376 the rootdn (when the rootdn is set to a DN within the database).
377
378 \Example:
379
380 >       rootpw secret
381
382 It is also permissible to provide hash of the password in RFC 2307
383 form.  {{slappasswd}}(8) may be used to generate the password hash.
384
385 \Example:
386
387 >       rootpw {SSHA}ZKKuqbEKJfKSXhUbHG3fG8MDn9j1v4QN
388
389 The hash was generated using the command {{EX:slappasswd -s secret}}.
390
391
392 H4: suffix <dn suffix>
393
394 This directive specifies the DN suffix of queries that will be
395 passed to this backend database. Multiple suffix lines can be
396 given, and at least one is required for each database
397 definition.
398
399 \Example:
400
401 >       suffix "dc=example,dc=com"
402
403 Queries with a DN ending in "dc=example,dc=com"
404 will be passed to this backend.
405
406 Note: When the backend to pass a query to is selected, slapd
407 looks at the suffix line(s) in each database definition in the
408 order they appear in the file. Thus, if one database suffix is a
409 prefix of another, it must appear after it in the config file.
410
411
412 H4: syncrepl
413
414 >       syncrepl rid=<replica ID>
415 >               provider=ldap[s]://<hostname>[:port]
416 >               [type=refreshOnly|refreshAndPersist]
417 >               [interval=dd:hh:mm:ss]
418 >               [retry=[<retry interval> <# of retries>]+]
419 >               [searchbase=<base DN>]
420 >               [filter=<filter str>]
421 >               [scope=sub|one|base]
422 >               [attrs=<attr list>]
423 >               [attrsonly]
424 >               [sizelimit=<limit>]
425 >               [timelimit=<limit>]
426 >               [schemachecking=on|off]
427 >               [bindmethod=simple|sasl]
428 >               [binddn=<DN>]
429 >               [saslmech=<mech>]
430 >               [authcid=<identity>]
431 >               [authzid=<identity>]
432 >               [credentials=<passwd>]
433 >               [realm=<realm>]
434 >               [secprops=<properties>]
435
436
437 This directive specifies the current database as a replica of the
438 master content by establishing the current {{slapd}}(8) as a
439 replication consumer site running a syncrepl replication engine.
440 The master database is located at the replication provider site
441 specified by the {{EX:provider}} parameter. The replica database is
442 kept up-to-date with the master content using the LDAP Content
443 Synchronization protocol. See {{EX:draft-zeilenga-ldup-sync-xx.txt}}
444 ({{a work in progress}}) for more information on the protocol.
445
446 The {{EX:rid}} parameter is used for identification of the current
447 {{EX:syncrepl}} directive within the replication consumer server,
448 where {{EX:<replica ID>}} uniquely identifies the syncrepl specification
449 described by the current {{EX:syncrepl}} directive. {{EX:<replica ID>}}
450 is non-negative and is no more than three decimal digits in length.
451
452 The {{EX:provider}} parameter specifies the replication provider site
453 containing the master content as an LDAP URI. The {{EX:provider}}
454 parameter specifies a scheme, a host and optionally a port where the
455 provider slapd instance can be found. Either a domain name or IP
456 address may be used for <hostname>. Examples are
457 {{EX:ldap://provider.example.com:389}} or {{EX:ldaps://192.168.1.1:636}}.
458 If <port> is not given, the standard LDAP port number (389 or 636) is used.
459 Note that the syncrepl uses a consumer-initiated protocol, and hence its
460 specification is located at the consumer site, whereas the {{EX:replica}}
461 specification is located at the provider site. {{EX:syncrepl}} and
462 {{EX:replica}} directives define two independent replication
463 mechanisms. They do not represent the replication peers of each other.
464
465 The content of the syncrepl replica is defined using a search
466 specification as its result set. The consumer slapd will
467 send search requests to the provider slapd according to the search
468 specification. The search specification includes {{EX:searchbase}},
469 {{EX:scope}}, {{EX:filter}}, {{EX:attrs}}, {{EX:attrsonly}},
470 {{EX:sizelimit}}, and {{EX:timelimit}} parameters as in the normal
471 search specification. The syncrepl search specification has
472 the same value syntax and the same default values as in the
473 {{ldapsearch}}(1) client search tool.
474
475 The LDAP Content Synchronization protocol has two operation
476 types: {{EX:refreshOnly}} and {{EX:refreshAndPersist}}.
477 The operation type is specified by the {{EX:type}} parameter.
478 In the {{EX:refreshOnly}} operation, the next synchronization search operation
479 is periodically rescheduled at an interval time after each
480 synchronization operation finishes. The interval is specified
481 by the {{EX:interval}} parameter. It is set to one day by default.
482 In the {{EX:refreshAndPersist}} operation, a synchronization search
483 remains persistent in the provider slapd. Further updates to the
484 master replica will generate {{EX:searchResultEntry}} to the consumer slapd
485 as the search responses to the persistent synchronization search.
486
487 If an error occurs during replication, the consumer will attempt to reconnect
488 according to the retry parameter which is a list of the <retry interval>
489 and <# of retries> pairs. For example, retry="60 10 300 3" lets the consumer
490 retry every 60 seconds for the first 10 times and then retry every 300 seconds
491 for the next three times before stop retrying. + in <#  of retries> means
492 indefinite number of retries until success.
493
494 The schema checking can be enforced at the LDAP Sync consumer site
495 by turning on the {{EX:schemachecking}} parameter.
496 If it is turned on, every replicated entry will be checked for its
497 schema as the entry is stored into the replica content.
498 Every entry in the replica should contain those attributes
499 required by the schema definition.
500 If it is turned off, entries will be stored without checking
501 schema conformance. The default is off.
502
503 The {{EX:binddn}} parameter gives the DN to bind as for the
504 syncrepl searches to the provider slapd. It should be a DN
505 which has read access to the replication content in the
506 master database. 
507
508 The {{EX:bindmethod}} is {{EX:simple}} or {{EX:sasl}},
509 depending on whether simple password-based authentication or
510 {{TERM:SASL}} authentication is to be used when connecting
511 to the provider slapd.
512
513 Simple authentication should not be used unless adequate data
514 integrity and confidentiality protections are in place (e.g. TLS
515 or IPSEC). Simple authentication requires specification of {{EX:binddn}}
516 and {{EX:credentials}} parameters.
517
518 SASL authentication is generally recommended.  SASL authentication
519 requires specification of a mechanism using the {{EX:saslmech}} parameter.
520 Depending on the mechanism, an authentication identity and/or
521 credentials can be specified using {{EX:authcid}} and {{EX:credentials}},
522 respectively.  The {{EX:authzid}} parameter may be used to specify
523 an authorization identity.
524
525 The {{EX:realm}} parameter specifies a realm which a certain
526 mechanisms authenticate the identity within. The {{EX:secprops}}
527 parameter specifies Cyrus SASL security properties.
528
529 The syncrepl replication mechanism is supported by the
530 three native backends: back-bdb, back-hdb, and back-ldbm.
531
532 See the {{SECT:LDAP Sync Replication}} chapter of the admin guide
533 for more information on how to use this directive.
534
535
536 H4: updatedn <DN>
537
538 This directive is only applicable in a slave slapd. It specifies
539 the DN allowed to make changes to the replica.  This may be the DN
540 {{slurpd}}(8) binds as when making changes to the replica or the DN
541 associated with a SASL identity.
542
543 Entry-based Example:
544
545 >       updatedn "cn=Update Daemon,dc=example,dc=com"
546
547 SASL-based Example:
548
549 >       updatedn "uid=slurpd,cn=example.com,cn=digest-md5,cn=auth"
550
551 See the {{SECT:Replication with slurpd}} chapter for more information
552 on how to use this directive.
553
554 H4: updateref <URL>
555
556 This directive is only applicable in a slave slapd. It
557 specifies the URL to return to clients which submit update
558 requests upon the replica.
559 If specified multiple times, each {{TERM:URL}} is provided.
560
561 \Example:
562
563 >       updateref       ldap://master.example.net
564
565
566 H3: BDB and HDB Database Directives
567
568 Directives in this category only apply to both the {{TERM:BDB}}
569 and the {{TERM:HDB}} database.
570 That is, they must follow a "database bdb" or "database hdb" line
571 and come before any
572 subsequent "backend" or "database" line.  For a complete reference
573 of BDB/HDB configuration directives, see {{slapd-bdb}}(5).
574
575
576 H4: directory <directory>
577
578 This directive specifies the directory where the BDB files
579 containing the database and associated indices live.
580
581 \Default:
582
583 >       directory /usr/local/var/openldap-data
584
585
586 H3: LDBM Database Directives
587
588 Directives in this category only apply to a {{TERM:LDBM}} database.
589 That is, they must follow a "database ldbm" line and come before
590 any subsequent "backend" or "database" line.  For a complete reference
591 of LDBM configuration directives, see {{slapd-ldbm}}(5).
592
593 H4: cachesize <integer>
594
595 This directive specifies the size in entries of the in-memory
596 cache maintained by the LDBM backend database instance.
597
598 \Default:
599
600 >       cachesize 1000
601
602
603 H4: dbcachesize <integer>
604
605 This directive specifies the size in bytes of the in-memory cache
606 associated with each open index file. If not supported by the
607 underlying database method, this directive is ignored without
608 comment. Increasing this number uses more memory but can
609 cause a dramatic performance increase, especially during
610 modifies or when building indices.
611
612 \Default:
613
614 >       dbcachesize 100000
615
616
617 H4: dbnolocking
618
619 This option, if present, disables database locking.
620 Enabling this option may improve performance at the expense
621 of data security.
622
623
624 H4: dbnosync
625
626 This option causes on-disk database contents to not be immediately
627 synchronized with in memory changes upon change.  Enabling this option
628 may improve performance at the expense of data integrity.
629
630
631 H4: directory <directory>
632
633 This directive specifies the directory where the LDBM files
634 containing the database and associated indices live.
635
636 \Default:
637
638 >       directory /usr/local/var/openldap-data
639
640
641 H4: index {<attrlist> | default} [pres,eq,approx,sub,none]
642
643 This directive specifies the indices to maintain for the given
644 attribute. If only an {{EX:<attrlist>}} is given, the default
645 indices are maintained.
646
647 \Example:
648
649 >       index default pres,eq
650 >       index uid
651 >       index cn,sn pres,eq,sub
652 >       index objectClass eq
653
654 The first line sets the default set of indices to maintain to
655 present and equality.  The second line causes the default (pres,eq)
656 set of indices to be maintained for the {{EX:uid}} attribute type.
657 The third line causes present, equality, and substring indices to
658 be maintained for {{EX:cn}} and {{EX:sn}} attribute types.  The
659 fourth line causes an equality index for the {{EX:objectClass}}
660 attribute type.
661
662 By default, no indices are maintained.  It is generally advised
663 that minimally an equality index upon objectClass be maintained.
664
665 >       index objectClass eq
666
667
668
669 H4: mode <integer>
670
671 This directive specifies the file protection mode that newly
672 created database index files should have.
673
674 \Default:
675
676 >       mode 0600
677
678
679 H2: Access Control
680
681 Access to slapd entries and attributes is controlled by the
682 access configuration file directive. The general form of an
683 access line is:
684
685 >       <access directive> ::= access to <what>
686 >               [by <who> <access> <control>]+
687 >       <what> ::= * |
688 >               [dn[.<basic-style>]=<regex> | dn.<scope-style>=<DN>]
689 >               [filter=<ldapfilter>] [attrs=<attrlist>]
690 >       <basic-style> ::= regex | exact
691 >       <scope-style> ::= base | one | subtree | children
692 >       <attrlist> ::= <attr> [val[.<basic-style>]=<regex>] | <attr> , <attrlist>
693 >       <attr> ::= <attrname> | entry | children
694 >       <who> ::= * | [anonymous | users | self
695 >                       | dn[.<basic-style>]=<regex> | dn.<scope-style>=<DN>] 
696 >               [dnattr=<attrname>]
697 >               [group[/<objectclass>[/<attrname>][.<basic-style>]]=<regex>]
698 >               [peername[.<basic-style>]=<regex>]
699 >               [sockname[.<basic-style>]=<regex>]
700 >               [domain[.<basic-style>]=<regex>]
701 >               [sockurl[.<basic-style>]=<regex>]
702 >               [set=<setspec>]
703 >               [aci=<attrname>]
704 >       <access> ::= [self]{<level>|<priv>}
705 >       <level> ::= none | auth | compare | search | read | write
706 >       <priv> ::= {=|+|-}{w|r|s|c|x|0}+
707 >       <control> ::= [stop | continue | break]
708
709 where the <what> part selects the entries and/or attributes to which
710 the access applies, the {{EX:<who>}} part specifies which entities
711 are granted access, and the {{EX:<access>}} part specifies the
712 access granted. Multiple {{EX:<who> <access> <control>}} triplets
713 are supported, allowing many entities to be granted different access
714 to the same set of entries and attributes. Not all of these access
715 control options are described here; for more details see the
716 {{slapd.access}}(5) man page.
717
718
719 H3: What to control access to
720
721 The <what> part of an access specification determines the entries
722 and attributes to which the access control applies.  Entries are
723 commonly selected in two ways: by DN and by filter.  The following
724 qualifiers select entries by DN:
725
726 >       to *
727 >       to dn[.<basic-style>]=<regex>
728 >       to dn.<scope-style>=<DN>
729
730 The first form is used to select all entries.  The second form may
731 be used to select entries by matching a regular expression against
732 the target entry's {{normalized DN}}.   (The second form is not
733 discussed further in this document.)  The third form is used to
734 select entries which are within the requested scope of DN.  The
735 <DN> is a string representation of the Distinguished Name, as
736 described in {{REF:RFC2253}}.
737
738 The scope can be either {{EX:base}}, {{EX:one}}, {{EX:subtree}},
739 or {{EX:children}}.  Where {{EX:base}} matches only the entry with
740 provided DN, {{EX:one}} matches the entries whose parent is the
741 provided DN, {{EX:subtree}} matches all entries in the subtree whose
742 root is the provided DN, and {{EX:children}} matches all entries
743 under the DN (but not the entry named by the DN).
744
745 For example, if the directory contained entries named:
746
747 >       0: o=suffix
748 >       1: cn=Manager,o=suffix
749 >       2: ou=people,o=suffix
750 >       3: uid=kdz,ou=people,o=suffix
751 >       4: cn=addresses,uid=kdz,ou=people,o=suffix
752 >       5: uid=hyc,ou=people,o=suffix
753
754 \Then:
755 . {{EX:dn.base="ou=people,o=suffix"}} match 2;
756 . {{EX:dn.one="ou=people,o=suffix"}} match 3, and 5;
757 . {{EX:dn.subtree="ou=people,o=suffix"}} match 2, 3, 4, and 5; and
758 . {{EX:dn.children="ou=people,o=suffix"}} match 3, 4, and 5.
759
760
761 Entries may also be selected using a filter:
762
763 >       to filter=<ldap filter>
764
765 where <ldap filter> is a string representation of an LDAP
766 search filter, as described in {{REF:RFC2254}}.  For example:
767
768 >       to filter=(objectClass=person)
769
770 Note that entries may be selected by both DN and filter by
771 including both qualifiers in the <what> clause.
772
773 >       to dn.one="ou=people,o=suffix" filter=(objectClass=person)
774
775 Attributes within an entry are selected by including a comma-separated
776 list of attribute names in the <what> selector:
777
778 >       attrs=<attribute list>
779
780 A specific value of an attribute is selected by using a single
781 attribute name and also using a value selector:
782
783 >       attrs=<attribute> val[.<style>]=<regex>
784
785 There are two special {{pseudo}} attributes {{EX:entry}} and
786 {{EX:children}}.  To read (and hence return) a target entry, the
787 subject must have {{EX:read}} access to the target's {{entry}}
788 attribute.  To add or delete an entry, the subject must have
789 {{EX:write}} access to the entry's {{EX:entry}} attribute AND must
790 have {{EX:write}} access to the entry's parent's {{EX:children}}
791 attribute.  To rename an entry, the subject must have {{EX:write}}
792 access to entry's {{EX:entry}} attribute AND have {{EX:write}}
793 access to both the old parent's and new parent's {{EX:children}}
794 attributes.  The complete examples at the end of this section should
795 help clear things up.
796
797 Lastly, there is a special entry selector {{EX:"*"}} that is used to
798 select any entry.  It is used when no other {{EX:<what>}}
799 selector has been provided.  It's equivalent to "{{EX:dn=.*}}"
800
801
802 H3: Who to grant access to
803
804 The <who> part identifies the entity or entities being granted
805 access. Note that access is granted to "entities" not "entries."
806 The following table summarizes entity specifiers:
807
808 !block table; align=Center; coltags="EX,N"; \
809         title="Table 5.3: Access Entity Specifiers"
810 Specifier|Entities
811 *|All, including anonymous and authenticated users
812 anonymous|Anonymous (non-authenticated) users
813 users|Authenticated users
814 self|User associated with target entry
815 dn[.<basic-style>]=<regex>|Users matching a regular expression
816 dn.<scope-style>=<DN>|Users within scope of a DN
817 !endblock
818
819 The DN specifier behaves much like <what> clause DN specifiers.
820
821 Other control factors are also supported.  For example, a {{EX:<who>}}
822 can be restricted by an entry listed in a DN-valued attribute in
823 the entry to which the access applies:
824
825 >       dnattr=<dn-valued attribute name>
826
827 The dnattr specification is used to give access to an entry
828 whose DN is listed in an attribute of the entry (e.g., give
829 access to a group entry to whoever is listed as the owner of
830 the group entry).
831
832 Some factors may not be appropriate in all environments (or any).
833 For example, the domain factor relies on IP to domain name lookups.
834 As these can easily spoofed, the domain factor should not be avoided.
835
836
837 H3: The access to grant
838
839
840 The kind of <access> granted can be one of the following:
841
842
843 !block table; colaligns="LRL"; coltags="EX,EX,N"; align=Center; \
844         title="Table 5.4: Access Levels"
845 Level   Privileges      Description
846 none    =0              no access
847 auth    =x              needed to bind
848 compare =cx             needed to compare
849 search  =scx            needed to apply search filters
850 read    =rscx           needed to read search results
851 write   =wrscx          needed to modify/rename
852 !endblock
853
854 Each level implies all lower levels of access. So, for
855 example, granting someone {{EX:write}} access to an entry also
856 grants them {{EX:read}}, {{EX:search}}, {{EX:compare}}, and 
857 {{EX:auth}} access.  However, one may use the privileges specifier
858 to grant specific permissions.
859
860
861 H3: Access Control Evaluation
862
863 When evaluating whether some requester should be given access to
864 an entry and/or attribute, slapd compares the entry and/or attribute
865 to the {{EX:<what>}} selectors given in the configuration file.
866 For each entry, access controls provided in the database which holds
867 the entry (or the first database if not held in any database) apply
868 first, followed by the global access directives.  Within this
869 priority, access directives are examined in the order in which they
870 appear in the config file.  Slapd stops with the first {{EX:<what>}}
871 selector that matches the entry and/or attribute. The corresponding
872 access directive is the one slapd will use to evaluate access.
873
874 Next, slapd compares the entity requesting access to the {{EX:<who>}}
875 selectors within the access directive selected above in the order
876 in which they appear. It stops with the first {{EX:<who>}} selector
877 that matches the requester. This determines the access the entity
878 requesting access has to the entry and/or attribute.
879
880 Finally, slapd compares the access granted in the selected
881 {{EX:<access>}} clause to the access requested by the client. If
882 it allows greater or equal access, access is granted. Otherwise,
883 access is denied.
884
885 The order of evaluation of access directives makes their placement
886 in the configuration file important. If one access directive is
887 more specific than another in terms of the entries it selects, it
888 should appear first in the config file. Similarly, if one {{EX:<who>}}
889 selector is more specific than another it should come first in the
890 access directive. The access control examples given below should
891 help make this clear.
892
893
894
895 H3: Access Control Examples
896
897 The access control facility described above is quite powerful.  This
898 section shows some examples of its use for descriptive purposes.
899
900 A simple example:
901
902 >       access to * by * read
903
904 This access directive grants read access to everyone.
905
906 >       access to *
907 >               by self write
908 >               by anonymous auth
909 >               by * read
910
911 This directive allows the user to modify their entry, allows anonymous
912 to authentication against these entries, and allows all others to
913 read these entries.  Note that only the first {{EX:by <who>}} clause
914 which matches applies.  Hence, the anonymous users are granted
915 {{EX:auth}}, not {{EX:read}}.  The last clause could just as well
916 have been "{{EX:by users read}}".
917
918 It is often desirable to restrict operations based upon the level
919 of protection in place.  The following shows how security strength
920 factors (SSF) can be used.
921
922 >       access to *
923 >               by ssf=128 self write
924 >               by ssf=64 anonymous auth
925 >               by ssf=64 users read
926
927 This directive allows users to modify their own entries if security
928 protections have of strength 128 or better have been established,
929 allows authentication access to anonymous users, and read access
930 when 64 or better security protections have been established.  If
931 client has not establish sufficient security protections, the
932 implicit {{EX:by * none}} clause would be applied.
933
934 The following example shows the use of a style specifiers to select
935 the entries by DN in two access directives where ordering is
936 significant.
937
938 >       access to dn.children="dc=example,dc=com"
939 >               by * search
940 >       access to dn.children="dc=com"
941 >               by * read
942
943 Read access is granted to entries under the {{EX:dc=com}} subtree,
944 except for those entries under the {{EX:dc=example,dc=com}} subtree,
945 to which search access is granted.  No access is granted to
946 {{EX:dc=com}} as neither access directive matches this DN.  If the
947 order of these access directives was reversed, the trailing directive
948 would never be reached, since all entries under {{EX:dc=example,dc=com}}
949 are also under {{EX:dc=com}} entries.
950
951 Also note that if no {{EX:access to}} directive matches or no {{EX:by
952 <who>}} clause, {{B:access is denied}}.  That is, every {{EX:access
953 to}} directive ends with an implicit {{EX:by * none}} clause and
954 every access list ends with an implicit {{EX:access to * by * none}}
955 directive.
956
957 The next example again shows the importance of ordering, both of
958 the access directives and the {{EX:by <who>}} clauses.  It also
959 shows the use of an attribute selector to grant access to a specific
960 attribute and various {{EX:<who>}} selectors.
961
962 >       access to dn.subtree="dc=example,dc=com" attr=homePhone
963 >               by self write
964 >               by dn.children="dc=example,dc=com" search
965 >               by peername.regex=IP:10\..+ read
966 >       access to dn.subtree="dc=example,dc=com"
967 >               by self write
968 >               by dn.children="dc=example,dc=com" search
969 >               by anonymous auth
970
971 This example applies to entries in the "{{EX:dc=example,dc=com}}"
972 subtree. To all attributes except {{EX:homePhone}}, an entry can
973 write to itself, entries under {{EX:example.com}} entries can search
974 by them, anybody else has no access (implicit {{EX:by * none}})
975 excepting for authentication/authorization (which is always done
976 anonymously).  The {{EX:homePhone}} attribute is writable by the
977 entry, searchable by entries under {{EX:example.com}}, readable by
978 clients connecting from network 10, and otherwise not readable
979 (implicit {{EX:by * none}}).  All other access is denied by the
980 implicit {{EX:access to * by * none}}.
981
982 Sometimes it is useful to permit a particular DN to add or
983 remove itself from an attribute. For example, if you would like to
984 create a group and allow people to add and remove only
985 their own DN from the member attribute, you could accomplish
986 it with an access directive like this:
987
988 >       access to attr=member,entry
989 >               by dnattr=member selfwrite
990
991 The dnattr {{EX:<who>}} selector says that the access applies to
992 entries listed in the {{EX:member}} attribute. The {{EX:selfwrite}} access
993 selector says that such members can only add or delete their
994 own DN from the attribute, not other values. The addition of
995 the entry attribute is required because access to the entry is
996 required to access any of the entry's attributes.
997
998 !if 0
999 For more details on how to use the {{EX:access}} directive,
1000 consult the {{Advanced Access Control}} chapter.
1001 !endif
1002
1003
1004 H2: Configuration File Example
1005
1006 The following is an example configuration file, interspersed
1007 with explanatory text. It defines two databases to handle
1008 different parts of the {{TERM:X.500}} tree; both are {{TERM:BDB}}
1009 database instances. The line numbers shown are provided for
1010 reference only and are not included in the actual file. First, the
1011 global configuration section:
1012
1013 E:  1.  # example config file - global configuration section
1014 E:  2.  include /usr/local/etc/schema/core.schema
1015 E:  3.  referral ldap://root.openldap.org
1016 E:  4.  access to * by * read
1017  
1018 Line 1 is a comment. Line 2 includes another config file
1019 which contains {{core}} schema definitions.
1020 The {{EX:referral}} directive on line 3
1021 means that queries not local to one of the databases defined
1022 below will be referred to the LDAP server running on the
1023 standard port (389) at the host {{EX:root.openldap.org}}.
1024
1025 Line 4 is a global access control.  It applies to all
1026 entries (after any applicable database-specific access
1027 controls).
1028
1029 The next section of the configuration file defines a BDB
1030 backend that will handle queries for things in the
1031 "dc=example,dc=com" portion of the tree. The
1032 database is to be replicated to two slave slapds, one on
1033 truelies, the other on judgmentday. Indices are to be
1034 maintained for several attributes, and the {{EX:userPassword}}
1035 attribute is to be protected from unauthorized access.
1036
1037 E:  5.  # BDB definition for the example.com
1038 E:  6.  database bdb
1039 E:  7.  suffix "dc=example,dc=com"
1040 E:  8.  directory /usr/local/var/openldap-data
1041 E:  9.  rootdn "cn=Manager,dc=example,dc=com"
1042 E: 10.  rootpw secret
1043 E: 11.  # replication directives
1044 E: 12.  replogfile /usr/local/var/openldap/slapd.replog
1045 E: 13.  replica uri=ldap://slave1.example.com:389
1046 E: 14.          binddn="cn=Replicator,dc=example,dc=com"
1047 E: 15.          bindmethod=simple credentials=secret
1048 E: 16.  replica uri=ldaps://slave2.example.com:636
1049 E: 17.          binddn="cn=Replicator,dc=example,dc=com"
1050 E: 18.          bindmethod=simple credentials=secret
1051 E: 19.  # indexed attribute definitions
1052 E: 20.  index uid pres,eq
1053 E: 21.  index cn,sn,uid pres,eq,approx,sub
1054 E: 22.  index objectClass eq
1055 E: 23.  # database access control definitions
1056 E: 24.  access to attr=userPassword
1057 E: 25.          by self write
1058 E: 26.          by anonymous auth
1059 E: 27.          by dn.base="cn=Admin,dc=example,dc=com" write
1060 E: 28.          by * none
1061 E: 29.  access to *
1062 E: 30.          by self write
1063 E: 31.          by dn.base="cn=Admin,dc=example,dc=com" write
1064 E: 32.          by * read
1065
1066 Line 5 is a comment. The start of the database definition is marked
1067 by the database keyword on line 6. Line 7 specifies the DN suffix
1068 for queries to pass to this database. Line 8 specifies the directory
1069 in which the database files will live.
1070
1071 Lines 9 and 10 identify the database {{super-user}} entry and associated
1072 password. This entry is not subject to access control or size or
1073 time limit restrictions.
1074
1075 Lines 11 through 18 are for replication. Line 12 specifies the
1076 replication log file (where changes to the database are logged -
1077 this file is written by slapd and read by slurpd). Lines 13 through
1078 15 specify the hostname and port for a replicated host, the DN to
1079 bind as when performing updates, the bind method (simple) and the
1080 credentials (password) for the binddn. Lines 16 through 18 specify
1081 a second replication site.  See the {{SECT:Replication with slurpd}}
1082 chapter for more information on these directives.
1083
1084 Lines 20 through 22 indicate the indices to maintain for various
1085 attributes.
1086
1087 Lines 24 through 32 specify access control for entries in this
1088 database.  As this is the first database, the controls also apply
1089 to entries not held in any database (such as the Root DSE).  For
1090 all applicable entries, the {{EX:userPassword}} attribute is writable
1091 by the entry itself and by the "admin" entry.  It may be used for
1092 authentication/authorization purposes, but is otherwise not readable.
1093 All other attributes are writable by the entry and the "admin"
1094 entry, but may be read by all users (authenticated or not).
1095
1096 The next section of the example configuration file defines another
1097 BDB database. This one handles queries involving the
1098 {{EX:dc=example,dc=net}} subtree but is managed by the same entity
1099 as the first database.  Note that without line 39, the read access
1100 would be allowed due to the global access rule at line 4.
1101
1102 E: 33.  # BDB definition for example.net
1103 E: 34.  database bdb
1104 E: 35.  suffix "dc=example,dc=net"
1105 E: 36.  directory /usr/local/var/openldap-data-net
1106 E: 37.  rootdn "cn=Manager,dc=example,dc=com"
1107 E: 38.  index objectClass eq
1108 E: 39.  access to * by users read