1 .TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" Copyright 1998-2008 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.
42 Note: When looping back to the same instance of \fBslapd\fP(8),
43 each connection requires a new thread; as a consequence, \fBslapd\fP(8)
44 must be compiled with thread support, and the \fBthreads\fP parameter
45 may need some tuning; in those cases, unless the multiple target feature
46 is required, one may consider using \fBslapd-relay\fP(5) instead,
47 which performs the relayed operation internally and thus reuses
51 There are examples in various places in this document, as well as in the
52 slapd/back-meta/data/ directory in the OpenLDAP source tree.
56 options apply to the META backend database.
57 That is, they must follow a "database meta" line and come before any
58 subsequent "backend" or "database" lines.
59 Other database options are described in the
63 Note: In early versions of back-ldap and back-meta it was recommended to always set
76 This was required because operational attributes related to entry creation
77 and modification should not be proxied, as they could be mistakenly written
78 to the target server(s), generating an error.
79 The current implementation automatically sets lastmod to \fBoff\fP,
80 so its use is redundant and should be omitted.
82 .SH SPECIAL CONFIGURATION DIRECTIVES
83 Target configuration starts with the "uri" directive.
84 All the configuration directives that are not specific to targets
85 should be defined first for clarity, including those that are common
91 This directive causes a cached connection to be dropped an recreated
92 after a given ttl, regardless of being idle or not.
95 .B default-target none
96 This directive forces the backend to reject all those operations
97 that must resolve to a single target in case none or multiple
99 They include: add, delete, modify, modrdn; compare is not included, as
100 well as bind since, as they don't alter entries, in case of multiple
101 matches an attempt is made to perform the operation on any candidate
102 target, with the constraint that at most one must succeed.
103 This directive can also be used when processing targets to mark a
104 specific target as default.
107 .B dncache-ttl {DISABLED|forever|<ttl>}
108 This directive sets the time-to-live of the DN cache.
109 This caches the target that holds a given DN to speed up target
110 selection in case multiple targets would result from an uncached
111 search; forever means cache never expires; disabled means no DN
112 caching; otherwise a valid ( > 0 ) ttl is required, in the format
118 .B onerr {CONTINUE|report|stop}
119 This directive allows to select the behavior in case an error is returned
120 by one target during a search.
121 The default, \fBcontinue\fP, consists in continuing the operation,
122 trying to return as much data as possible.
123 If the value is set to \fBstop\fP, the search is terminated as soon
124 as an error is returned by one target, and the error is immediately
125 propagated to the client.
126 If the value is set to \fBreport\fP, the search is continuated to the end
127 but, in case at least one target returned an error code, the first
128 non-success error code is returned.
131 .B protocol\-version {0,2,3}
132 This directive indicates what protocol version must be used to contact
134 If set to 0 (the default), the proxy uses the same protocol version
135 used by the client, otherwise the requested protocol is used.
136 The proxy returns \fIunwillingToPerform\fP if an operation that is
137 incompatible with the requested protocol is attempted.
138 If set before any target specification, it affects all targets, unless
139 overridden by any per-target directive.
142 .B pseudoroot-bind-defer {NO|yes}
143 This directive, when set to
145 causes the authentication to the remote servers with the pseudo-root
146 identity to be deferred until actually needed by subsequent operations.
149 .B quarantine <interval>,<num>[;<interval>,<num>[...]]
150 Turns on quarantine of URIs that returned
151 .IR LDAP_UNAVAILABLE ,
152 so that an attempt to reconnect only occurs at given intervals instead
153 of any time a client requests an operation.
154 The pattern is: retry only after at least
156 seconds elapsed since last attempt, for exactly
158 times; then use the next pattern.
161 for the last pattern is "\fB+\fP", it retries forever; otherwise,
162 no more retries occur.
163 This directive must appear before any target specification;
164 it affects all targets with the same pattern.
167 .B rebind-as-user {NO|yes}
168 If this option is given, the client's bind credentials are remembered
169 for rebinds, when trying to re-establish a broken connection,
170 or when chasing a referral, if
176 .B session\-tracking\-request {NO|yes}
177 Adds session tracking control for all requests.
178 The client's IP and hostname, and the identity associated to each request,
179 if known, are sent to the remote server for informational purposes.
180 This directive is incompatible with setting \fIprotocol\-version\fP to 2.
181 If set before any target specification, it affects all targets, unless
182 overridden by any per-target directive.
185 .B single\-conn {NO|yes}
186 Discards current cached connection when the client rebinds.
189 .B use-temporary-conn {NO|yes}
192 create a temporary connection whenever competing with other threads
193 for a shared one; otherwise, wait until the shared connection is available.
195 .SH TARGET SPECIFICATION
196 Target specification starts with a "uri" directive:
199 .B uri <protocol>://[<host>]/<naming context> [...]
200 The <protocol> part can be anything
201 .BR ldap_initialize (3)
202 accepts ({ldap|ldaps|ldapi} and variants); the <host> may be
203 omitted, defaulting to whatever is set in
205 The <naming context> part is \fImandatory\fP for the first URI,
206 but it \fImust be omitted\fP for subsequent ones, if any.
207 The naming context part must be within the naming context defined for the backend,
212 suffix "\fBdc=foo,dc=com\fP"
213 uri "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
218 The <naming context> part doesn't need to be unique across the targets;
219 it may also match one of the values of the "suffix" directive.
220 Multiple URIs may be defined in a single URI statement.
221 The additional URIs must be separate arguments and must not have any
222 <naming context> part. This causes the underlying library
223 to contact the first server of the list that responds.
224 For example, if \fIl1.foo.com\fP and \fIl2.foo.com\fP are shadows
225 of the same server, the directive
228 suffix "\fBdc=foo,dc=com\fP"
229 uri "ldap://l1.foo.com/\fBdc=foo,dc=com\fP" "ldap://l2.foo.com/"
234 causes \fIl2.foo.com\fP to be contacted whenever \fIl1.foo.com\fP
236 In that case, the URI list is internally rearranged, by moving unavailable
237 URIs to the end, so that further connection attempts occur with respect to
238 the last URI that succeeded.
242 .B acl-authcDN "<administrative DN for access control purposes>"
243 DN which is used to query the target server for acl checking,
244 as in the LDAP backend; it is supposed to have read access
245 on the target server to attributes used on the proxy for acl checking.
246 There is no risk of giving away such values; they are only used to
248 .B The acl-authcDN identity is by no means implicitly used by the proxy
249 .B when the client connects anonymously.
252 .B acl-passwd <password>
253 Password used with the
259 .B bind-timeout <microseconds>
260 This directive defines the timeout, in microseconds, used when polling
261 for response after an asynchronous bind connection. The initial call
262 to ldap_result(3) is performed with a trade-off timeout of 100000 us;
263 if that results in a timeout exceeded, subsequent calls use the value
266 The default value is used also for subsequent calls if
269 If set before any target specification, it affects all targets, unless
270 overridden by any per-target directive.
273 .B chase-referrals {YES|no}
274 enable/disable automatic referral chasing, which is delegated to the
275 underlying libldap, with rebinding eventually performed if the
276 \fBrebind-as-user\fP directive is used. The default is to chase referrals.
277 If set before any target specification, it affects all targets, unless
278 overridden by any per-target directive.
281 .B default-target [<target>]
282 The "default-target" directive can also be used during target specification.
283 With no arguments it marks the current target as the default.
284 The optional number marks target <target> as the default one, starting
286 Target <target> must be defined.
289 .B idassert-authzFrom <authz-regexp>
290 if defined, selects what
292 identities are authorized to exploit the identity assertion feature.
295 follows the rules defined for the
302 for details on the syntax of this field.
307 .B bindmethod=none|simple|sasl [binddn=<simple DN>] [credentials=<simple password>]
308 .B [saslmech=<SASL mech>] [secprops=<properties>] [realm=<realm>]
309 .B [authcId=<authentication ID>] [authzId=<authorization ID>]
310 .B [authz={native|proxyauthz}] [mode=<mode>] [flags=<flags>]
313 .B [tls_cacert=<file>]
314 .B [tls_cacertdir=<path>]
315 .B [tls_reqcert=never|allow|try|demand]
316 .B [tls_ciphersuite=<ciphers>]
317 .B [tls_crlcheck=none|peer|all]
319 Allows to define the parameters of the authentication method that is
320 internally used by the proxy to authorize connections that are
321 authenticated by other databases.
322 The identity defined by this directive, according to the properties
323 associated to the authentication method, is supposed to have auth access
324 on the target server to attributes used on the proxy for authentication
325 and authorization, and to be allowed to authorize the users.
326 This requires to have
328 privileges on a wide set of DNs, e.g.
329 .BR authzTo=dn.subtree:"" ,
330 and the remote server to have
338 for details on these statements and for remarks and drawbacks about
340 The supported bindmethods are
342 \fBnone|simple|sasl\fP
346 is the default, i.e. no \fIidentity assertion\fP is performed.
348 The authz parameter is used to instruct the SASL bind to exploit
350 SASL authorization, if available; since connections are cached,
351 this should only be used when authorizing with a fixed identity
352 (e.g. by means of the
357 Otherwise, the default
359 is used, i.e. the proxyAuthz control (Proxied Authorization, RFC 4370)
360 is added to all operations.
362 The supported modes are:
364 \fB<mode> := {legacy|anonymous|none|self}\fP
370 is given, the proxy always authorizes that identity.
371 .B <authorization ID>
378 The former is supposed to be expanded by the remote server according
379 to the authz rules; see
382 In the latter case, whether or not the
384 prefix is present, the string must pass DN validation and normalization.
388 which implies that the proxy will either perform a simple bind as the
390 or a SASL bind as the
392 and assert the client's identity when it is not anonymous.
393 Direct binds are always proxied.
394 The other modes imply that the proxy will always either perform a simple bind
397 or a SASL bind as the
400 .BR idassert-authzFrom
401 rules (see below), in which case the operation will fail;
402 eventually, it will assert some other identity according to
404 Other identity assertion modes are
408 which respectively mean that the
415 which means that no proxyAuthz control will be used, so the
419 identity will be asserted.
420 For all modes that require the use of the
422 control, on the remote server the proxy identity must have appropriate
424 permissions, or the asserted identities must have appropriate
426 permissions. Note, however, that the ID assertion feature is mostly
427 useful when the asserted identities do not exist on the remote server.
431 \fBoverride,[non-]prescriptive\fP
435 flag is used, identity assertion takes place even when the database
436 is authorizing for the identity of the client, i.e. after binding
437 with the provided identity, and thus authenticating it, the proxy
438 performs the identity assertion using the configured identity and
439 authentication method.
443 flag is used (the default), operations fail with
444 \fIinappropriateAuthentication\fP
445 for those identities whose assertion is not allowed by the
446 .B idassert-authzFrom
450 flag is used, operations are performed anonymously for those identities
451 whose assertion is not allowed by the
452 .B idassert-authzFrom
455 The TLS settings default to the same as the main slapd TLS settings,
458 which defaults to "demand".
460 The identity associated to this directive is also used for privileged
461 operations whenever \fBidassert-bind\fP is defined and \fBacl-bind\fP
462 is not. See \fBacl-bind\fP for details.
466 .B idle-timeout <time>
467 This directive causes a cached connection to be dropped an recreated
468 after it has been idle for the specified time.
469 The value can be specified as
471 [<d>d][<h>h][<m>m][<s>[s]]
473 where <d>, <h>, <m> and <s> are respectively treated as days, hours,
475 If set before any target specification, it affects all targets, unless
476 overridden by any per-target directive.
479 .B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
480 This maps object classes and attributes as in the LDAP backend.
485 .B network-timeout <time>
486 Sets the network timeout value after which
487 .BR poll (2)/ select (2)
490 returns in case of no activity.
491 The value is in seconds, and it can be specified as for
493 If set before any target specification, it affects all targets, unless
494 overridden by any per-target directive.
497 .B nretries {forever|never|<nretries>}
498 This directive defines how many times a bind should be retried
499 in case of temporary failure in contacting a target. If defined
500 before any target specification, it applies to all targets (by default,
503 the global value can be overridden by redefinitions inside each target
507 .B pseudorootdn "<substitute DN in case of rootdn bind>"
508 This directive, if present, sets the DN that will be substituted to
509 the bind DN if a bind with the backend's "rootdn" succeeds.
510 The true "rootdn" of the target server ought not be used; an arbitrary
511 administrative DN should used instead.
514 .B pseudorootpw "<substitute password in case of rootdn bind>"
515 This directive sets the credential that will be used in case a bind
516 with the backend's "rootdn" succeeds, and the bind is propagated to
517 the target using the "pseudorootdn" DN.
519 Note: cleartext credentials must be supplied here; as a consequence,
520 using the pseudorootdn/pseudorootpw directives is inherently unsafe.
524 The rewrite options are described in the "REWRITING" section.
527 .B subtree-exclude "<DN>"
528 This directive instructs back-meta to ignore the current target
529 for operations whose requestDN is subordinate to
531 There may be multiple occurrences of the
533 directive for each of the targets.
536 .B suffixmassage "<virtual naming context>" "<real naming context>"
537 All the directives starting with "rewrite" refer to the rewrite engine
538 that has been added to slapd.
539 The "suffixmassage" directive was introduced in the LDAP backend to
540 allow suffix massaging while proxying.
541 It has been obsoleted by the rewriting tools.
542 However, both for backward compatibility and for ease of configuration
543 when simple suffix massage is required, it has been preserved.
544 It wraps the basic rewriting instructions that perform suffix
545 massaging. See the "REWRITING" section for a detailed list
546 of the rewrite rules it implies.
549 .B t-f-support {NO|yes|discover}
550 enable if the remote server supports absolute filters
551 (see \fIdraft-zeilenga-ldap-t-f\fP for details).
554 support is detected by reading the remote server's root DSE.
555 If set before any target specification, it affects all targets, unless
556 overridden by any per-target directive.
559 .B timeout [<op>=]<val> [...]
560 This directive allows to set per-operation timeouts.
563 \fB<op> ::= bind, add, delete, modrdn, modify, compare, search\fP
565 The overall duration of the \fBsearch\fP operation is controlled either
566 by the \fBtimelimit\fP parameter or by server-side enforced
567 time limits (see \fBtimelimit\fP and \fBlimits\fP in
570 This \fBtimeout\fP parameter controls how long the target can be
571 irresponsive before the operation is aborted.
572 Timeout is meaningless for the remaining operations,
573 \fBunbind\fP and \fBabandon\fP, which do not imply any response,
574 while it is not yet implemented in currently supported \fBextended\fP
576 If no operation is specified, the timeout \fBval\fP affects all
577 supported operations.
578 If specified before any target definition, it affects all targets
579 unless overridden by per-target directives.
581 Note: if the timeout is exceeded, the operation is cancelled
582 (according to the \fBcancel\fP directive);
583 the protocol does not provide any means to rollback operations,
584 so the client will not be notified about the result of the operation,
585 which may eventually succeeded or not.
586 In case the timeout is exceeded during a bind operation, the connection
587 is destroyed, according to RFC4511.
590 .B tls {[try-]start|[try-]propagate}
591 execute the StartTLS extended operation when the connection is initialized;
592 only works if the URI directive protocol scheme is not \fBldaps://\fP.
593 \fBpropagate\fP issues the StartTLS operation only if the original
595 The \fBtry-\fP prefix instructs the proxy to continue operations
596 if the StartTLS operation failed; its use is highly deprecated.
597 If set before any target specification, it affects all targets, unless
598 overridden by any per-target directive.
601 A powerful (and in some sense dangerous) rewrite engine has been added
602 to both the LDAP and Meta backends.
603 While the former can gain limited beneficial effects from rewriting
604 stuff, the latter can become an amazingly powerful tool.
606 Consider a couple of scenarios first.
608 1) Two directory servers share two levels of naming context;
609 say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
610 Then, an unambiguous Meta database can be configured as:
615 suffix "\fBdc=foo,dc=com\fP"
616 uri "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
617 uri "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
621 Operations directed to a specific target can be easily resolved
622 because there are no ambiguities.
623 The only operation that may resolve to multiple targets is a search
624 with base "dc=foo,dc=com" and scope at least "one", which results in
625 spawning two searches to the targets.
627 2a) Two directory servers don't share any portion of naming context,
628 but they'd present as a single DIT
629 [Caveat: uniqueness of (massaged) entries among the two servers is
630 assumed; integrity checks risk to incur in excessive overhead and have
631 not been implemented].
632 Say we have "dc=bar,dc=org" and "o=Foo,c=US",
633 and we'd like them to appear as branches of "dc=foo,dc=com", say
634 "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
635 Then we need to configure our Meta backend as:
640 suffix "dc=foo,dc=com"
642 uri "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
643 suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"
645 uri "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
646 suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
650 Again, operations can be resolved without ambiguity, although
651 some rewriting is required.
652 Notice that the virtual naming context of each target is a branch of
653 the database's naming context; it is rewritten back and forth when
654 operations are performed towards the target servers.
655 What "back and forth" means will be clarified later.
657 When a search with base "dc=foo,dc=com" is attempted, if the
658 scope is "base" it fails with "no such object"; in fact, the
659 common root of the two targets (prior to massaging) does not
661 If the scope is "one", both targets are contacted with the base
662 replaced by each target's base; the scope is derated to "base".
663 In general, a scope "one" search is honored, and the scope is derated,
664 only when the incoming base is at most one level lower of a target's
665 naming context (prior to massaging).
667 Finally, if the scope is "sub" the incoming base is replaced
668 by each target's unmassaged naming context, and the scope
671 2b) Consider the above reported scenario with the two servers
672 sharing the same naming context:
677 suffix "\fBdc=foo,dc=com\fP"
679 uri "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
680 suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"
682 uri "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
683 suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
687 All the previous considerations hold, except that now there is
688 no way to unambiguously resolve a DN.
689 In this case, all the operations that require an unambiguous target
690 selection will fail unless the DN is already cached or a default
692 Practical configurations may result as a combination of all the
695 Note on ACLs: at present you may add whatever ACL rule you desire
696 to to the Meta (and LDAP) backends.
697 However, the meaning of an ACL on a proxy may require some
699 Two philosophies may be considered:
701 a) the remote server dictates the permissions; the proxy simply passes
702 back what it gets from the remote server.
704 b) the remote server unveils "everything"; the proxy is responsible
705 for protecting data from unauthorized access.
707 Of course the latter sounds unreasonable, but it is not.
708 It is possible to imagine scenarios in which a remote host discloses
709 data that can be considered "public" inside an intranet, and a proxy
710 that connects it to the internet may impose additional constraints.
711 To this purpose, the proxy should be able to comply with all the ACL
712 matching criteria that the server supports.
713 This has been achieved with regard to all the criteria supported by
714 slapd except a special subtle case (please drop me a note if you can
715 find other exceptions: <ando@openldap.org>).
720 access to dn="<dn>" attrs=<attr>
721 by dnattr=<dnattr> read
726 cannot be matched iff the attribute that is being requested, <attr>,
727 is NOT <dnattr>, and the attribute that determines membership,
728 <dnattr>, has not been requested (e.g. in a search)
730 In fact this ACL is resolved by slapd using the portion of entry it
731 retrieved from the remote server without requiring any further
732 intervention of the backend, so, if the <dnattr> attribute has not
733 been fetched, the match cannot be assessed because the attribute is
734 not present, not because no value matches the requirement!
736 Note on ACLs and attribute mapping: ACLs are applied to the mapped
737 attributes; for instance, if the attribute locally known as "foo" is
738 mapped to "bar" on a remote server, then local ACLs apply to attribute
739 "foo" and are totally unaware of its remote name.
740 The remote server will check permissions for "bar", and the local
741 server will possibly enforce additional restrictions to "foo".
743 .\" If this section is moved, also update the reference in
744 .\" libraries/librewrite/RATIONALE.
747 A string is rewritten according to a set of rules, called a `rewrite
749 The rules are based on POSIX (''extended'') regular expressions (regex)
750 with substring matching; basic variable substitution and map resolution
751 of substrings is allowed by specific mechanisms detailed in the following.
752 The behavior of pattern matching/substitution can be altered by a set
755 The underlying concept is to build a lightweight rewrite module
756 for the slapd server (initially dedicated to the LDAP backend).
758 An incoming string is matched against a set of rules.
759 Rules are made of a regex match pattern, a substitution pattern
760 and a set of actions, described by a set of flags.
761 In case of match a string rewriting is performed according to the
762 substitution pattern that allows to refer to substrings matched in the
764 The actions, if any, are finally performed.
765 The substitution pattern allows map resolution of substrings.
766 A map is a generic object that maps a substitution pattern to a value.
767 The flags are divided in "Pattern matching Flags" and "Action Flags";
768 the former alter the regex match pattern behavior while the latter
769 alter the action that is taken after substitution.
770 .SH "Pattern Matching Flags"
773 honors case in matching (default is case insensitive)
776 use POSIX ''basic'' regular expressions (default is ''extended'')
781 recursive passes for a specific rule; does not alter the max total count
782 of passes, so it can only enforce a stricter limit for a specific rule.
786 apply the rule once only (default is recursive)
789 stop applying rules in case of match; the current rule is still applied
790 recursively; combine with `:' to apply the current rule only once
794 stop current operation if the rule matches, and issue an `unwilling to
800 rules back and forth (watch for loops!).
801 Note that `G{1}' is implicit in every rule.
804 ignores errors in rule; this means, in case of error, e.g. issued by a
805 map, the error is treated as a missed match.
806 The `unwilling to perform' is not overridden.
812 as return code if the rule matches; the flag does not alter the recursive
813 behavior of the rule, so, to have it performed only once, it must be used
814 in combination with `:', e.g.
816 returns the value `16' after exactly one execution of the rule, if the
818 As a consequence, its behavior is equivalent to `@', with the return
821 or, in other words, `@' is equivalent to `U{0}'.
822 By convention, the freely available codes are above 16 included;
823 the others are reserved.
825 The ordering of the flags can be significant.
826 For instance: `IG{2}' means ignore errors and jump two lines ahead
827 both in case of match and in case of error, while `G{2}I' means ignore
828 errors, but jump two lines ahead only in case of match.
830 More flags (mainly Action Flags) will be added as needed.
831 .SH "Pattern matching:"
836 .SH "Substitution Pattern Syntax:"
837 Everything starting with `%' requires substitution;
839 the only obvious exception is `%%', which is left as is;
841 the basic substitution is `%d', where `d' is a digit;
842 0 means the whole string, while 1-9 is a submatch;
844 a `%' followed by a `{' invokes an advanced substitution.
848 `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
851 where <name> must be a legal name for the map, i.e.
855 <name> ::= [a-z][a-z0-9]* (case insensitive)
856 <op> ::= `>' `|' `&' `&&' `*' `**' `$'
860 and <substitution> must be a legal substitution
861 pattern, with no limits on the nesting level.
866 sub context invocation; <name> must be a legal, already defined
870 external command invocation; <name> must refer to a legal, already
871 defined command name (NOT IMPL.)
874 variable assignment; <name> defines a variable in the running
875 operation structure which can be dereferenced later; operator
877 assigns a variable in the rewrite context scope; operator
879 assigns a variable that scopes the entire session, e.g. its value
880 can be dereferenced later by other rewrite contexts
883 variable dereferencing; <name> must refer to a variable that is
884 defined and assigned for the running operation; operator
886 dereferences a variable scoping the rewrite context; operator
888 dereferences a variable scoping the whole session, e.g. the value
889 is passed across rewrite contexts
892 parameter dereferencing; <name> must refer to an existing parameter;
893 the idea is to make some run-time parameters set by the system
894 available to the rewrite engine, as the client host name, the bind DN
895 if any, constant parameters initialized at config time, and so on;
896 no parameter is currently set by either
900 but constant parameters can be defined in the configuration file
905 Substitution escaping has been delegated to the `%' symbol,
906 which is used instead of `\e' in string substitution patterns
907 because `\e' is already escaped by slapd's low level parsing routines;
908 as a consequence, regex escaping requires two `\e' symbols,
909 e.g. `\fB.*\e.foo\e.bar\fP' must be written as `\fB.*\e\e.foo\e\e.bar\fP'.
911 .\" The symbol can be altered at will by redefining the related macro in
914 .SH "Rewrite context:"
915 A rewrite context is a set of rules which are applied in sequence.
916 The basic idea is to have an application initialize a rewrite
917 engine (think of Apache's mod_rewrite ...) with a set of rewrite
918 contexts; when string rewriting is required, one invokes the
919 appropriate rewrite context with the input string and obtains the
920 newly rewritten one if no errors occur.
922 Each basic server operation is associated to a rewrite context;
923 they are divided in two main groups: client \-> server and
924 server \-> client rewriting.
930 (default) if defined and no specific context
935 searchFilterAttrDN search
937 compareAttrDN compare AVA
941 modifyAttrDN modify AVA
945 exopPasswdDN password modify extended operation DN if proxy
953 searchResult search (only if defined; no default;
954 acts on DN and DN-syntax attributes
956 searchAttrDN search AVA
957 matchedDN all ops (only if applicable)
961 .SH "Basic configuration syntax"
963 .B rewriteEngine { on | off }
964 If `on', the requested rewriting is performed; if `off', no
965 rewriting takes place (an easy way to stop rewriting without
966 altering too much the configuration file).
968 .B rewriteContext <context name> "[ alias <aliased context name> ]"
969 <Context name> is the name that identifies the context, i.e. the name
970 used by the application to refer to the set of rules it contains.
971 It is used also to reference sub contexts in string rewriting.
972 A context may alias another one.
973 In this case the alias context contains no rule, and any reference to
974 it will result in accessing the aliased one.
976 .B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
977 Determines how a string can be rewritten if a pattern is matched.
978 Examples are reported below.
979 .SH "Additional configuration syntax:"
981 .B rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"
982 Allows to define a map that transforms substring rewriting into
984 The map is referenced inside the substitution pattern of a rule.
986 .B rewriteParam <param name> <param value>
987 Sets a value with global scope, that can be dereferenced by the
988 command `%{$paramName}'.
990 .B rewriteMaxPasses <number of passes> [<number of passes per rule>]
991 Sets the maximum number of total rewriting passes that can be
992 performed in a single rewrite operation (to avoid loops).
993 A safe default is set to 100; note that reaching this limit is still
994 treated as a success; recursive invocation of rules is simply
996 The count applies to the rewriting operation as a whole, not
997 to any single rule; an optional per-rule limit can be set.
998 This limit is overridden by setting specific per-rule limits
999 with the `M{n}' flag.
1000 .SH "Configuration examples:"
1002 # set to `off' to disable rewriting
1005 # the rules the "suffixmassage" directive implies
1007 # all dataflow from client to server referring to DNs
1008 rewriteContext default
1009 rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
1011 rewriteContext searchFilter
1012 # all dataflow from server to client
1013 rewriteContext searchResult
1014 rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
1015 rewriteContext searchAttrDN alias searchResult
1016 rewriteContext matchedDN alias searchResult
1018 # Everything defined here goes into the `default' context.
1019 # This rule changes the naming context of anything sent
1020 # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
1022 rewriteRule "(.*)dc=home,[ ]?dc=net"
1023 "%1dc=OpenLDAP, dc=org" ":"
1025 # since a pretty/normalized DN does not include spaces
1026 # after rdn separators, e.g. `,', this rule suffices:
1028 rewriteRule "(.*)dc=home,dc=net"
1029 "%1dc=OpenLDAP,dc=org" ":"
1031 # Start a new context (ends input of the previous one).
1032 # This rule adds blanks between DN parts if not present.
1033 rewriteContext addBlanks
1034 rewriteRule "(.*),([^ ].*)" "%1, %2"
1036 # This one eats blanks
1037 rewriteContext eatBlanks
1038 rewriteRule "(.*),[ ](.*)" "%1,%2"
1040 # Here control goes back to the default rewrite
1041 # context; rules are appended to the existing ones.
1042 # anything that gets here is piped into rule `addBlanks'
1043 rewriteContext default
1044 rewriteRule ".*" "%{>addBlanks(%0)}" ":"
1046 .\" # Anything with `uid=username' is looked up in
1047 .\" # /etc/passwd for gecos (I know it's nearly useless,
1048 .\" # but it is there just as a guideline to implementing
1050 .\" # Note the `I' flag that leaves `uid=username' in place
1051 .\" # if `username' does not have a valid account, and the
1052 .\" # `:' that forces the rule to be processed exactly once.
1053 .\" rewriteContext uid2Gecos
1054 .\" rewriteRule "(.*)uid=([a-z0-9]+),(.+)"
1055 .\" "%1cn=%2{xpasswd},%3" "I:"
1057 .\" # Finally, in a bind, if one uses a `uid=username' DN,
1058 .\" # it is rewritten in `cn=name surname' if possible.
1059 .\" rewriteContext bindDN
1060 .\" rewriteRule ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
1062 # Rewrite the search base according to `default' rules.
1063 rewriteContext searchBase alias default
1065 # Search results with OpenLDAP DN are rewritten back with
1066 # `dc=home,dc=net' naming context, with spaces eaten.
1067 rewriteContext searchResult
1068 rewriteRule "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
1069 "%{>eatBlanks(%1)}dc=home,dc=net" ":"
1071 # Bind with email instead of full DN: we first need
1072 # an ldap map that turns attributes into a DN (the
1073 # argument used when invoking the map is appended to
1074 # the URI and acts as the filter portion)
1075 rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
1077 # Then we need to detect DN made up of a single email,
1078 # e.g. `mail=someone@example.com'; note that the rule
1079 # in case of match stops rewriting; in case of error,
1080 # it is ignored. In case we are mapping virtual
1081 # to real naming contexts, we also need to rewrite
1082 # regular DNs, because the definition of a bindDn
1083 # rewrite context overrides the default definition.
1084 rewriteContext bindDN
1085 rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
1087 # This is a rather sophisticated example. It massages a
1088 # search filter in case who performs the search has
1089 # administrative privileges. First we need to keep
1090 # track of the bind DN of the incoming request, which is
1091 # stored in a variable called `binddn' with session scope,
1092 # and left in place to allow regular binding:
1093 rewriteContext bindDN
1094 rewriteRule ".+" "%{&&binddn(%0)}%0" ":"
1096 # A search filter containing `uid=' is rewritten only
1097 # if an appropriate DN is bound.
1098 # To do this, in the first rule the bound DN is
1099 # dereferenced, while the filter is decomposed in a
1100 # prefix, in the value of the `uid=<arg>' AVA, and
1101 # in a suffix. A tag `<>' is appended to the DN.
1102 # If the DN refers to an entry in the `ou=admin' subtree,
1103 # the filter is rewritten OR-ing the `uid=<arg>' with
1104 # `cn=<arg>'; otherwise it is left as is. This could be
1105 # useful, for instance, to allow apache's auth_ldap-1.4
1106 # module to authenticate users with both `uid' and
1107 # `cn', but only if the request comes from a possible
1108 # `cn=Web auth,ou=admin,dc=home,dc=net' user.
1109 rewriteContext searchFilter
1110 rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
1111 "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
1113 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
1114 "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
1115 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
1117 # This example shows how to strip unwanted DN-valued
1118 # attribute values from a search result; the first rule
1119 # matches DN values below "ou=People,dc=example,dc=com";
1120 # in case of match the rewriting exits successfully.
1121 # The second rule matches everything else and causes
1122 # the value to be rejected.
1123 rewriteContext searchResult
1124 rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
1125 rewriteRule ".*" "" "#"
1127 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
1128 In case the rewritten DN is an LDAP URI, the operation is initiated
1129 towards the host[:port] indicated in the uri, if it does not refer
1130 to the local server.
1134 rewriteRule '^cn=root,.*' '%0' 'G{3}'
1135 rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
1136 rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
1137 rewriteRule '.*' 'ldap://ldap3.my.org/%0' ':@'
1140 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
1144 rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
1147 with the advantage of saving one rewrite pass ...)
1152 backend does not honor all ACL semantics as described in
1153 .BR slapd.access (5).
1154 In general, access checking is delegated to the remote server(s).
1159 pseudo-attribute and to the other attribute values of the entries
1162 operation is honored, which is performed by the frontend.
1164 .SH PROXY CACHE OVERLAY
1165 The proxy cache overlay
1166 allows caching of LDAP search requests (queries) in a local database.
1168 .BR slapo-pcache (5)
1173 default slapd configuration file
1176 .BR slapd\-ldap (5),
1177 .BR slapo\-pcache (5),
1182 Pierangelo Masarati, based on back-ldap by Howard Chu