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 {YES|no}
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.
147 Otherwise, all binds as the rootdn are propagated to the targets.
150 .B quarantine <interval>,<num>[;<interval>,<num>[...]]
151 Turns on quarantine of URIs that returned
152 .IR LDAP_UNAVAILABLE ,
153 so that an attempt to reconnect only occurs at given intervals instead
154 of any time a client requests an operation.
155 The pattern is: retry only after at least
157 seconds elapsed since last attempt, for exactly
159 times; then use the next pattern.
162 for the last pattern is "\fB+\fP", it retries forever; otherwise,
163 no more retries occur.
164 This directive must appear before any target specification;
165 it affects all targets with the same pattern.
168 .B rebind-as-user {NO|yes}
169 If this option is given, the client's bind credentials are remembered
170 for rebinds, when trying to re-establish a broken connection,
171 or when chasing a referral, if
177 .B session\-tracking\-request {NO|yes}
178 Adds session tracking control for all requests.
179 The client's IP and hostname, and the identity associated to each request,
180 if known, are sent to the remote server for informational purposes.
181 This directive is incompatible with setting \fIprotocol\-version\fP to 2.
182 If set before any target specification, it affects all targets, unless
183 overridden by any per-target directive.
186 .B single\-conn {NO|yes}
187 Discards current cached connection when the client rebinds.
190 .B use-temporary-conn {NO|yes}
193 create a temporary connection whenever competing with other threads
194 for a shared one; otherwise, wait until the shared connection is available.
196 .SH TARGET SPECIFICATION
197 Target specification starts with a "uri" directive:
200 .B uri <protocol>://[<host>]/<naming context> [...]
201 The <protocol> part can be anything
202 .BR ldap_initialize (3)
203 accepts ({ldap|ldaps|ldapi} and variants); the <host> may be
204 omitted, defaulting to whatever is set in
206 The <naming context> part is \fImandatory\fP for the first URI,
207 but it \fImust be omitted\fP for subsequent ones, if any.
208 The naming context part must be within the naming context defined for the backend,
213 suffix "\fBdc=foo,dc=com\fP"
214 uri "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
219 The <naming context> part doesn't need to be unique across the targets;
220 it may also match one of the values of the "suffix" directive.
221 Multiple URIs may be defined in a single URI statement.
222 The additional URIs must be separate arguments and must not have any
223 <naming context> part. This causes the underlying library
224 to contact the first server of the list that responds.
225 For example, if \fIl1.foo.com\fP and \fIl2.foo.com\fP are shadows
226 of the same server, the directive
229 suffix "\fBdc=foo,dc=com\fP"
230 uri "ldap://l1.foo.com/\fBdc=foo,dc=com\fP" "ldap://l2.foo.com/"
235 causes \fIl2.foo.com\fP to be contacted whenever \fIl1.foo.com\fP
237 In that case, the URI list is internally rearranged, by moving unavailable
238 URIs to the end, so that further connection attempts occur with respect to
239 the last URI that succeeded.
243 .B acl-authcDN "<administrative DN for access control purposes>"
244 DN which is used to query the target server for acl checking,
245 as in the LDAP backend; it is supposed to have read access
246 on the target server to attributes used on the proxy for acl checking.
247 There is no risk of giving away such values; they are only used to
249 .B The acl-authcDN identity is by no means implicitly used by the proxy
250 .B when the client connects anonymously.
253 .B acl-passwd <password>
254 Password used with the
260 .B bind-timeout <microseconds>
261 This directive defines the timeout, in microseconds, used when polling
262 for response after an asynchronous bind connection. The initial call
263 to ldap_result(3) is performed with a trade-off timeout of 100000 us;
264 if that results in a timeout exceeded, subsequent calls use the value
267 The default value is used also for subsequent calls if
270 If set before any target specification, it affects all targets, unless
271 overridden by any per-target directive.
274 .B chase-referrals {YES|no}
275 enable/disable automatic referral chasing, which is delegated to the
276 underlying libldap, with rebinding eventually performed if the
277 \fBrebind-as-user\fP directive is used. The default is to chase referrals.
278 If set before any target specification, it affects all targets, unless
279 overridden by any per-target directive.
282 .B default-target [<target>]
283 The "default-target" directive can also be used during target specification.
284 With no arguments it marks the current target as the default.
285 The optional number marks target <target> as the default one, starting
287 Target <target> must be defined.
290 .B idassert-authzFrom <authz-regexp>
291 if defined, selects what
293 identities are authorized to exploit the identity assertion feature.
296 follows the rules defined for the
303 for details on the syntax of this field.
308 .B bindmethod=none|simple|sasl [binddn=<simple DN>] [credentials=<simple password>]
309 .B [saslmech=<SASL mech>] [secprops=<properties>] [realm=<realm>]
310 .B [authcId=<authentication ID>] [authzId=<authorization ID>]
311 .B [authz={native|proxyauthz}] [mode=<mode>] [flags=<flags>]
314 .B [tls_cacert=<file>]
315 .B [tls_cacertdir=<path>]
316 .B [tls_reqcert=never|allow|try|demand]
317 .B [tls_ciphersuite=<ciphers>]
318 .B [tls_crlcheck=none|peer|all]
320 Allows to define the parameters of the authentication method that is
321 internally used by the proxy to authorize connections that are
322 authenticated by other databases.
323 The identity defined by this directive, according to the properties
324 associated to the authentication method, is supposed to have auth access
325 on the target server to attributes used on the proxy for authentication
326 and authorization, and to be allowed to authorize the users.
327 This requires to have
329 privileges on a wide set of DNs, e.g.
330 .BR authzTo=dn.subtree:"" ,
331 and the remote server to have
339 for details on these statements and for remarks and drawbacks about
341 The supported bindmethods are
343 \fBnone|simple|sasl\fP
347 is the default, i.e. no \fIidentity assertion\fP is performed.
349 The authz parameter is used to instruct the SASL bind to exploit
351 SASL authorization, if available; since connections are cached,
352 this should only be used when authorizing with a fixed identity
353 (e.g. by means of the
358 Otherwise, the default
360 is used, i.e. the proxyAuthz control (Proxied Authorization, RFC 4370)
361 is added to all operations.
363 The supported modes are:
365 \fB<mode> := {legacy|anonymous|none|self}\fP
371 is given, the proxy always authorizes that identity.
372 .B <authorization ID>
379 The former is supposed to be expanded by the remote server according
380 to the authz rules; see
383 In the latter case, whether or not the
385 prefix is present, the string must pass DN validation and normalization.
389 which implies that the proxy will either perform a simple bind as the
391 or a SASL bind as the
393 and assert the client's identity when it is not anonymous.
394 Direct binds are always proxied.
395 The other modes imply that the proxy will always either perform a simple bind
398 or a SASL bind as the
401 .BR idassert-authzFrom
402 rules (see below), in which case the operation will fail;
403 eventually, it will assert some other identity according to
405 Other identity assertion modes are
409 which respectively mean that the
416 which means that no proxyAuthz control will be used, so the
420 identity will be asserted.
421 For all modes that require the use of the
423 control, on the remote server the proxy identity must have appropriate
425 permissions, or the asserted identities must have appropriate
427 permissions. Note, however, that the ID assertion feature is mostly
428 useful when the asserted identities do not exist on the remote server.
432 \fBoverride,[non-]prescriptive\fP
436 flag is used, identity assertion takes place even when the database
437 is authorizing for the identity of the client, i.e. after binding
438 with the provided identity, and thus authenticating it, the proxy
439 performs the identity assertion using the configured identity and
440 authentication method.
444 flag is used (the default), operations fail with
445 \fIinappropriateAuthentication\fP
446 for those identities whose assertion is not allowed by the
447 .B idassert-authzFrom
451 flag is used, operations are performed anonymously for those identities
452 whose assertion is not allowed by the
453 .B idassert-authzFrom
456 The TLS settings default to the same as the main slapd TLS settings,
459 which defaults to "demand".
461 The identity associated to this directive is also used for privileged
462 operations whenever \fBidassert-bind\fP is defined and \fBacl-bind\fP
463 is not. See \fBacl-bind\fP for details.
467 .B idle-timeout <time>
468 This directive causes a cached connection to be dropped an recreated
469 after it has been idle for the specified time.
470 The value can be specified as
472 [<d>d][<h>h][<m>m][<s>[s]]
474 where <d>, <h>, <m> and <s> are respectively treated as days, hours,
476 If set before any target specification, it affects all targets, unless
477 overridden by any per-target directive.
480 .B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
481 This maps object classes and attributes as in the LDAP backend.
486 .B network-timeout <time>
487 Sets the network timeout value after which
488 .BR poll (2)/ select (2)
491 returns in case of no activity.
492 The value is in seconds, and it can be specified as for
494 If set before any target specification, it affects all targets, unless
495 overridden by any per-target directive.
498 .B nretries {forever|never|<nretries>}
499 This directive defines how many times a bind should be retried
500 in case of temporary failure in contacting a target. If defined
501 before any target specification, it applies to all targets (by default,
504 the global value can be overridden by redefinitions inside each target
508 .B pseudorootdn "<substitute DN in case of rootdn bind>"
509 This directive, if present, sets the DN that will be substituted to
510 the bind DN if a bind with the backend's "rootdn" succeeds.
511 The true "rootdn" of the target server ought not be used; an arbitrary
512 administrative DN should used instead.
515 .B pseudorootpw "<substitute password in case of rootdn bind>"
516 This directive sets the credential that will be used in case a bind
517 with the backend's "rootdn" succeeds, and the bind is propagated to
518 the target using the "pseudorootdn" DN.
520 Note: cleartext credentials must be supplied here; as a consequence,
521 using the pseudorootdn/pseudorootpw directives is inherently unsafe.
525 The rewrite options are described in the "REWRITING" section.
528 .B subtree-exclude "<DN>"
529 This directive instructs back-meta to ignore the current target
530 for operations whose requestDN is subordinate to
532 There may be multiple occurrences of the
534 directive for each of the targets.
537 .B suffixmassage "<virtual naming context>" "<real naming context>"
538 All the directives starting with "rewrite" refer to the rewrite engine
539 that has been added to slapd.
540 The "suffixmassage" directive was introduced in the LDAP backend to
541 allow suffix massaging while proxying.
542 It has been obsoleted by the rewriting tools.
543 However, both for backward compatibility and for ease of configuration
544 when simple suffix massage is required, it has been preserved.
545 It wraps the basic rewriting instructions that perform suffix
546 massaging. See the "REWRITING" section for a detailed list
547 of the rewrite rules it implies.
550 .B t-f-support {NO|yes|discover}
551 enable if the remote server supports absolute filters
552 (see \fIdraft-zeilenga-ldap-t-f\fP for details).
555 support is detected by reading the remote server's root DSE.
556 If set before any target specification, it affects all targets, unless
557 overridden by any per-target directive.
560 .B timeout [<op>=]<val> [...]
561 This directive allows to set per-operation timeouts.
564 \fB<op> ::= bind, add, delete, modrdn, modify, compare, search\fP
566 The overall duration of the \fBsearch\fP operation is controlled either
567 by the \fBtimelimit\fP parameter or by server-side enforced
568 time limits (see \fBtimelimit\fP and \fBlimits\fP in
571 This \fBtimeout\fP parameter controls how long the target can be
572 irresponsive before the operation is aborted.
573 Timeout is meaningless for the remaining operations,
574 \fBunbind\fP and \fBabandon\fP, which do not imply any response,
575 while it is not yet implemented in currently supported \fBextended\fP
577 If no operation is specified, the timeout \fBval\fP affects all
578 supported operations.
579 If specified before any target definition, it affects all targets
580 unless overridden by per-target directives.
582 Note: if the timeout is exceeded, the operation is cancelled
583 (according to the \fBcancel\fP directive);
584 the protocol does not provide any means to rollback operations,
585 so the client will not be notified about the result of the operation,
586 which may eventually succeeded or not.
587 In case the timeout is exceeded during a bind operation, the connection
588 is destroyed, according to RFC4511.
591 .B tls {[try-]start|[try-]propagate}
592 execute the StartTLS extended operation when the connection is initialized;
593 only works if the URI directive protocol scheme is not \fBldaps://\fP.
594 \fBpropagate\fP issues the StartTLS operation only if the original
596 The \fBtry-\fP prefix instructs the proxy to continue operations
597 if the StartTLS operation failed; its use is highly deprecated.
598 If set before any target specification, it affects all targets, unless
599 overridden by any per-target directive.
602 A powerful (and in some sense dangerous) rewrite engine has been added
603 to both the LDAP and Meta backends.
604 While the former can gain limited beneficial effects from rewriting
605 stuff, the latter can become an amazingly powerful tool.
607 Consider a couple of scenarios first.
609 1) Two directory servers share two levels of naming context;
610 say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
611 Then, an unambiguous Meta database can be configured as:
616 suffix "\fBdc=foo,dc=com\fP"
617 uri "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
618 uri "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
622 Operations directed to a specific target can be easily resolved
623 because there are no ambiguities.
624 The only operation that may resolve to multiple targets is a search
625 with base "dc=foo,dc=com" and scope at least "one", which results in
626 spawning two searches to the targets.
628 2a) Two directory servers don't share any portion of naming context,
629 but they'd present as a single DIT
630 [Caveat: uniqueness of (massaged) entries among the two servers is
631 assumed; integrity checks risk to incur in excessive overhead and have
632 not been implemented].
633 Say we have "dc=bar,dc=org" and "o=Foo,c=US",
634 and we'd like them to appear as branches of "dc=foo,dc=com", say
635 "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
636 Then we need to configure our Meta backend as:
641 suffix "dc=foo,dc=com"
643 uri "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
644 suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"
646 uri "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
647 suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
651 Again, operations can be resolved without ambiguity, although
652 some rewriting is required.
653 Notice that the virtual naming context of each target is a branch of
654 the database's naming context; it is rewritten back and forth when
655 operations are performed towards the target servers.
656 What "back and forth" means will be clarified later.
658 When a search with base "dc=foo,dc=com" is attempted, if the
659 scope is "base" it fails with "no such object"; in fact, the
660 common root of the two targets (prior to massaging) does not
662 If the scope is "one", both targets are contacted with the base
663 replaced by each target's base; the scope is derated to "base".
664 In general, a scope "one" search is honored, and the scope is derated,
665 only when the incoming base is at most one level lower of a target's
666 naming context (prior to massaging).
668 Finally, if the scope is "sub" the incoming base is replaced
669 by each target's unmassaged naming context, and the scope
672 2b) Consider the above reported scenario with the two servers
673 sharing the same naming context:
678 suffix "\fBdc=foo,dc=com\fP"
680 uri "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
681 suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"
683 uri "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
684 suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
688 All the previous considerations hold, except that now there is
689 no way to unambiguously resolve a DN.
690 In this case, all the operations that require an unambiguous target
691 selection will fail unless the DN is already cached or a default
693 Practical configurations may result as a combination of all the
696 Note on ACLs: at present you may add whatever ACL rule you desire
697 to to the Meta (and LDAP) backends.
698 However, the meaning of an ACL on a proxy may require some
700 Two philosophies may be considered:
702 a) the remote server dictates the permissions; the proxy simply passes
703 back what it gets from the remote server.
705 b) the remote server unveils "everything"; the proxy is responsible
706 for protecting data from unauthorized access.
708 Of course the latter sounds unreasonable, but it is not.
709 It is possible to imagine scenarios in which a remote host discloses
710 data that can be considered "public" inside an intranet, and a proxy
711 that connects it to the internet may impose additional constraints.
712 To this purpose, the proxy should be able to comply with all the ACL
713 matching criteria that the server supports.
714 This has been achieved with regard to all the criteria supported by
715 slapd except a special subtle case (please drop me a note if you can
716 find other exceptions: <ando@openldap.org>).
721 access to dn="<dn>" attrs=<attr>
722 by dnattr=<dnattr> read
727 cannot be matched iff the attribute that is being requested, <attr>,
728 is NOT <dnattr>, and the attribute that determines membership,
729 <dnattr>, has not been requested (e.g. in a search)
731 In fact this ACL is resolved by slapd using the portion of entry it
732 retrieved from the remote server without requiring any further
733 intervention of the backend, so, if the <dnattr> attribute has not
734 been fetched, the match cannot be assessed because the attribute is
735 not present, not because no value matches the requirement!
737 Note on ACLs and attribute mapping: ACLs are applied to the mapped
738 attributes; for instance, if the attribute locally known as "foo" is
739 mapped to "bar" on a remote server, then local ACLs apply to attribute
740 "foo" and are totally unaware of its remote name.
741 The remote server will check permissions for "bar", and the local
742 server will possibly enforce additional restrictions to "foo".
744 .\" If this section is moved, also update the reference in
745 .\" libraries/librewrite/RATIONALE.
748 A string is rewritten according to a set of rules, called a `rewrite
750 The rules are based on POSIX (''extended'') regular expressions (regex)
751 with substring matching; basic variable substitution and map resolution
752 of substrings is allowed by specific mechanisms detailed in the following.
753 The behavior of pattern matching/substitution can be altered by a set
756 The underlying concept is to build a lightweight rewrite module
757 for the slapd server (initially dedicated to the LDAP backend).
759 An incoming string is matched against a set of rules.
760 Rules are made of a regex match pattern, a substitution pattern
761 and a set of actions, described by a set of flags.
762 In case of match a string rewriting is performed according to the
763 substitution pattern that allows to refer to substrings matched in the
765 The actions, if any, are finally performed.
766 The substitution pattern allows map resolution of substrings.
767 A map is a generic object that maps a substitution pattern to a value.
768 The flags are divided in "Pattern matching Flags" and "Action Flags";
769 the former alter the regex match pattern behavior while the latter
770 alter the action that is taken after substitution.
771 .SH "Pattern Matching Flags"
774 honors case in matching (default is case insensitive)
777 use POSIX ''basic'' regular expressions (default is ''extended'')
782 recursive passes for a specific rule; does not alter the max total count
783 of passes, so it can only enforce a stricter limit for a specific rule.
787 apply the rule once only (default is recursive)
790 stop applying rules in case of match; the current rule is still applied
791 recursively; combine with `:' to apply the current rule only once
795 stop current operation if the rule matches, and issue an `unwilling to
801 rules back and forth (watch for loops!).
802 Note that `G{1}' is implicit in every rule.
805 ignores errors in rule; this means, in case of error, e.g. issued by a
806 map, the error is treated as a missed match.
807 The `unwilling to perform' is not overridden.
813 as return code if the rule matches; the flag does not alter the recursive
814 behavior of the rule, so, to have it performed only once, it must be used
815 in combination with `:', e.g.
817 returns the value `16' after exactly one execution of the rule, if the
819 As a consequence, its behavior is equivalent to `@', with the return
822 or, in other words, `@' is equivalent to `U{0}'.
823 By convention, the freely available codes are above 16 included;
824 the others are reserved.
826 The ordering of the flags can be significant.
827 For instance: `IG{2}' means ignore errors and jump two lines ahead
828 both in case of match and in case of error, while `G{2}I' means ignore
829 errors, but jump two lines ahead only in case of match.
831 More flags (mainly Action Flags) will be added as needed.
832 .SH "Pattern matching:"
837 .SH "Substitution Pattern Syntax:"
838 Everything starting with `%' requires substitution;
840 the only obvious exception is `%%', which is left as is;
842 the basic substitution is `%d', where `d' is a digit;
843 0 means the whole string, while 1-9 is a submatch;
845 a `%' followed by a `{' invokes an advanced substitution.
849 `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
852 where <name> must be a legal name for the map, i.e.
856 <name> ::= [a-z][a-z0-9]* (case insensitive)
857 <op> ::= `>' `|' `&' `&&' `*' `**' `$'
861 and <substitution> must be a legal substitution
862 pattern, with no limits on the nesting level.
867 sub context invocation; <name> must be a legal, already defined
871 external command invocation; <name> must refer to a legal, already
872 defined command name (NOT IMPL.)
875 variable assignment; <name> defines a variable in the running
876 operation structure which can be dereferenced later; operator
878 assigns a variable in the rewrite context scope; operator
880 assigns a variable that scopes the entire session, e.g. its value
881 can be dereferenced later by other rewrite contexts
884 variable dereferencing; <name> must refer to a variable that is
885 defined and assigned for the running operation; operator
887 dereferences a variable scoping the rewrite context; operator
889 dereferences a variable scoping the whole session, e.g. the value
890 is passed across rewrite contexts
893 parameter dereferencing; <name> must refer to an existing parameter;
894 the idea is to make some run-time parameters set by the system
895 available to the rewrite engine, as the client host name, the bind DN
896 if any, constant parameters initialized at config time, and so on;
897 no parameter is currently set by either
901 but constant parameters can be defined in the configuration file
906 Substitution escaping has been delegated to the `%' symbol,
907 which is used instead of `\e' in string substitution patterns
908 because `\e' is already escaped by slapd's low level parsing routines;
909 as a consequence, regex escaping requires two `\e' symbols,
910 e.g. `\fB.*\e.foo\e.bar\fP' must be written as `\fB.*\e\e.foo\e\e.bar\fP'.
912 .\" The symbol can be altered at will by redefining the related macro in
915 .SH "Rewrite context:"
916 A rewrite context is a set of rules which are applied in sequence.
917 The basic idea is to have an application initialize a rewrite
918 engine (think of Apache's mod_rewrite ...) with a set of rewrite
919 contexts; when string rewriting is required, one invokes the
920 appropriate rewrite context with the input string and obtains the
921 newly rewritten one if no errors occur.
923 Each basic server operation is associated to a rewrite context;
924 they are divided in two main groups: client \-> server and
925 server \-> client rewriting.
931 (default) if defined and no specific context
936 searchFilterAttrDN search
938 compareAttrDN compare AVA
942 modifyAttrDN modify AVA
946 exopPasswdDN password modify extended operation DN if proxy
954 searchResult search (only if defined; no default;
955 acts on DN and DN-syntax attributes
957 searchAttrDN search AVA
958 matchedDN all ops (only if applicable)
962 .SH "Basic configuration syntax"
964 .B rewriteEngine { on | off }
965 If `on', the requested rewriting is performed; if `off', no
966 rewriting takes place (an easy way to stop rewriting without
967 altering too much the configuration file).
969 .B rewriteContext <context name> "[ alias <aliased context name> ]"
970 <Context name> is the name that identifies the context, i.e. the name
971 used by the application to refer to the set of rules it contains.
972 It is used also to reference sub contexts in string rewriting.
973 A context may alias another one.
974 In this case the alias context contains no rule, and any reference to
975 it will result in accessing the aliased one.
977 .B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
978 Determines how a string can be rewritten if a pattern is matched.
979 Examples are reported below.
980 .SH "Additional configuration syntax:"
982 .B rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"
983 Allows to define a map that transforms substring rewriting into
985 The map is referenced inside the substitution pattern of a rule.
987 .B rewriteParam <param name> <param value>
988 Sets a value with global scope, that can be dereferenced by the
989 command `%{$paramName}'.
991 .B rewriteMaxPasses <number of passes> [<number of passes per rule>]
992 Sets the maximum number of total rewriting passes that can be
993 performed in a single rewrite operation (to avoid loops).
994 A safe default is set to 100; note that reaching this limit is still
995 treated as a success; recursive invocation of rules is simply
997 The count applies to the rewriting operation as a whole, not
998 to any single rule; an optional per-rule limit can be set.
999 This limit is overridden by setting specific per-rule limits
1000 with the `M{n}' flag.
1001 .SH "Configuration examples:"
1003 # set to `off' to disable rewriting
1006 # the rules the "suffixmassage" directive implies
1008 # all dataflow from client to server referring to DNs
1009 rewriteContext default
1010 rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
1012 rewriteContext searchFilter
1013 # all dataflow from server to client
1014 rewriteContext searchResult
1015 rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
1016 rewriteContext searchAttrDN alias searchResult
1017 rewriteContext matchedDN alias searchResult
1019 # Everything defined here goes into the `default' context.
1020 # This rule changes the naming context of anything sent
1021 # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
1023 rewriteRule "(.*)dc=home,[ ]?dc=net"
1024 "%1dc=OpenLDAP, dc=org" ":"
1026 # since a pretty/normalized DN does not include spaces
1027 # after rdn separators, e.g. `,', this rule suffices:
1029 rewriteRule "(.*)dc=home,dc=net"
1030 "%1dc=OpenLDAP,dc=org" ":"
1032 # Start a new context (ends input of the previous one).
1033 # This rule adds blanks between DN parts if not present.
1034 rewriteContext addBlanks
1035 rewriteRule "(.*),([^ ].*)" "%1, %2"
1037 # This one eats blanks
1038 rewriteContext eatBlanks
1039 rewriteRule "(.*),[ ](.*)" "%1,%2"
1041 # Here control goes back to the default rewrite
1042 # context; rules are appended to the existing ones.
1043 # anything that gets here is piped into rule `addBlanks'
1044 rewriteContext default
1045 rewriteRule ".*" "%{>addBlanks(%0)}" ":"
1047 .\" # Anything with `uid=username' is looked up in
1048 .\" # /etc/passwd for gecos (I know it's nearly useless,
1049 .\" # but it is there just as a guideline to implementing
1051 .\" # Note the `I' flag that leaves `uid=username' in place
1052 .\" # if `username' does not have a valid account, and the
1053 .\" # `:' that forces the rule to be processed exactly once.
1054 .\" rewriteContext uid2Gecos
1055 .\" rewriteRule "(.*)uid=([a-z0-9]+),(.+)"
1056 .\" "%1cn=%2{xpasswd},%3" "I:"
1058 .\" # Finally, in a bind, if one uses a `uid=username' DN,
1059 .\" # it is rewritten in `cn=name surname' if possible.
1060 .\" rewriteContext bindDN
1061 .\" rewriteRule ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
1063 # Rewrite the search base according to `default' rules.
1064 rewriteContext searchBase alias default
1066 # Search results with OpenLDAP DN are rewritten back with
1067 # `dc=home,dc=net' naming context, with spaces eaten.
1068 rewriteContext searchResult
1069 rewriteRule "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
1070 "%{>eatBlanks(%1)}dc=home,dc=net" ":"
1072 # Bind with email instead of full DN: we first need
1073 # an ldap map that turns attributes into a DN (the
1074 # argument used when invoking the map is appended to
1075 # the URI and acts as the filter portion)
1076 rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
1078 # Then we need to detect DN made up of a single email,
1079 # e.g. `mail=someone@example.com'; note that the rule
1080 # in case of match stops rewriting; in case of error,
1081 # it is ignored. In case we are mapping virtual
1082 # to real naming contexts, we also need to rewrite
1083 # regular DNs, because the definition of a bindDn
1084 # rewrite context overrides the default definition.
1085 rewriteContext bindDN
1086 rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
1088 # This is a rather sophisticated example. It massages a
1089 # search filter in case who performs the search has
1090 # administrative privileges. First we need to keep
1091 # track of the bind DN of the incoming request, which is
1092 # stored in a variable called `binddn' with session scope,
1093 # and left in place to allow regular binding:
1094 rewriteContext bindDN
1095 rewriteRule ".+" "%{&&binddn(%0)}%0" ":"
1097 # A search filter containing `uid=' is rewritten only
1098 # if an appropriate DN is bound.
1099 # To do this, in the first rule the bound DN is
1100 # dereferenced, while the filter is decomposed in a
1101 # prefix, in the value of the `uid=<arg>' AVA, and
1102 # in a suffix. A tag `<>' is appended to the DN.
1103 # If the DN refers to an entry in the `ou=admin' subtree,
1104 # the filter is rewritten OR-ing the `uid=<arg>' with
1105 # `cn=<arg>'; otherwise it is left as is. This could be
1106 # useful, for instance, to allow apache's auth_ldap-1.4
1107 # module to authenticate users with both `uid' and
1108 # `cn', but only if the request comes from a possible
1109 # `cn=Web auth,ou=admin,dc=home,dc=net' user.
1110 rewriteContext searchFilter
1111 rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
1112 "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
1114 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
1115 "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
1116 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
1118 # This example shows how to strip unwanted DN-valued
1119 # attribute values from a search result; the first rule
1120 # matches DN values below "ou=People,dc=example,dc=com";
1121 # in case of match the rewriting exits successfully.
1122 # The second rule matches everything else and causes
1123 # the value to be rejected.
1124 rewriteContext searchResult
1125 rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
1126 rewriteRule ".*" "" "#"
1128 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
1129 In case the rewritten DN is an LDAP URI, the operation is initiated
1130 towards the host[:port] indicated in the uri, if it does not refer
1131 to the local server.
1135 rewriteRule '^cn=root,.*' '%0' 'G{3}'
1136 rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
1137 rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
1138 rewriteRule '.*' 'ldap://ldap3.my.org/%0' ':@'
1141 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
1145 rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
1148 with the advantage of saving one rewrite pass ...)
1153 backend does not honor all ACL semantics as described in
1154 .BR slapd.access (5).
1155 In general, access checking is delegated to the remote server(s).
1160 pseudo-attribute and to the other attribute values of the entries
1163 operation is honored, which is performed by the frontend.
1165 .SH PROXY CACHE OVERLAY
1166 The proxy cache overlay
1167 allows caching of LDAP search requests (queries) in a local database.
1169 .BR slapo-pcache (5)
1174 default slapd configuration file
1177 .BR slapd\-ldap (5),
1178 .BR slapo\-pcache (5),
1183 Pierangelo Masarati, based on back-ldap by Howard Chu