]> git.sur5r.net Git - openldap/blob - doc/guide/admin/overlays.sdf
4bd6af05dbcf7fa929252352c0b6e51cf9ce7a1b
[openldap] / doc / guide / admin / overlays.sdf
1 # $OpenLDAP$
2 # Copyright 2007-2008 The OpenLDAP Foundation, All Rights Reserved.
3 # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
4
5 H1: Overlays
6
7 Overlays are software components that provide hooks to functions analogous to 
8 those provided by backends, which can be stacked on top of the backend calls 
9 and as callbacks on top of backend responses to alter their behavior. 
10
11 Overlays may be compiled statically into {{slapd}}, or when module support
12 is enabled, they may be dynamically loaded. Most of the overlays
13 are only allowed to be configured on individual databases.
14
15 Some can be stacked on the {{EX:frontend}} as well, for global use. This means that
16 they can be executed after a request is parsed and validated, but right before the 
17 appropriate database is selected. The main purpose is to affect operations 
18 regardless of the database they will be handled by, and, in some cases, 
19 to influence the selection of the database by massaging the request DN. 
20
21 Essentially, overlays represent a means to:
22
23     * customize the behavior of existing backends without changing the backend 
24       code and without requiring one to write a new custom backend with 
25       complete functionality
26     * write functionality of general usefulness that can be applied to 
27       different backend types
28
29 When using {{slapd.conf}}(5), overlays that are configured before any other
30 databases are considered global, as mentioned above. In fact they are implicitly
31 stacked on top of the {{EX:frontend}} database. They can also be explicitly
32 configured as such:
33
34 >        database frontend
35 >        overlay <overlay name>
36
37 Overlays are usually documented by separate specific man pages in section 5; 
38 the naming convention is
39
40 >        slapo-<overlay name>
41
42 All distributed core overlays have a man page. Feel free to contribute to any, 
43 if you think there is anything missing in describing the behavior of the component 
44 and the implications of all the related configuration directives.
45
46 Official overlays are located in
47
48 >        servers/slapd/overlays/
49
50 That directory also contains the file slapover.txt, which describes the 
51 rationale of the overlay implementation, and may serve as a guideline for the 
52 development of custom overlays.
53
54 Contribware overlays are located in
55
56 >        contrib/slapd-modules/<overlay name>/
57
58 along with other types of run-time loadable components; they are officially 
59 distributed, but not maintained by the project.
60
61 All the current overlays in OpenLDAP are listed and described in detail in the 
62 following sections.
63
64
65 H2: Access Logging
66
67
68 H3: Overview
69
70 This overlay can record accesses to a given backend database on another
71 database.
72
73 This allows all of the activity on a given database to be reviewed using arbitrary 
74 LDAP queries, instead of just logging to local flat text files. Configuration 
75 options are available for selecting a subset of operation types to log, and to 
76 automatically prune older log records from the logging database. Log records 
77 are stored with audit schema to assure their readability whether viewed as LDIF 
78 or in raw form.
79
80 It is also used for {{SECT:delta-syncrepl replication}}
81
82 H3: Access Logging Configuration
83
84 The following is a basic example that implements Access Logging:
85
86 >        database bdb
87 >        suffix dc=example,dc=com
88 >        ...
89 >        overlay accesslog
90 >        logdb cn=log
91 >        logops writes reads
92 >        logold (objectclass=person)
93 >        
94 >        database bdb
95 >        suffix cn=log
96 >        ...
97 >        index reqStart eq
98 >        access to *
99 >          by dn.base="cn=admin,dc=example,dc=com" read
100
101 The following is an example used for {{SECT:delta-syncrepl replication}}:
102
103 >        database hdb
104 >        suffix cn=accesslog
105 >        directory /usr/local/var/openldap-accesslog
106 >        rootdn cn=accesslog
107 >        index default eq
108 >        index entryCSN,objectClass,reqEnd,reqResult,reqStart
109
110 Accesslog overlay definitions for the primary db
111
112 >        database bdb
113 >        suffix dc=example,dc=com
114 >        ...
115 >        overlay accesslog
116 >        logdb cn=accesslog
117 >        logops writes
118 >        logsuccess TRUE
119 >        # scan the accesslog DB every day, and purge entries older than 7 days
120 >        logpurge 07+00:00 01+00:00
121
122 An example search result against {{B:cn=accesslog}} might look like:
123
124 >        [ghenry@suretec ghenry]# ldapsearch -x -b cn=accesslog
125 >        # extended LDIF
126 >        #
127 >        # LDAPv3
128 >        # base <cn=accesslog> with scope subtree
129 >        # filter: (objectclass=*)
130 >        # requesting: ALL
131 >        #
132 >        
133 >        # accesslog
134 >        dn: cn=accesslog
135 >        objectClass: auditContainer
136 >        cn: accesslog
137 >        
138 >        # 20080110163829.000004Z, accesslog
139 >        dn: reqStart=20080110163829.000004Z,cn=accesslog
140 >        objectClass: auditModify
141 >        reqStart: 20080110163829.000004Z
142 >        reqEnd: 20080110163829.000005Z
143 >        reqType: modify
144 >        reqSession: 196696
145 >        reqAuthzID: cn=admin,dc=suretecsystems,dc=com
146 >        reqDN: uid=suretec-46022f8$,ou=Users,dc=suretecsystems,dc=com
147 >        reqResult: 0
148 >        reqMod: sambaPwdCanChange:- ###CENSORED###
149 >        reqMod: sambaPwdCanChange:+ ###CENSORED###
150 >        reqMod: sambaNTPassword:- ###CENSORED###
151 >        reqMod: sambaNTPassword:+ ###CENSORED###
152 >        reqMod: sambaPwdLastSet:- ###CENSORED###
153 >        reqMod: sambaPwdLastSet:+ ###CENSORED###
154 >        reqMod: entryCSN:= 20080110163829.095157Z#000000#000#000000
155 >        reqMod: modifiersName:= cn=admin,dc=suretecsystems,dc=com
156 >        reqMod: modifyTimestamp:= 20080110163829Z
157 >        
158 >        # search result
159 >        search: 2
160 >        result: 0 Success
161 >        
162 >        # numResponses: 3
163 >        # numEntries: 2
164
165 For more information, please see {{slapo-accesslog(5)}} and the {{SECT:delta-syncrepl replication}} section.
166
167
168 H2: Audit Logging
169
170 The Audit Logging overlay can be used to record all changes on a given backend database to a specified log file.
171
172 H3: Overview
173
174 If the need arises whereby changes need to be logged as standard LDIF, then the auditlog overlay {{B:slapo-auditlog (5)}}
175 can be used. Full examples are available in the man page {{B:slapo-auditlog (5)}}
176
177 H3: Audit Logging Configuration
178
179 If the directory is running vi {{F:slapd.d}}, then the following LDIF could be used to add the overlay to the overlay list 
180 in {{B:cn=config}} and set what file the {{TERM:LDIF}} gets logged to (adjust to suit)
181
182 >       dn: olcOverlay=auditlog,olcDatabase={1}hdb,cn=config
183 >       changetype: add
184 >       objectClass: olcOverlayConfig
185 >       objectClass: olcAuditLogConfig
186 >       olcOverlay: auditlog
187 >       olcAuditlogFile: /tmp/auditlog.ldif
188
189
190 In this example for testing, we are logging changes to {{F:/tmp/auditlog.ldif}}
191
192 A typical {{TERM:LDIF}} file created by {{B:slapo-auditlog (5)}} would look like:
193
194 >       # add 1196797576 dc=suretecsystems,dc=com cn=admin,dc=suretecsystems,dc=com
195 >       dn: dc=suretecsystems,dc=com
196 >       changetype: add
197 >       objectClass: dcObject
198 >       objectClass: organization
199 >       dc: suretecsystems
200 >       o: Suretec Systems Ltd.
201 >       structuralObjectClass: organization
202 >       entryUUID: 1606f8f8-f06e-1029-8289-f0cc9d81e81a
203 >       creatorsName: cn=admin,dc=suretecsystems,dc=com
204 >       modifiersName: cn=admin,dc=suretecsystems,dc=com
205 >       createTimestamp: 20051123130912Z
206 >       modifyTimestamp: 20051123130912Z
207 >       entryCSN: 20051123130912.000000Z#000001#000#000000
208 >       auditContext: cn=accesslog
209 >       # end add 1196797576
210 >       
211 >       # add 1196797577 dc=suretecsystems,dc=com cn=admin,dc=suretecsystems,dc=com
212 >       dn: ou=Groups,dc=suretecsystems,dc=com
213 >       changetype: add
214 >       objectClass: top
215 >       objectClass: organizationalUnit
216 >       ou: Groups
217 >       structuralObjectClass: organizationalUnit
218 >       entryUUID: 160aaa2a-f06e-1029-828a-f0cc9d81e81a
219 >       creatorsName: cn=admin,dc=suretecsystems,dc=com
220 >       modifiersName: cn=admin,dc=suretecsystems,dc=com
221 >       createTimestamp: 20051123130912Z
222 >       modifyTimestamp: 20051123130912Z
223 >       entryCSN: 20051123130912.000000Z#000002#000#000000
224 >       # end add 1196797577
225
226
227 H2: Chaining
228
229
230 H3: Overview
231
232 The chain overlay provides basic chaining capability to the underlying 
233 database.
234
235 What is chaining? It indicates the capability of a DSA to follow referrals on 
236 behalf of the client, so that distributed systems are viewed as a single 
237 virtual DSA by clients that are otherwise unable to "chase" (i.e. follow) 
238 referrals by themselves.
239
240 The chain overlay is built on top of the ldap backend; it is compiled by 
241 default when {{B:--enable-ldap}}.
242
243
244 H3: Chaining Configuration
245
246 In order to demonstrate how this overlay works, we shall discuss a typical 
247 scenario which might be one master server and three Syncrepl slaves. 
248
249 On each replica, add this near the top of the {{slapd.conf}}(5) file
250 (global), before any database definitions:
251
252 >        overlay                    chain
253 >        chain-uri                  "ldap://ldapmaster.example.com"
254 >        chain-idassert-bind        bindmethod="simple"
255 >                                   binddn="cn=Manager,dc=example,dc=com"
256 >                                   credentials="<secret>" 
257 >                                   mode="self"
258 >        chain-tls                  start
259 >        chain-return-error         TRUE 
260
261 Add this below your {{syncrepl}} statement:
262
263 >        updateref                  "ldap://ldapmaster.example.com/"
264
265 The {{B:chain-tls}} statement enables TLS from the slave to the ldap master. 
266 The DITs are exactly the same between these machines, therefore whatever user 
267 bound to the slave will also exist on the master. If that DN does not have 
268 update privileges on the master, nothing will happen.
269
270 You will need to restart the slave after these {{slapd.conf}} changes.
271 Then, if you are using {{loglevel stats}} (256), you can monitor an
272 {{ldapmodify}} on the slave and the master. (If you're using {{cn=config}}
273 no restart is required.)
274
275 Now start an {{ldapmodify}} on the slave and watch the logs. You should expect 
276 something like:
277
278 >        Sep  6 09:27:25 slave1 slapd[29274]: conn=11 fd=31 ACCEPT from IP=143.199.102.216:45181 (IP=143.199.102.216:389)
279 >        Sep  6 09:27:25 slave1 slapd[29274]: conn=11 op=0 STARTTLS
280 >        Sep  6 09:27:25 slave1 slapd[29274]: conn=11 op=0 RESULT oid= err=0 text=
281 >        Sep  6 09:27:25 slave1 slapd[29274]: conn=11 fd=31 TLS established tls_ssf=256 ssf=256
282 >        Sep  6 09:27:28 slave1 slapd[29274]: conn=11 op=1 BIND dn="uid=user1,ou=people,dc=example,dc=com" method=128
283 >        Sep  6 09:27:28 slave1 slapd[29274]: conn=11 op=1 BIND dn="uid=user1,ou=People,dc=example,dc=com" mech=SIMPLE ssf=0
284 >        Sep  6 09:27:28 slave1 slapd[29274]: conn=11 op=1 RESULT tag=97 err=0 text=
285 >        Sep  6 09:27:28 slave1 slapd[29274]: conn=11 op=2 MOD dn="uid=user1,ou=People,dc=example,dc=com"
286 >        Sep  6 09:27:28 slave1 slapd[29274]: conn=11 op=2 MOD attr=mail
287 >        Sep  6 09:27:28 slave1 slapd[29274]: conn=11 op=2 RESULT tag=103 err=0 text=
288 >        Sep  6 09:27:28 slave1 slapd[29274]: conn=11 op=3 UNBIND
289 >        Sep  6 09:27:28 slave1 slapd[29274]: conn=11 fd=31 closed
290 >        Sep  6 09:27:28 slave1 slapd[29274]: syncrepl_entry: LDAP_RES_SEARCH_ENTRY(LDAP_SYNC_MODIFY)
291 >        Sep  6 09:27:28 slave1 slapd[29274]: syncrepl_entry: be_search (0)
292 >        Sep  6 09:27:28 slave1 slapd[29274]: syncrepl_entry: uid=user1,ou=People,dc=example,dc=com
293 >        Sep  6 09:27:28 slave1 slapd[29274]: syncrepl_entry: be_modify (0)
294
295 And on the master you will see this:
296
297 >        Sep  6 09:23:57 ldapmaster slapd[2961]: conn=55902 op=3 PROXYAUTHZ dn="uid=user1,ou=people,dc=example,dc=com"
298 >        Sep  6 09:23:57 ldapmaster slapd[2961]: conn=55902 op=3 MOD dn="uid=user1,ou=People,dc=example,dc=com"
299 >        Sep  6 09:23:57 ldapmaster slapd[2961]: conn=55902 op=3 MOD attr=mail
300 >        Sep  6 09:23:57 ldapmaster slapd[2961]: conn=55902 op=3 RESULT tag=103 err=0 text=
301
302 Note: You can clearly see the PROXYAUTHZ line on the master, indicating the 
303 proper identity assertion for the update on the master. Also note the slave 
304 immediately receiving the Syncrepl update from the master.
305
306 H3: Handling Chaining Errors
307
308 By default, if chaining fails, the original referral is returned to the client
309 under the assumption that the client might want to try and follow the referral.
310
311 With the following directive however, if the chaining fails at the provider 
312 side, the actual error is returned to the client.
313
314 >        chain-return-error TRUE
315
316
317 H2: Constraints
318
319
320 H3: Overview
321
322 This overlay enforces a regular expression constraint on all values
323 of specified attributes during an LDAP modify request that contains add or modify
324 commands. It is used to enforce a more rigorous syntax when the underlying attribute 
325 syntax is too general.
326
327
328 H3: Constraint Configuration
329
330 Configuration via {{slapd.conf}}(5) would look like:
331
332 >        overlay constraint
333 >        constraint_attribute mail regex ^[:alnum:]+@mydomain.com$
334 >        constraint_attribute title uri
335 >        ldap:///dc=catalog,dc=example,dc=com?title?sub?(objectClass=titleCatalog)
336
337 A specification like the above would reject any {{mail}} attribute which did not
338 look like {{<alpha-numeric string>@mydomain.com}}.
339
340 It would also reject any title attribute whose values were not listed in the 
341 title attribute of any {{titleCatalog}} entries in the given scope.   
342
343 An example for use with {{cn=config}}:
344
345 >       dn: olcOverlay=constraint,olcDatabase={1}hdb,cn=config
346 >       changetype: add
347 >       objectClass: olcOverlayConfig
348 >       objectClass: olcConstraintConfig
349 >       olcOverlay: constraint
350 >       olcConstraintAttribute: mail regex ^[:alnum:]+@mydomain.com$
351 >       olcConstraintAttribute: title uri ldap:///dc=catalog,dc=example,dc=com?title?sub?(objectClass=titleCatalog)
352
353    
354 H2: Dynamic Directory Services
355
356
357 H3: Overview
358
359 The {{dds}} overlay to {{slapd}}(8) implements dynamic objects as per {{REF:RFC2589}}.
360 The name {{dds}} stands for Dynamic Directory Services. It allows to define 
361 dynamic objects, characterized by the {{dynamicObject}} objectClass.
362
363 Dynamic objects have a limited lifetime, determined by a time-to-live (TTL) 
364 that can be refreshed by means of a specific refresh extended operation. This 
365 operation allows to set the Client Refresh Period (CRP), namely the period 
366 between refreshes that is required to preserve the dynamic object from expiration. 
367 The expiration time is computed by adding the requested TTL to the current time.
368 When dynamic objects reach the end of their lifetime without being further 
369 refreshed, they are automatically {{deleted}}. There is no guarantee of immediate 
370 deletion, so clients should not count on it.
371
372 H3: Dynamic Directory Service Configuration
373
374 A usage of dynamic objects might be to implement dynamic meetings; in this case, 
375 all the participants to the meeting are allowed to refresh the meeting object, 
376 but only the creator can delete it (otherwise it will be deleted when the TTL expires).
377
378 If we add the overlay to an example database, specifying a Max TTL of 1 day, a 
379 min of 10 seconds, with a default TTL of 1 hour. We'll also specify an interval
380 of 120 (less than 60s might be too small) seconds between expiration checks and a 
381 tolerance of 5 second (lifetime of a dynamic object will be {{entryTtl + tolerance}}).
382
383 >       overlay dds
384 >       dds-max-ttl     1d
385 >       dds-min-ttl     10s
386 >       dds-default-ttl 1h
387 >       dds-interval    120s
388 >       dds-tolerance   5s
389
390 and add an index:
391
392 >       entryExpireTimestamp
393
394 Creating a meeting is as simple as adding the following:
395
396 >       dn: cn=OpenLDAP Documentation Meeting,ou=Meetings,dc=example,dc=com
397 >       objectClass: groupOfNames
398 >       objectClass: dynamicObject
399 >       cn: OpenLDAP Documentation Meeting
400 >       member: uid=ghenry,ou=People,dc=example,dc=com
401 >       member: uid=hyc,ou=People,dc=example,dc=com
402
403 H4: Dynamic Directory Service ACLs
404
405 Allow users to start a meeting and to join it; restrict refresh to the {{member}}; 
406 restrict delete to the creator:
407
408 >       access to attrs=userPassword
409 >          by self write
410 >          by * read
411 >       
412 >       access to dn.base="ou=Meetings,dc=example,dc=com"
413 >                 attrs=children
414 >            by users write
415 >       
416 >       access to dn.onelevel="ou=Meetings,dc=example,dc=com"
417 >                 attrs=entry
418 >            by dnattr=creatorsName write
419 >            by * read
420 >       
421 >       access to dn.onelevel="ou=Meetings,dc=example,dc=com"
422 >                 attrs=participant
423 >            by dnattr=creatorsName write
424 >            by users selfwrite
425 >            by * read
426 >       
427 >       access to dn.onelevel="ou=Meetings,dc=example,dc=com"
428 >                 attrs=entryTtl
429 >            by dnattr=member manage
430 >            by * read
431
432 In simple terms, the user who created the {{OpenLDAP Documentation Meeting}} can add new attendees, 
433 refresh the meeting using (basically complete control):
434
435 >       ldapexop -x -H ldap://ldaphost "refresh" "cn=OpenLDAP Documentation Meeting,ou=Meetings,dc=example,dc=com" "120" -D "uid=ghenry,ou=People,dc=example,dc=com" -W
436
437 Any user can join the meeting, but not add another attendee, but they can refresh the meeting. The ACLs above are quite straight forward to understand.
438
439 H2: Dynamic Groups
440
441
442 H3: Overview
443
444 This overlay extends the Compare operation to detect
445 members of a dynamic group. This overlay is now deprecated
446 as all of its functions are available using the
447 {{SECT:Dynamic Lists}} overlay.
448
449
450 H3: Dynamic Group Configuration
451
452
453 H2: Dynamic Lists
454    
455    
456 H3: Overview
457
458 This overlay allows expansion of dynamic groups and lists. Instead of having the
459 group members or list attributes hard coded, this overlay allows us to define
460 an LDAP search whose results will make up the group or list.
461
462 H3: Dynamic List Configuration
463
464 This module can behave both as a dynamic list and dynamic group, depending on
465 the configuration. The syntax is as follows:
466
467 >       overlay dynlist
468 >       dynlist-attrset <group-oc> <URL-ad> [member-ad]
469
470 The parameters to the {{F:dynlist-attrset}} directive have the following meaning:
471 * {{F:<group-oc>}}: specifies which object class triggers the subsequent LDAP search.
472 Whenever an entry with this object class is retrieved, the search is performed.
473 * {{F:<URL-ad>}}: is the name of the attribute which holds the search URI. It
474 has to be a subtype of {{F:labeledURI}}. The attributes and values present in
475 the search result are added to the entry unless {{F:member-ad}} is used (see
476 below).
477 * {{F:member-ad}}: if present, changes the overlay behavior into a dynamic group.
478 Instead of inserting the results of the search in the entry, the distinguished name
479 of the results are added as values of this attribute.
480
481 Here is an example which will allow us to have an email alias which automatically
482 expands to all user's emails according to our LDAP filter:
483
484 In {{slapd.conf}}(5):
485 >       overlay dynlist
486 >       dynlist-attrset nisMailAlias labeledURI
487
488 This means that whenever an entry which has the {{F:nisMailAlias}} object class is
489 retrieved, the search specified in the {{F:labeledURI}} attribute is performed.
490
491 Let's say we have this entry in our directory:
492 >       cn=all,ou=aliases,dc=example,dc=com
493 >       cn: all
494 >       objectClass: nisMailAlias
495 >       labeledURI: ldap:///ou=People,dc=example,dc=com?mail?one?(objectClass=inetOrgPerson)
496
497 If this entry is retrieved, the search specified in {{F:labeledURI}} will be
498 performed and the results will be added to the entry just as if they have always
499 been there. In this case, the search filter selects all entries directly
500 under {{F:ou=People}} that have the {{F:inetOrgPerson}} object class and retrieves
501 the {{F:mail}} attribute, if it exists.
502
503 This is what gets added to the entry when we have two users under {{F:ou=People}}
504 that match the filter:
505 !import "allmail-en.png"; align="center"; title="Dynamic list for email aliases"
506 FT[align="Center"] Figure X.Y: Dynamic List for all emails
507
508 The configuration for a dynamic group is similar. Let's see an example which would
509 automatically populate an {{F:allusers}} group with all the user accounts in the
510 directory.
511
512 In {{F:slapd.conf}}(5):
513 >       overlay dynlist
514 >       dynlist-attrset groupOfNames labeledURI member
515
516 Let's apply it to the following entry:
517 >       cn=allusers,ou=group,dc=example,dc=com
518 >       cn: all
519 >       objectClass: groupOfNames
520 >       labeledURI: ldap:///ou=people,dc=example,dc=com??one?(objectClass=inetOrgPerson)
521
522 The behavior is similar to the dynamic list configuration we had before:
523 whenever an entry with the {{F:groupOfNames}} object class is retrieved, the
524 search specified in the {{F:labeledURI}} attribute is performed. But this time,
525 only the distinguished names of the results are added, and as values of the
526 {{F:member}} attribute.
527
528 This is what we get:
529 !import "allusersgroup-en.png"; align="center"; title="Dynamic group for all users"
530 FT[align="Center"] Figure X.Y: Dynamic Group for all users
531
532 Note that a side effect of this scheme of dynamic groups is that the members
533 need to be specified as full DNs. So, if you are planning in using this for
534 {{F:posixGroup}}s, be sure to use RFC2307bis and some attribute which can hold
535 distinguished names. The {{F:memberUid}} attribute used in the {{F:posixGroup}}
536 object class can hold only names, not DNs, and is therefore not suitable for
537 dynamic groups.
538
539 H2: Reverse Group Membership Maintenance
540
541 H3: Overview
542
543 In some scenarios, it may be desirable for a client to be able to determine
544 which groups an entry is a member of, without performing an additional search.
545 Examples of this are applications using the {{TERM:DIT}} for access control
546 based on group authorization.
547
548 The {{B:memberof}} overlay updates an attribute (by default {{B:memberOf}}) whenever
549 changes occur to the membership attribute (by default {{B:member}}) of entries of the
550 objectclass (by default {{B:groupOfNames}}) configured to trigger updates.
551
552 Thus, it provides maintenance of the list of groups an entry is a member of,
553 when usual maintenance of groups is done by modifying the members on the group
554 entry.
555
556 H3: Member Of Configuration
557
558 The typical use of this overlay requires just enabling the overlay for a
559 specific database. For example, with the following minimal slapd.conf:
560
561 >        include /usr/share/openldap/schema/core.schema
562 >        include /usr/share/openldap/schema/cosine.schema
563 >        modulepath      /usr/lib/openldap
564 >        moduleload      memberof.la
565 >        authz-regexp "gidNumber=0\\\+uidNumber=0,cn=peercred,cn=external,cn=auth"
566 >                "cn=Manager,dc=example,dc=com"
567 >        database        bdb
568 >        suffix          "dc=example,dc=com"
569 >        rootdn          "cn=Manager,dc=example,dc=com"
570 >        rootpw          secret
571 >        directory       /var/lib/ldap2.4
572 >        checkpoint 256 5
573 >        index   objectClass   eq
574 >        index   uid           eq,sub
575 >        
576 >        overlay memberof
577
578 adding the following ldif:
579
580 >        cat memberof.ldif
581 >        dn: dc=example,dc=com
582 >        objectclass: domain
583 >        dc: example
584 >        
585 >        dn: ou=Group,dc=example,dc=com
586 >        objectclass: organizationalUnit
587 >        ou: Group
588 >        
589 >        dn: ou=People,dc=example,dc=com
590 >        objectclass: organizationalUnit
591 >        ou: People
592 >        
593 >        dn: uid=test1,ou=People,dc=example,dc=com
594 >        objectclass: account
595 >        uid: test1
596 >        
597 >        dn: cn=testgroup,ou=Group,dc=example,dc=com
598 >        objectclass: groupOfNames
599 >        cn: testgroup
600 >        member: uid=test1,ou=People,dc=example,dc=com
601
602 Results in the following output from a search on the test1 user:
603
604 > # ldapsearch -LL -Y EXTERNAL -H ldapi:/// "(uid=test1)" -b dc=example,dc=com memberOf
605 > SASL/EXTERNAL authentication started
606 > SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
607 > SASL SSF: 0
608 > version: 1
609
610 > dn: uid=test1,ou=People,dc=example,dc=com
611 > memberOf: cn=testgroup,ou=Group,dc=example,dc=com
612
613 Note that the {{B:memberOf}} attribute is an operational attribute, so it must be
614 requested explicitly.
615
616
617 H2: The Proxy Cache Engine
618
619 {{TERM:LDAP}} servers typically hold one or more subtrees of a
620 {{TERM:DIT}}. Replica (or shadow) servers hold shadow copies of
621 entries held by one or more master servers.  Changes are propagated
622 from the master server to replica (slave) servers using LDAP Sync
623 replication.  An LDAP cache is a special type of replica which holds
624 entries corresponding to search filters instead of subtrees.
625
626 H3: Overview
627
628 The proxy cache extension of slapd is designed to improve the
629 responsiveness of the ldap and meta backends. It handles a search
630 request (query)
631 by first determining whether it is contained in any cached search
632 filter. Contained requests are answered from the proxy cache's local
633 database. Other requests are passed on to the underlying ldap or
634 meta backend and processed as usual.
635
636 E.g. {{EX:(shoesize>=9)}} is contained in {{EX:(shoesize>=8)}} and
637 {{EX:(sn=Richardson)}} is contained in {{EX:(sn=Richards*)}}
638
639 Correct matching rules and syntaxes are used while comparing
640 assertions for query containment. To simplify the query containment
641 problem, a list of cacheable "templates" (defined below) is specified
642 at configuration time. A query is cached or answered only if it
643 belongs to one of these templates. The entries corresponding to
644 cached queries are stored in the proxy cache local database while
645 its associated meta information (filter, scope, base, attributes)
646 is stored in main memory. 
647
648 A template is a prototype for generating LDAP search requests.
649 Templates are described by a prototype search filter and a list of
650 attributes which are required in queries generated from the template.
651 The representation for prototype filter is similar to {{REF:RFC4515}},
652 except that the assertion values are missing. Examples of prototype
653 filters are: (sn=),(&(sn=)(givenname=)) which are instantiated by
654 search filters (sn=Doe) and (&(sn=Doe)(givenname=John)) respectively.
655
656 The cache replacement policy removes the least recently used (LRU)
657 query and entries belonging to only that query. Queries are allowed
658 a maximum time to live (TTL) in the cache thus providing weak
659 consistency. A background task periodically checks the cache for
660 expired queries and removes them.
661
662 The Proxy Cache paper
663 ({{URL:http://www.openldap.org/pub/kapurva/proxycaching.pdf}}) provides
664 design and implementation details.
665
666
667 H3: Proxy Cache Configuration
668
669 The cache configuration specific directives described below must
670 appear after a {{EX:overlay proxycache}} directive within a
671 {{EX:"database meta"}} or {{EX:database ldap}} section of
672 the server's {{slapd.conf}}(5) file.
673
674 H4: Setting cache parameters
675
676 > proxyCache <DB> <maxentries> <nattrsets> <entrylimit> <period>
677
678 This directive enables proxy caching and sets general cache
679 parameters.  The <DB> parameter specifies which underlying database
680 is to be used to hold cached entries.  It should be set to
681 {{EX:bdb}} or {{EX:hdb}}.  The <maxentries> parameter specifies the
682 total number of entries which may be held in the cache.  The
683 <nattrsets> parameter specifies the total number of attribute sets
684 (as specified by the {{EX:proxyAttrSet}} directive) that may be
685 defined.  The <entrylimit> parameter specifies the maximum number of
686 entries in a cacheable query.  The <period> specifies the consistency
687 check period (in seconds).  In each period, queries with expired
688 TTLs are removed.
689
690 H4: Defining attribute sets
691
692 > proxyAttrset <index> <attrs...>
693
694 Used to associate a set of attributes to an index. Each attribute
695 set is associated with an index number from 0 to <numattrsets>-1.
696 These indices are used by the proxyTemplate directive to define
697 cacheable templates.
698
699 H4: Specifying cacheable templates 
700
701 > proxyTemplate <prototype_string> <attrset_index> <TTL>
702
703 Specifies a cacheable template and the "time to live" (in sec) <TTL>
704 for queries belonging to the template. A template is described by
705 its prototype filter string and set of required attributes identified
706 by <attrset_index>.
707
708
709 H4: Example
710
711 An example {{slapd.conf}}(5) database section for a caching server
712 which proxies for the {{EX:"dc=example,dc=com"}} subtree held
713 at server {{EX:ldap.example.com}}.
714  
715 >       database        ldap
716 >       suffix          "dc=example,dc=com" 
717 >       rootdn          "dc=example,dc=com" 
718 >       uri             ldap://ldap.example.com/
719 >       overlay proxycache
720 >       proxycache    bdb 100000 1 1000 100
721 >       proxyAttrset  0 mail postaladdress telephonenumber 
722 >       proxyTemplate (sn=) 0 3600
723 >       proxyTemplate (&(sn=)(givenName=)) 0 3600
724 >       proxyTemplate (&(departmentNumber=)(secretary=*)) 0 3600
725 >
726 >       cachesize 20
727 >       directory ./testrun/db.2.a
728 >       index       objectClass eq
729 >       index       cn,sn,uid,mail  pres,eq,sub
730
731
732 H5: Cacheable Queries
733
734 A LDAP search query is cacheable when its filter matches one of the
735 templates as defined in the "proxyTemplate" statements and when it references
736 only the attributes specified in the corresponding attribute set. 
737 In the example above the attribute set number 0 defines that only the
738 attributes: {{EX:mail postaladdress telephonenumber}} are cached for the following
739 proxyTemplates.
740
741 H5: Examples:
742
743 >       Filter: (&(sn=Richard*)(givenName=jack)) 
744 >       Attrs: mail telephoneNumber
745
746     is cacheable, because it matches the template {{EX:(&(sn=)(givenName=))}} and its
747     attributes are contained in proxyAttrset 0.
748
749 >       Filter: (&(sn=Richard*)(telephoneNumber))
750 >       Attrs: givenName 
751
752     is not cacheable, because the filter does not match the template,
753     nor is the attribute givenName stored in the cache
754
755 >       Filter: (|(sn=Richard*)(givenName=jack))
756 >       Attrs: mail telephoneNumber
757
758     is not cacheable, because the filter does not match the template ( logical
759     OR "|" condition instead of logical AND "&" )
760                            
761                            
762 H2: Password Policies
763
764
765 H3: Overview
766
767 This overlay follows the specifications contained in the draft RFC titled 
768 draft-behera-ldap-password-policy-09. While the draft itself is expired, it has 
769 been implemented in several directory servers, including slapd. Nonetheless, 
770 it is important to note that it is a draft, meaning that it is subject to change 
771 and is a work-in-progress.
772
773 The key abilities of the password policy overlay are as follows:
774
775 * Enforce a minimum length for new passwords
776 * Make sure passwords are not changed too frequently
777 * Cause passwords to expire, provide warnings before they need to be changed, and allow a fixed number of 'grace' logins to allow them to be changed after they have expired
778 * Maintain a history of passwords to prevent password re-use
779 * Prevent password guessing by locking a password for a specified period of time after repeated authentication failures
780 * Force a password to be changed at the next authentication
781 * Set an administrative lock on an account
782 * Support multiple password policies on a default or a per-object basis.
783 * Perform arbitrary quality checks using an external loadable module. This is a non-standard extension of the draft RFC.
784
785
786 H3: Password Policy Configuration
787
788 Instantiate the module in the database where it will be used, after adding the 
789 new ppolicy schema and loading the ppolicy module. The following example shows 
790 the ppolicy module being added to the database that handles the naming 
791 context "dc=example,dc=com". In this example we are also specifying the DN of 
792 a policy object to use if none other is specified in a user's object.
793
794 >       database bdb
795 >       suffix "dc=example,dc=com"
796 >       [...additional database configuration directives go here...]
797 >       
798 >       overlay ppolicy
799 >       ppolicy_default "cn=default,ou=policies,dc=example,dc=com"
800
801
802 Now we need a container for the policy objects. In our example the password 
803 policy objects are going to be placed in a section of the tree called 
804 "ou=policies,dc=example,dc=com":
805
806 >       dn: ou=policies,dc=example,dc=com
807 >       objectClass: organizationalUnit
808 >       objectClass: top
809 >       ou: policies
810
811
812 The default policy object that we are creating defines the following policies:
813
814 * The user is allowed to change his own password. Note that the directory ACLs for this attribute can also affect this ability (pwdAllowUserChange: TRUE).
815 * The name of the password attribute is "userPassword" (pwdAttribute: userPassword). Note that this is the only value that is accepted by OpenLDAP for this attribute.
816 * The server will check the syntax of the password. If the server is unable to check the syntax (i.e., it was hashed or otherwise encoded by the client) it will return an error refusing the password (pwdCheckQuality: 2).
817 * When a client includes the Password Policy Request control with a bind request, the server will respond with a password expiration warning if it is going to expire in ten minutes or less (pwdExpireWarning: 600). The warnings themselves are returned in a Password Policy Response control.
818 * When the password for a DN has expired, the server will allow five additional "grace" logins (pwdGraceAuthNLimit: 5).
819 * The server will maintain a history of the last five passwords that were used for a DN (pwdInHistory: 5).
820 * The server will lock the account after the maximum number of failed bind attempts has been exceeded (pwdLockout: TRUE).
821 * When the server has locked an account, the server will keep it locked until an administrator unlocks it (pwdLockoutDuration: 0)
822 * The server will reset its failed bind count after a period of 30 seconds.
823 * Passwords will not expire (pwdMaxAge: 0).
824 * Passwords can be changed as often as desired (pwdMinAge: 0).
825 * Passwords must be at least 5 characters in length (pwdMinLength: 5).
826 * The password does not need to be changed at the first bind or when the administrator has reset the password (pwdMustChange: FALSE)
827 * The current password does not need to be included with password change requests (pwdSafeModify: FALSE)
828 * The server will only allow five failed binds in a row for a particular DN (pwdMaxFailure: 5).
829
830
831 The actual policy would be:
832
833 >       dn: cn=default,ou=policies,dc=example,dc=com
834 >       cn: default
835 >       objectClass: pwdPolicy
836 >       objectClass: person
837 >       objectClass: top
838 >       pwdAllowUserChange: TRUE
839 >       pwdAttribute: userPassword
840 >       pwdCheckQuality: 2
841 >       pwdExpireWarning: 600
842 >       pwdFailureCountInterval: 30
843 >       pwdGraceAuthNLimit: 5
844 >       pwdInHistory: 5
845 >       pwdLockout: TRUE
846 >       pwdLockoutDuration: 0
847 >       pwdMaxAge: 0
848 >       pwdMaxFailure: 5
849 >       pwdMinAge: 0
850 >       pwdMinLength: 5
851 >       pwdMustChange: FALSE
852 >       pwdSafeModify: FALSE
853 >       sn: dummy value
854
855 You can create additional policy objects as needed. 
856
857
858 There are two ways password policy can be applied to individual objects:
859
860 1. The pwdPolicySubentry in a user's object - If a user's object has a
861 pwdPolicySubEntry attribute specifying the DN of a policy object, then 
862 the policy defined by that object is applied.
863
864 2. Default password policy - If there is no specific pwdPolicySubentry set
865 for an object, and the password policy module was configured with the DN of a
866 default policy object and if that object exists, then the policy defined in
867 that object is applied.
868
869 Please see {{slapo-ppolicy(5)}} for complete explanations of features and discussion of
870  "Password Management Issues" at {{URL:http://www.connexitor.com/forums/viewtopic.php?f=6&t=25}}
871
872
873
874 H2: Referential Integrity
875
876
877 H3: Overview
878
879 This overlay can be used with a backend database such as slapd-bdb(5)
880 to maintain the cohesiveness of a schema which utilizes reference
881 attributes.
882
883 Whenever a {{modrdn}} or {{delete}} is performed, that is, when an entry's DN
884 is renamed or an entry is removed, the server will search the directory for
885 references to this DN (in selected attributes: see below) and update them
886 accordingly. If it was a {{delete}} operation, the reference is deleted. If it
887 was a {{modrdn}} operation, then the reference is updated with the new DN.
888
889 For example, a very common administration task is to maintain group membership
890 lists, specially when users are removed from the directory. When an
891 user account is deleted or renamed, all groups this user is a member of have to be
892 updated. LDAP administrators usually have scripts for that. But we can use the
893 {{F:refint}} overlay to automate this task. In this example, if the user is
894 removed from the directory, the overlay will take care to remove the user from
895 all the groups he/she was a member of. No more scripting for this.
896
897 H3: Referential Integrity Configuration
898
899 The configuration for this overlay is as follows:
900 >       overlay refint
901 >       refint_attributes <attribute [attribute ...]>
902 >       refint_nothing <string>
903
904 * {{F:refint_attributes}}: this parameter specifies a space separated list of
905 attributes which will have the referential integrity maintained. When an entry is
906 removed or has its DN renamed, the server will do an internal search for any of the
907 {{F:refint_attributes}} that point to the affected DN and update them accordingly. IMPORTANT:
908 the attributes listed here must have the {{F:distinguishedName}} syntax, that is,
909 hold DNs as values.
910 * {{F:refint_nothing}}: some times, while trying to maintain the referential
911 integrity, the server has to remove the last attribute of its kind from an
912 entry. This may be prohibited by the schema: for example, the
913 {{F:groupOfNames}} object class requires at least one member. In these cases,
914 the server will add the attribute value specified in {{F:refint_nothing}}
915 to the entry.
916
917 To illustrate this overlay, we will use the group membership scenario.
918
919 In {{F:slapd.conf}}:
920 >       overlay refint
921 >       refint_attributes member
922 >       refint_nothing "cn=admin,dc=example,dc=com"
923
924 This configuration tells the overlay to maintain the referential integrity of the {{F:member}}
925 attribute. This attribute is used in the {{F:groupOfNames}} object class which always needs
926 a member, so we add the {{F:refint_nothing}} directive to fill in the group with a standard
927 member should all the members vanish.
928
929 If we have the following group membership, the refint overlay will
930 automatically remove {{F:john}} from the group if his entry is removed from the
931 directory:
932
933 !import "refint.png"; align="center"; title="Group membership"
934 FT[align="Center"] Figure X.Y: Maintaining referential integrity in groups
935
936 Notice that if we rename ({{F:modrdn}}) the {{F:john}} entry to, say, {{F:jsmith}}, the refint
937 overlay will also rename the reference in the {{F:member}} attribute, so the group membership
938 stays correct.
939
940 If we removed all users from the directory who are a member of this group, then the end result
941 would be a single member in the group: {{F:cn=admin,dc=example,dc=com}}. This is the
942 {{F:refint_nothing}} parameter kicking into action so that the schema is not violated.
943
944 H2: Return Code
945
946
947 H3: Overview
948
949 This overlay is useful to test the behavior of clients when
950 server-generated erroneous and/or unusual responses occur.
951
952
953 H3: Return Code Configuration
954
955
956 H2: Rewrite/Remap
957             
958             
959 H3: Overview
960
961 It performs basic DN/data rewrite and
962 objectClass/attributeType mapping.
963
964
965 H3: Rewrite/Remap Configuration
966
967
968 H2: Sync Provider
969
970
971 H3: Overview
972
973 This overlay implements the provider-side support for syncrepl
974 replication, including persistent search functionality
975
976
977 H3: Sync Provider Configuration
978
979
980 H2: Translucent Proxy
981
982
983 H3: Overview
984
985 This overlay can be used with a backend database such as slapd-bdb (5)
986 to create a "translucent proxy".
987
988 Content of entries retrieved from a remote LDAP server can be partially
989 overridden by the database.
990
991
992 H3: Translucent Proxy Configuration
993
994
995 H2: Attribute Uniqueness
996
997
998 H3: Overview
999
1000 This overlay can be used with a backend database such as slapd-bdb (5)
1001 to enforce the uniqueness of some or all attributes within a subtree.
1002
1003
1004 H3: Attribute Uniqueness Configuration
1005
1006
1007 H2: Value Sorting
1008
1009
1010 H3: Overview
1011
1012 This overlay can be used to enforce a specific order for the values
1013 of an attribute when it is returned in a search.
1014
1015
1016 H3: Value Sorting Configuration
1017
1018
1019 H2: Overlay Stacking
1020
1021
1022 H3: Overview
1023
1024 Overlays can be stacked, which means that more than one overlay
1025 can be instantiated for each database, or for the {{EX:frontend}}.
1026 As a consequence, each overlays function is called, if defined,
1027 when overlay execution is invoked.
1028 Multiple overlays are executed in reverse order (as a stack)
1029 with respect to their definition in slapd.conf (5), or with respect
1030 to their ordering in the config database, as documented in slapd-config (5).
1031
1032
1033 H3: Example Scenarios
1034
1035
1036 H4: Samba