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