1 .TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" Copyright 1998-2009 The OpenLDAP Foundation, All Rights Reserved.
3 .\" Copying restrictions apply. See the COPYRIGHT file.
4 .\" Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
7 .\" Portions of this document should probably be moved to slapd-ldap(5)
8 .\" and maybe manual pages for librewrite.
11 slapd-meta \- metadirectory backend to slapd
19 performs basic LDAP proxying with respect to a set of remote LDAP
20 servers, called "targets".
21 The information contained in these servers can be presented as
22 belonging to a single Directory Information Tree (DIT).
24 A basic knowledge of the functionality of the
26 backend is recommended.
27 This backend has been designed as an enhancement of the ldap backend.
28 The two backends share many features (actually they also share
32 backend is intended to proxy operations directed to a single server, the
34 backend is mainly intended for proxying of multiple servers and possibly
35 naming context masquerading.
36 These features, although useful in many scenarios, may result in
37 excessive overhead for some applications, so its use should be
39 In the examples section, some typical scenarios will be discussed.
43 must contain schema information for the attributes and objectClasses
44 used in filters, request DN and request-related data in general.
45 It should also contain schema information for the data returned
46 by the proxied server.
47 It is the responsibility of the proxy administrator to keep the schema
48 of the proxy lined up with that of the proxied server.
51 Note: When looping back to the same instance of \fBslapd\fP(8),
52 each connection requires a new thread; as a consequence, \fBslapd\fP(8)
53 must be compiled with thread support, and the \fBthreads\fP parameter
54 may need some tuning; in those cases, unless the multiple target feature
55 is required, one may consider using \fBslapd-relay\fP(5) instead,
56 which performs the relayed operation internally and thus reuses
60 There are examples in various places in this document, as well as in the
61 slapd/back-meta/data/ directory in the OpenLDAP source tree.
65 options apply to the META backend database.
66 That is, they must follow a "database meta" line and come before any
67 subsequent "backend" or "database" lines.
68 Other database options are described in the
72 Note: In early versions of back-ldap and back-meta it was recommended to always set
85 This was required because operational attributes related to entry creation
86 and modification should not be proxied, as they could be mistakenly written
87 to the target server(s), generating an error.
88 The current implementation automatically sets lastmod to \fBoff\fP,
89 so its use is redundant and should be omitted.
91 .SH SPECIAL CONFIGURATION DIRECTIVES
92 Target configuration starts with the "uri" directive.
93 All the configuration directives that are not specific to targets
94 should be defined first for clarity, including those that are common
100 This directive causes a cached connection to be dropped an recreated
101 after a given ttl, regardless of being idle or not.
104 .B default-target none
105 This directive forces the backend to reject all those operations
106 that must resolve to a single target in case none or multiple
107 targets are selected.
108 They include: add, delete, modify, modrdn; compare is not included, as
109 well as bind since, as they don't alter entries, in case of multiple
110 matches an attempt is made to perform the operation on any candidate
111 target, with the constraint that at most one must succeed.
112 This directive can also be used when processing targets to mark a
113 specific target as default.
116 .B dncache-ttl {DISABLED|forever|<ttl>}
117 This directive sets the time-to-live of the DN cache.
118 This caches the target that holds a given DN to speed up target
119 selection in case multiple targets would result from an uncached
120 search; forever means cache never expires; disabled means no DN
121 caching; otherwise a valid ( > 0 ) ttl is required, in the format
127 .B onerr {CONTINUE|report|stop}
128 This directive allows to select the behavior in case an error is returned
129 by one target during a search.
130 The default, \fBcontinue\fP, consists in continuing the operation,
131 trying to return as much data as possible.
132 If the value is set to \fBstop\fP, the search is terminated as soon
133 as an error is returned by one target, and the error is immediately
134 propagated to the client.
135 If the value is set to \fBreport\fP, the search is continuated to the end
136 but, in case at least one target returned an error code, the first
137 non-success error code is returned.
143 do not return search reference responses.
144 By default, they are returned unless request is LDAPv2.
145 If set before any target specification, it affects all targets, unless
146 overridden by any per-target directive.
149 .B noundeffilter <NO|yes>
152 return success instead of searching if a filter is undefined or contains
154 By default, the search is propagated after replacing undefined portions
156 .BR (!(objectClass=*)) ,
157 which corresponds to the empty result set.
158 If set before any target specification, it affects all targets, unless
159 overridden by any per-target directive.
162 .B protocol\-version {0,2,3}
163 This directive indicates what protocol version must be used to contact
165 If set to 0 (the default), the proxy uses the same protocol version
166 used by the client, otherwise the requested protocol is used.
167 The proxy returns \fIunwillingToPerform\fP if an operation that is
168 incompatible with the requested protocol is attempted.
169 If set before any target specification, it affects all targets, unless
170 overridden by any per-target directive.
173 .B pseudoroot-bind-defer {YES|no}
174 This directive, when set to
176 causes the authentication to the remote servers with the pseudo-root
177 identity to be deferred until actually needed by subsequent operations.
178 Otherwise, all binds as the rootdn are propagated to the targets.
181 .B quarantine <interval>,<num>[;<interval>,<num>[...]]
182 Turns on quarantine of URIs that returned
183 .IR LDAP_UNAVAILABLE ,
184 so that an attempt to reconnect only occurs at given intervals instead
185 of any time a client requests an operation.
186 The pattern is: retry only after at least
188 seconds elapsed since last attempt, for exactly
190 times; then use the next pattern.
193 for the last pattern is "\fB+\fP", it retries forever; otherwise,
194 no more retries occur.
195 This directive must appear before any target specification;
196 it affects all targets with the same pattern.
199 .B rebind-as-user {NO|yes}
200 If this option is given, the client's bind credentials are remembered
201 for rebinds, when trying to re-establish a broken connection,
202 or when chasing a referral, if
208 .B session\-tracking\-request {NO|yes}
209 Adds session tracking control for all requests.
210 The client's IP and hostname, and the identity associated to each request,
211 if known, are sent to the remote server for informational purposes.
212 This directive is incompatible with setting \fIprotocol\-version\fP to 2.
213 If set before any target specification, it affects all targets, unless
214 overridden by any per-target directive.
217 .B single\-conn {NO|yes}
218 Discards current cached connection when the client rebinds.
221 .B use-temporary-conn {NO|yes}
224 create a temporary connection whenever competing with other threads
225 for a shared one; otherwise, wait until the shared connection is available.
227 .SH TARGET SPECIFICATION
228 Target specification starts with a "uri" directive:
231 .B uri <protocol>://[<host>]/<naming context> [...]
232 The <protocol> part can be anything
233 .BR ldap_initialize (3)
234 accepts ({ldap|ldaps|ldapi} and variants); the <host> may be
235 omitted, defaulting to whatever is set in
237 The <naming context> part is \fImandatory\fP for the first URI,
238 but it \fImust be omitted\fP for subsequent ones, if any.
239 The naming context part must be within the naming context defined for the backend,
244 suffix "\fBdc=foo,dc=com\fP"
245 uri "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
250 The <naming context> part doesn't need to be unique across the targets;
251 it may also match one of the values of the "suffix" directive.
252 Multiple URIs may be defined in a single URI statement.
253 The additional URIs must be separate arguments and must not have any
254 <naming context> part. This causes the underlying library
255 to contact the first server of the list that responds.
256 For example, if \fIl1.foo.com\fP and \fIl2.foo.com\fP are shadows
257 of the same server, the directive
260 suffix "\fBdc=foo,dc=com\fP"
261 uri "ldap://l1.foo.com/\fBdc=foo,dc=com\fP" "ldap://l2.foo.com/"
266 causes \fIl2.foo.com\fP to be contacted whenever \fIl1.foo.com\fP
268 In that case, the URI list is internally rearranged, by moving unavailable
269 URIs to the end, so that further connection attempts occur with respect to
270 the last URI that succeeded.
274 .B acl-authcDN "<administrative DN for access control purposes>"
275 DN which is used to query the target server for acl checking,
276 as in the LDAP backend; it is supposed to have read access
277 on the target server to attributes used on the proxy for acl checking.
278 There is no risk of giving away such values; they are only used to
280 .B The acl-authcDN identity is by no means implicitly used by the proxy
281 .B when the client connects anonymously.
284 .B acl-passwd <password>
285 Password used with the
291 .B bind-timeout <microseconds>
292 This directive defines the timeout, in microseconds, used when polling
293 for response after an asynchronous bind connection. The initial call
294 to ldap_result(3) is performed with a trade-off timeout of 100000 us;
295 if that results in a timeout exceeded, subsequent calls use the value
298 The default value is used also for subsequent calls if
301 If set before any target specification, it affects all targets, unless
302 overridden by any per-target directive.
305 .B chase-referrals {YES|no}
306 enable/disable automatic referral chasing, which is delegated to the
307 underlying libldap, with rebinding eventually performed if the
308 \fBrebind-as-user\fP directive is used. The default is to chase referrals.
309 If set before any target specification, it affects all targets, unless
310 overridden by any per-target directive.
313 .B default-target [<target>]
314 The "default-target" directive can also be used during target specification.
315 With no arguments it marks the current target as the default.
316 The optional number marks target <target> as the default one, starting
318 Target <target> must be defined.
321 .B idassert-authzFrom <authz-regexp>
322 if defined, selects what
324 identities are authorized to exploit the identity assertion feature.
327 follows the rules defined for the
334 for details on the syntax of this field.
339 .B bindmethod=none|simple|sasl [binddn=<simple DN>] [credentials=<simple password>]
340 .B [saslmech=<SASL mech>] [secprops=<properties>] [realm=<realm>]
341 .B [authcId=<authentication ID>] [authzId=<authorization ID>]
342 .B [authz={native|proxyauthz}] [mode=<mode>] [flags=<flags>]
343 .B [starttls=no|yes|critical]
344 .B [starttls=no|yes|critical]
347 .B [tls_cacert=<file>]
348 .B [tls_cacertdir=<path>]
349 .B [tls_reqcert=never|allow|try|demand]
350 .B [tls_ciphersuite=<ciphers>]
351 .B [tls_protocol_min=<version>]
352 .B [tls_crlcheck=none|peer|all]
354 Allows to define the parameters of the authentication method that is
355 internally used by the proxy to authorize connections that are
356 authenticated by other databases.
357 The identity defined by this directive, according to the properties
358 associated to the authentication method, is supposed to have auth access
359 on the target server to attributes used on the proxy for authentication
360 and authorization, and to be allowed to authorize the users.
361 This requires to have
363 privileges on a wide set of DNs, e.g.
364 .BR authzTo=dn.subtree:"" ,
365 and the remote server to have
373 for details on these statements and for remarks and drawbacks about
375 The supported bindmethods are
377 \fBnone|simple|sasl\fP
381 is the default, i.e. no \fIidentity assertion\fP is performed.
383 The authz parameter is used to instruct the SASL bind to exploit
385 SASL authorization, if available; since connections are cached,
386 this should only be used when authorizing with a fixed identity
387 (e.g. by means of the
392 Otherwise, the default
394 is used, i.e. the proxyAuthz control (Proxied Authorization, RFC 4370)
395 is added to all operations.
397 The supported modes are:
399 \fB<mode> := {legacy|anonymous|none|self}\fP
405 is given, the proxy always authorizes that identity.
406 .B <authorization ID>
413 The former is supposed to be expanded by the remote server according
414 to the authz rules; see
417 In the latter case, whether or not the
419 prefix is present, the string must pass DN validation and normalization.
423 which implies that the proxy will either perform a simple bind as the
425 or a SASL bind as the
427 and assert the client's identity when it is not anonymous.
428 Direct binds are always proxied.
429 The other modes imply that the proxy will always either perform a simple bind
432 or a SASL bind as the
435 .BR idassert-authzFrom
436 rules (see below), in which case the operation will fail;
437 eventually, it will assert some other identity according to
439 Other identity assertion modes are
443 which respectively mean that the
450 which means that no proxyAuthz control will be used, so the
454 identity will be asserted.
455 For all modes that require the use of the
457 control, on the remote server the proxy identity must have appropriate
459 permissions, or the asserted identities must have appropriate
461 permissions. Note, however, that the ID assertion feature is mostly
462 useful when the asserted identities do not exist on the remote server.
466 \fBoverride,[non-]prescriptive\fP
470 flag is used, identity assertion takes place even when the database
471 is authorizing for the identity of the client, i.e. after binding
472 with the provided identity, and thus authenticating it, the proxy
473 performs the identity assertion using the configured identity and
474 authentication method.
478 flag is used (the default), operations fail with
479 \fIinappropriateAuthentication\fP
480 for those identities whose assertion is not allowed by the
481 .B idassert-authzFrom
485 flag is used, operations are performed anonymously for those identities
486 whose assertion is not allowed by the
487 .B idassert-authzFrom
490 The TLS settings default to the same as the main slapd TLS settings,
493 which defaults to "demand".
495 The identity associated to this directive is also used for privileged
496 operations whenever \fBidassert-bind\fP is defined and \fBacl-bind\fP
497 is not. See \fBacl-bind\fP for details.
501 .B idle-timeout <time>
502 This directive causes a cached connection to be dropped an recreated
503 after it has been idle for the specified time.
504 The value can be specified as
506 [<d>d][<h>h][<m>m][<s>[s]]
508 where <d>, <h>, <m> and <s> are respectively treated as days, hours,
510 If set before any target specification, it affects all targets, unless
511 overridden by any per-target directive.
514 .B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
515 This maps object classes and attributes as in the LDAP backend.
520 .B network-timeout <time>
521 Sets the network timeout value after which
522 .BR poll (2)/ select (2)
525 returns in case of no activity.
526 The value is in seconds, and it can be specified as for
528 If set before any target specification, it affects all targets, unless
529 overridden by any per-target directive.
532 .B nretries {forever|never|<nretries>}
533 This directive defines how many times a bind should be retried
534 in case of temporary failure in contacting a target. If defined
535 before any target specification, it applies to all targets (by default,
538 the global value can be overridden by redefinitions inside each target
542 .B pseudorootdn "<substitute DN in case of rootdn bind>"
543 This directive, if present, sets the DN that will be substituted to
544 the bind DN if a bind with the backend's "rootdn" succeeds.
545 The true "rootdn" of the target server ought not be used; an arbitrary
546 administrative DN should used instead.
549 .B pseudorootpw "<substitute password in case of rootdn bind>"
550 This directive sets the credential that will be used in case a bind
551 with the backend's "rootdn" succeeds, and the bind is propagated to
552 the target using the "pseudorootdn" DN.
554 Note: cleartext credentials must be supplied here; as a consequence,
555 using the pseudorootdn/pseudorootpw directives is inherently unsafe.
559 The rewrite options are described in the "REWRITING" section.
562 .B subtree-exclude "<DN>"
563 This directive instructs back-meta to ignore the current target
564 for operations whose requestDN is subordinate to
566 There may be multiple occurrences of the
568 directive for each of the targets.
571 .B suffixmassage "<virtual naming context>" "<real naming context>"
572 All the directives starting with "rewrite" refer to the rewrite engine
573 that has been added to slapd.
574 The "suffixmassage" directive was introduced in the LDAP backend to
575 allow suffix massaging while proxying.
576 It has been obsoleted by the rewriting tools.
577 However, both for backward compatibility and for ease of configuration
578 when simple suffix massage is required, it has been preserved.
579 It wraps the basic rewriting instructions that perform suffix
580 massaging. See the "REWRITING" section for a detailed list
581 of the rewrite rules it implies.
584 .B t-f-support {NO|yes|discover}
585 enable if the remote server supports absolute filters
586 (see \fIdraft-zeilenga-ldap-t-f\fP for details).
589 support is detected by reading the remote server's root DSE.
590 If set before any target specification, it affects all targets, unless
591 overridden by any per-target directive.
594 .B timeout [<op>=]<val> [...]
595 This directive allows to set per-operation timeouts.
598 \fB<op> ::= bind, add, delete, modrdn, modify, compare, search\fP
600 The overall duration of the \fBsearch\fP operation is controlled either
601 by the \fBtimelimit\fP parameter or by server-side enforced
602 time limits (see \fBtimelimit\fP and \fBlimits\fP in
605 This \fBtimeout\fP parameter controls how long the target can be
606 irresponsive before the operation is aborted.
607 Timeout is meaningless for the remaining operations,
608 \fBunbind\fP and \fBabandon\fP, which do not imply any response,
609 while it is not yet implemented in currently supported \fBextended\fP
611 If no operation is specified, the timeout \fBval\fP affects all
612 supported operations.
613 If specified before any target definition, it affects all targets
614 unless overridden by per-target directives.
616 Note: if the timeout is exceeded, the operation is cancelled
617 (according to the \fBcancel\fP directive);
618 the protocol does not provide any means to rollback operations,
619 so the client will not be notified about the result of the operation,
620 which may eventually succeeded or not.
621 In case the timeout is exceeded during a bind operation, the connection
622 is destroyed, according to RFC4511.
625 .B tls {[try-]start|[try-]propagate}
626 execute the StartTLS extended operation when the connection is initialized;
627 only works if the URI directive protocol scheme is not \fBldaps://\fP.
628 \fBpropagate\fP issues the StartTLS operation only if the original
630 The \fBtry-\fP prefix instructs the proxy to continue operations
631 if the StartTLS operation failed; its use is highly deprecated.
632 If set before any target specification, it affects all targets, unless
633 overridden by any per-target directive.
636 A powerful (and in some sense dangerous) rewrite engine has been added
637 to both the LDAP and Meta backends.
638 While the former can gain limited beneficial effects from rewriting
639 stuff, the latter can become an amazingly powerful tool.
641 Consider a couple of scenarios first.
643 1) Two directory servers share two levels of naming context;
644 say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
645 Then, an unambiguous Meta database can be configured as:
650 suffix "\fBdc=foo,dc=com\fP"
651 uri "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
652 uri "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
656 Operations directed to a specific target can be easily resolved
657 because there are no ambiguities.
658 The only operation that may resolve to multiple targets is a search
659 with base "dc=foo,dc=com" and scope at least "one", which results in
660 spawning two searches to the targets.
662 2a) Two directory servers don't share any portion of naming context,
663 but they'd present as a single DIT
664 [Caveat: uniqueness of (massaged) entries among the two servers is
665 assumed; integrity checks risk to incur in excessive overhead and have
666 not been implemented].
667 Say we have "dc=bar,dc=org" and "o=Foo,c=US",
668 and we'd like them to appear as branches of "dc=foo,dc=com", say
669 "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
670 Then we need to configure our Meta backend as:
675 suffix "dc=foo,dc=com"
677 uri "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
678 suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"
680 uri "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
681 suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
685 Again, operations can be resolved without ambiguity, although
686 some rewriting is required.
687 Notice that the virtual naming context of each target is a branch of
688 the database's naming context; it is rewritten back and forth when
689 operations are performed towards the target servers.
690 What "back and forth" means will be clarified later.
692 When a search with base "dc=foo,dc=com" is attempted, if the
693 scope is "base" it fails with "no such object"; in fact, the
694 common root of the two targets (prior to massaging) does not
696 If the scope is "one", both targets are contacted with the base
697 replaced by each target's base; the scope is derated to "base".
698 In general, a scope "one" search is honored, and the scope is derated,
699 only when the incoming base is at most one level lower of a target's
700 naming context (prior to massaging).
702 Finally, if the scope is "sub" the incoming base is replaced
703 by each target's unmassaged naming context, and the scope
706 2b) Consider the above reported scenario with the two servers
707 sharing the same naming context:
712 suffix "\fBdc=foo,dc=com\fP"
714 uri "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
715 suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"
717 uri "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
718 suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
722 All the previous considerations hold, except that now there is
723 no way to unambiguously resolve a DN.
724 In this case, all the operations that require an unambiguous target
725 selection will fail unless the DN is already cached or a default
727 Practical configurations may result as a combination of all the
730 Note on ACLs: at present you may add whatever ACL rule you desire
731 to to the Meta (and LDAP) backends.
732 However, the meaning of an ACL on a proxy may require some
734 Two philosophies may be considered:
736 a) the remote server dictates the permissions; the proxy simply passes
737 back what it gets from the remote server.
739 b) the remote server unveils "everything"; the proxy is responsible
740 for protecting data from unauthorized access.
742 Of course the latter sounds unreasonable, but it is not.
743 It is possible to imagine scenarios in which a remote host discloses
744 data that can be considered "public" inside an intranet, and a proxy
745 that connects it to the internet may impose additional constraints.
746 To this purpose, the proxy should be able to comply with all the ACL
747 matching criteria that the server supports.
748 This has been achieved with regard to all the criteria supported by
749 slapd except a special subtle case (please drop me a note if you can
750 find other exceptions: <ando@openldap.org>).
755 access to dn="<dn>" attrs=<attr>
756 by dnattr=<dnattr> read
761 cannot be matched iff the attribute that is being requested, <attr>,
762 is NOT <dnattr>, and the attribute that determines membership,
763 <dnattr>, has not been requested (e.g. in a search)
765 In fact this ACL is resolved by slapd using the portion of entry it
766 retrieved from the remote server without requiring any further
767 intervention of the backend, so, if the <dnattr> attribute has not
768 been fetched, the match cannot be assessed because the attribute is
769 not present, not because no value matches the requirement!
771 Note on ACLs and attribute mapping: ACLs are applied to the mapped
772 attributes; for instance, if the attribute locally known as "foo" is
773 mapped to "bar" on a remote server, then local ACLs apply to attribute
774 "foo" and are totally unaware of its remote name.
775 The remote server will check permissions for "bar", and the local
776 server will possibly enforce additional restrictions to "foo".
778 .\" If this section is moved, also update the reference in
779 .\" libraries/librewrite/RATIONALE.
782 A string is rewritten according to a set of rules, called a `rewrite
784 The rules are based on POSIX (''extended'') regular expressions (regex)
785 with substring matching; basic variable substitution and map resolution
786 of substrings is allowed by specific mechanisms detailed in the following.
787 The behavior of pattern matching/substitution can be altered by a set
790 The underlying concept is to build a lightweight rewrite module
791 for the slapd server (initially dedicated to the LDAP backend).
793 An incoming string is matched against a set of rules.
794 Rules are made of a regex match pattern, a substitution pattern
795 and a set of actions, described by a set of flags.
796 In case of match a string rewriting is performed according to the
797 substitution pattern that allows to refer to substrings matched in the
799 The actions, if any, are finally performed.
800 The substitution pattern allows map resolution of substrings.
801 A map is a generic object that maps a substitution pattern to a value.
802 The flags are divided in "Pattern matching Flags" and "Action Flags";
803 the former alter the regex match pattern behavior while the latter
804 alter the action that is taken after substitution.
805 .SH "Pattern Matching Flags"
808 honors case in matching (default is case insensitive)
811 use POSIX ''basic'' regular expressions (default is ''extended'')
816 recursive passes for a specific rule; does not alter the max total count
817 of passes, so it can only enforce a stricter limit for a specific rule.
821 apply the rule once only (default is recursive)
824 stop applying rules in case of match; the current rule is still applied
825 recursively; combine with `:' to apply the current rule only once
829 stop current operation if the rule matches, and issue an `unwilling to
835 rules back and forth (watch for loops!).
836 Note that `G{1}' is implicit in every rule.
839 ignores errors in rule; this means, in case of error, e.g. issued by a
840 map, the error is treated as a missed match.
841 The `unwilling to perform' is not overridden.
847 as return code if the rule matches; the flag does not alter the recursive
848 behavior of the rule, so, to have it performed only once, it must be used
849 in combination with `:', e.g.
851 returns the value `16' after exactly one execution of the rule, if the
853 As a consequence, its behavior is equivalent to `@', with the return
856 or, in other words, `@' is equivalent to `U{0}'.
857 By convention, the freely available codes are above 16 included;
858 the others are reserved.
860 The ordering of the flags can be significant.
861 For instance: `IG{2}' means ignore errors and jump two lines ahead
862 both in case of match and in case of error, while `G{2}I' means ignore
863 errors, but jump two lines ahead only in case of match.
865 More flags (mainly Action Flags) will be added as needed.
866 .SH "Pattern matching:"
871 .SH "Substitution Pattern Syntax:"
872 Everything starting with `%' requires substitution;
874 the only obvious exception is `%%', which is left as is;
876 the basic substitution is `%d', where `d' is a digit;
877 0 means the whole string, while 1-9 is a submatch;
879 a `%' followed by a `{' invokes an advanced substitution.
883 `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
886 where <name> must be a legal name for the map, i.e.
890 <name> ::= [a-z][a-z0-9]* (case insensitive)
891 <op> ::= `>' `|' `&' `&&' `*' `**' `$'
895 and <substitution> must be a legal substitution
896 pattern, with no limits on the nesting level.
901 sub context invocation; <name> must be a legal, already defined
905 external command invocation; <name> must refer to a legal, already
906 defined command name (NOT IMPL.)
909 variable assignment; <name> defines a variable in the running
910 operation structure which can be dereferenced later; operator
912 assigns a variable in the rewrite context scope; operator
914 assigns a variable that scopes the entire session, e.g. its value
915 can be dereferenced later by other rewrite contexts
918 variable dereferencing; <name> must refer to a variable that is
919 defined and assigned for the running operation; operator
921 dereferences a variable scoping the rewrite context; operator
923 dereferences a variable scoping the whole session, e.g. the value
924 is passed across rewrite contexts
927 parameter dereferencing; <name> must refer to an existing parameter;
928 the idea is to make some run-time parameters set by the system
929 available to the rewrite engine, as the client host name, the bind DN
930 if any, constant parameters initialized at config time, and so on;
931 no parameter is currently set by either
935 but constant parameters can be defined in the configuration file
940 Substitution escaping has been delegated to the `%' symbol,
941 which is used instead of `\e' in string substitution patterns
942 because `\e' is already escaped by slapd's low level parsing routines;
943 as a consequence, regex escaping requires two `\e' symbols,
944 e.g. `\fB.*\e.foo\e.bar\fP' must be written as `\fB.*\e\e.foo\e\e.bar\fP'.
946 .\" The symbol can be altered at will by redefining the related macro in
949 .SH "Rewrite context:"
950 A rewrite context is a set of rules which are applied in sequence.
951 The basic idea is to have an application initialize a rewrite
952 engine (think of Apache's mod_rewrite ...) with a set of rewrite
953 contexts; when string rewriting is required, one invokes the
954 appropriate rewrite context with the input string and obtains the
955 newly rewritten one if no errors occur.
957 Each basic server operation is associated to a rewrite context;
958 they are divided in two main groups: client \-> server and
959 server \-> client rewriting.
965 (default) if defined and no specific context
970 searchFilterAttrDN search
972 compareAttrDN compare AVA
976 modifyAttrDN modify AVA
980 exopPasswdDN password modify extended operation DN if proxy
988 searchResult search (only if defined; no default;
989 acts on DN and DN-syntax attributes
991 searchAttrDN search AVA
992 matchedDN all ops (only if applicable)
996 .SH "Basic configuration syntax"
998 .B rewriteEngine { on | off }
999 If `on', the requested rewriting is performed; if `off', no
1000 rewriting takes place (an easy way to stop rewriting without
1001 altering too much the configuration file).
1003 .B rewriteContext <context name> "[ alias <aliased context name> ]"
1004 <Context name> is the name that identifies the context, i.e. the name
1005 used by the application to refer to the set of rules it contains.
1006 It is used also to reference sub contexts in string rewriting.
1007 A context may alias another one.
1008 In this case the alias context contains no rule, and any reference to
1009 it will result in accessing the aliased one.
1011 .B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
1012 Determines how a string can be rewritten if a pattern is matched.
1013 Examples are reported below.
1014 .SH "Additional configuration syntax:"
1016 .B rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"
1017 Allows to define a map that transforms substring rewriting into
1019 The map is referenced inside the substitution pattern of a rule.
1021 .B rewriteParam <param name> <param value>
1022 Sets a value with global scope, that can be dereferenced by the
1023 command `%{$paramName}'.
1025 .B rewriteMaxPasses <number of passes> [<number of passes per rule>]
1026 Sets the maximum number of total rewriting passes that can be
1027 performed in a single rewrite operation (to avoid loops).
1028 A safe default is set to 100; note that reaching this limit is still
1029 treated as a success; recursive invocation of rules is simply
1031 The count applies to the rewriting operation as a whole, not
1032 to any single rule; an optional per-rule limit can be set.
1033 This limit is overridden by setting specific per-rule limits
1034 with the `M{n}' flag.
1035 .SH "Configuration examples:"
1037 # set to `off' to disable rewriting
1040 # the rules the "suffixmassage" directive implies
1042 # all dataflow from client to server referring to DNs
1043 rewriteContext default
1044 rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
1046 rewriteContext searchFilter
1047 # all dataflow from server to client
1048 rewriteContext searchResult
1049 rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
1050 rewriteContext searchAttrDN alias searchResult
1051 rewriteContext matchedDN alias searchResult
1053 # Everything defined here goes into the `default' context.
1054 # This rule changes the naming context of anything sent
1055 # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
1057 rewriteRule "(.*)dc=home,[ ]?dc=net"
1058 "%1dc=OpenLDAP, dc=org" ":"
1060 # since a pretty/normalized DN does not include spaces
1061 # after rdn separators, e.g. `,', this rule suffices:
1063 rewriteRule "(.*)dc=home,dc=net"
1064 "%1dc=OpenLDAP,dc=org" ":"
1066 # Start a new context (ends input of the previous one).
1067 # This rule adds blanks between DN parts if not present.
1068 rewriteContext addBlanks
1069 rewriteRule "(.*),([^ ].*)" "%1, %2"
1071 # This one eats blanks
1072 rewriteContext eatBlanks
1073 rewriteRule "(.*),[ ](.*)" "%1,%2"
1075 # Here control goes back to the default rewrite
1076 # context; rules are appended to the existing ones.
1077 # anything that gets here is piped into rule `addBlanks'
1078 rewriteContext default
1079 rewriteRule ".*" "%{>addBlanks(%0)}" ":"
1081 .\" # Anything with `uid=username' is looked up in
1082 .\" # /etc/passwd for gecos (I know it's nearly useless,
1083 .\" # but it is there just as a guideline to implementing
1085 .\" # Note the `I' flag that leaves `uid=username' in place
1086 .\" # if `username' does not have a valid account, and the
1087 .\" # `:' that forces the rule to be processed exactly once.
1088 .\" rewriteContext uid2Gecos
1089 .\" rewriteRule "(.*)uid=([a-z0-9]+),(.+)"
1090 .\" "%1cn=%2{xpasswd},%3" "I:"
1092 .\" # Finally, in a bind, if one uses a `uid=username' DN,
1093 .\" # it is rewritten in `cn=name surname' if possible.
1094 .\" rewriteContext bindDN
1095 .\" rewriteRule ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
1097 # Rewrite the search base according to `default' rules.
1098 rewriteContext searchBase alias default
1100 # Search results with OpenLDAP DN are rewritten back with
1101 # `dc=home,dc=net' naming context, with spaces eaten.
1102 rewriteContext searchResult
1103 rewriteRule "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
1104 "%{>eatBlanks(%1)}dc=home,dc=net" ":"
1106 # Bind with email instead of full DN: we first need
1107 # an ldap map that turns attributes into a DN (the
1108 # argument used when invoking the map is appended to
1109 # the URI and acts as the filter portion)
1110 rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
1112 # Then we need to detect DN made up of a single email,
1113 # e.g. `mail=someone@example.com'; note that the rule
1114 # in case of match stops rewriting; in case of error,
1115 # it is ignored. In case we are mapping virtual
1116 # to real naming contexts, we also need to rewrite
1117 # regular DNs, because the definition of a bindDn
1118 # rewrite context overrides the default definition.
1119 rewriteContext bindDN
1120 rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
1122 # This is a rather sophisticated example. It massages a
1123 # search filter in case who performs the search has
1124 # administrative privileges. First we need to keep
1125 # track of the bind DN of the incoming request, which is
1126 # stored in a variable called `binddn' with session scope,
1127 # and left in place to allow regular binding:
1128 rewriteContext bindDN
1129 rewriteRule ".+" "%{&&binddn(%0)}%0" ":"
1131 # A search filter containing `uid=' is rewritten only
1132 # if an appropriate DN is bound.
1133 # To do this, in the first rule the bound DN is
1134 # dereferenced, while the filter is decomposed in a
1135 # prefix, in the value of the `uid=<arg>' AVA, and
1136 # in a suffix. A tag `<>' is appended to the DN.
1137 # If the DN refers to an entry in the `ou=admin' subtree,
1138 # the filter is rewritten OR-ing the `uid=<arg>' with
1139 # `cn=<arg>'; otherwise it is left as is. This could be
1140 # useful, for instance, to allow apache's auth_ldap-1.4
1141 # module to authenticate users with both `uid' and
1142 # `cn', but only if the request comes from a possible
1143 # `cn=Web auth,ou=admin,dc=home,dc=net' user.
1144 rewriteContext searchFilter
1145 rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
1146 "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
1148 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
1149 "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
1150 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
1152 # This example shows how to strip unwanted DN-valued
1153 # attribute values from a search result; the first rule
1154 # matches DN values below "ou=People,dc=example,dc=com";
1155 # in case of match the rewriting exits successfully.
1156 # The second rule matches everything else and causes
1157 # the value to be rejected.
1158 rewriteContext searchResult
1159 rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
1160 rewriteRule ".*" "" "#"
1162 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
1163 In case the rewritten DN is an LDAP URI, the operation is initiated
1164 towards the host[:port] indicated in the uri, if it does not refer
1165 to the local server.
1169 rewriteRule '^cn=root,.*' '%0' 'G{3}'
1170 rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
1171 rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
1172 rewriteRule '.*' 'ldap://ldap3.my.org/%0' ':@'
1175 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
1179 rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
1182 with the advantage of saving one rewrite pass ...)
1187 backend does not honor all ACL semantics as described in
1188 .BR slapd.access (5).
1189 In general, access checking is delegated to the remote server(s).
1194 pseudo-attribute and to the other attribute values of the entries
1197 operation is honored, which is performed by the frontend.
1199 .SH PROXY CACHE OVERLAY
1200 The proxy cache overlay
1201 allows caching of LDAP search requests (queries) in a local database.
1203 .BR slapo-pcache (5)
1208 default slapd configuration file
1211 .BR slapd\-ldap (5),
1212 .BR slapo\-pcache (5),
1217 Pierangelo Masarati, based on back-ldap by Howard Chu