1 .TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" Copyright 1998-2006 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
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 is because operational attributes related to entry creation and
77 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 off, so its use
80 is redundant and should be omitted, because the lastmod directive will
81 be deprecated in the future.
83 .SH SPECIAL CONFIGURATION DIRECTIVES
84 Target configuration starts with the "uri" directive.
85 All the configuration directives that are not specific to targets
86 should be defined first for clarity, including those that are common
91 .B default-target none
92 This directive forces the backend to reject all those operations
93 that must resolve to a single target in case none or multiple
95 They include: add, delete, modify, modrdn; compare is not included, as
96 well as bind since, as they don't alter entries, in case of multiple
97 matches an attempt is made to perform the operation on any candidate
98 target, with the constraint that at most one must succeed.
99 This directive can also be used when processing targets to mark a
100 specific target as default.
103 .B dncache-ttl {DISABLED|forever|<ttl>}
104 This directive sets the time-to-live of the DN cache.
105 This caches the target that holds a given DN to speed up target
106 selection in case multiple targets would result from an uncached
107 search; forever means cache never expires; disabled means no DN
108 caching; otherwise a valid ( > 0 ) ttl is required, in the format
115 This directive causes a cached connection to be dropped an recreated
116 after a given ttl, regardless of being idle or not.
119 .B onerr {CONTINUE|stop}
120 This directive allows to select the behavior in case an error is returned
121 by one target during a search.
122 The default, \fBcontinue\fP, consists in continuing the operation,
123 trying to return as much data as possible.
124 If this statement is set to \fBstop\fP, the search is terminated as soon
125 as an error is returned by one target, and the error is immediately
126 propagated to the client.
129 .B protocol\-version {0,2,3}
130 This directive indicates what protocol version must be used to contact
132 If set to 0 (the default), the proxy uses the same protocol version
133 used by the client, otherwise the requested protocol is used.
134 The proxy returns \fIunwillingToPerform\fP if an operation that is
135 incompatible with the requested protocol is attempted.
136 If set before any target specification, it affects all targets, unless
137 overridden by any per-target directive.
140 .B pseudoroot-bind-defer {NO|yes}
141 This directive, when set to
143 causes the authentication to the remote servers with the pseudo-root
144 identity to be deferred until actually needed by subsequent operations.
147 .B quarantine <interval>,<num>[;<interval>,<num>[...]]
148 Turns on quarantine of URIs that returned
149 .IR LDAP_UNAVAILABLE ,
150 so that an attempt to reconnect only occurs at given intervals instead
151 of any time a client requests an operation.
152 The pattern is: retry only after at least
154 seconds elapsed since last attempt, for exactly
156 times; then use the next pattern.
159 for the last pattern is "\fB+\fP", it retries forever; otherwise,
160 no more retries occur.
161 This directive must appear before any target specification;
162 it affects all targets with the same pattern.
165 .B rebind-as-user {NO|yes}
166 If this option is given, the client's bind credentials are remembered
167 for rebinds when chasing referrals.
170 .B single\-conn {NO|yes}
171 Discards current cached connection when the client rebinds.
173 .SH TARGET SPECIFICATION
174 Target specification starts with a "uri" directive:
177 .B uri <protocol>://[<host>[:<port>]]/<naming context>
178 The "server" directive that was allowed in the LDAP backend (although
179 deprecated) has been completely discarded in the Meta backend.
180 The <protocol> part can be anything
181 .BR ldap_initialize (3)
182 accepts ({ldap|ldaps|ldapi} and variants); <host> and <port> may be
183 omitted, defaulting to whatever is set in
185 The <naming context> part is mandatory.
186 It must end with one of the naming contexts defined for the backend,
191 suffix "\fBdc=foo,dc=com\fP"
192 uri "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
197 The <naming context> part doesn't need to be unique across the targets;
198 it may also match one of the values of the "suffix" directive.
199 Multiple URIs may be defined in a single argument. The URIs must
200 be separated by TABs (e.g. '\\t'; commas or spaces, unlike back-ldap,
202 because they are legal in the <naming context>, and we don't want to use
203 URL-encoded <naming context>s), and the additional URIs must have
204 no <naming context> part. This causes the underlying library
205 to contact the first server of the list that responds.
206 For example, if \fIl1.foo.com\fP and \fIl2.foo.com\fP are shadows
207 of the same server, the directive
210 suffix "\fBdc=foo,dc=com\fP"
211 uri "ldap://l1.foo.com/\fBdc=foo,dc=com\fP ldap://l2.foo.com/"
216 causes \fIl2.foo.com\fP to be contacted whenever \fIl1.foo.com\fP
221 .B acl-authcDN "<administrative DN for access control purposes>"
222 DN which is used to query the target server for acl checking,
223 as in the LDAP backend; it is supposed to have read access
224 on the target server to attributes used on the proxy for acl checking.
225 There is no risk of giving away such values; they are only used to
227 .B The acl-authcDN identity is by no means implicitly used by the proxy
228 .B when the client connects anonymously.
231 .B acl-passwd <password>
232 Password used with the
238 .B bind-timeout <microseconds>
239 This directive defines the timeout, in microseconds, used when polling
240 for response after an asynchronous bind connection. The initial call
241 to ldap_result(3) is performed with a trade-off timeout of 100000 us;
242 if that results in a timeout exceeded, subsequent calls use the value
245 The default value is used also for subsequent calls if
248 If set before any target specification, it affects all targets, unless
249 overridden by any per-target directive.
252 .B chase-referrals {YES|no}
253 enable/disable automatic referral chasing, which is delegated to the
254 underlying libldap, with rebinding eventually performed if the
255 \fBrebind-as-user\fP directive is used. The default is to chase referrals.
256 If set before any target specification, it affects all targets, unless
257 overridden by any per-target directive.
260 .B default-target [<target>]
261 The "default-target" directive can also be used during target specification.
262 With no arguments it marks the current target as the default.
263 The optional number marks target <target> as the default one, starting
265 Target <target> must be defined.
268 .B idle-timeout <time>
269 This directive causes a cached connection to be dropped an recreated
270 after it has been idle for the specified time.
271 The value can be specified as
273 [<d>d][<h>h][<m>m][<s>[s]]
275 where <d>, <h>, <m> and <s> are respectively treated as days, hours,
277 If set before any target specification, it affects all targets, unless
278 overridden by any per-target directive.
281 .B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
282 This maps object classes and attributes as in the LDAP backend.
287 .B nretries {forever|never|<nretries>}
288 This directive defines how many times a bind should be retried
289 in case of temporary failure in contacting a target. If defined
290 before any target specification, it applies to all targets (by default,
293 the global value can be overridden by redefinitions inside each target
297 .B pseudorootdn "<substitute DN in case of rootdn bind>"
298 This directive, if present, sets the DN that will be substituted to
299 the bind DN if a bind with the backend's "rootdn" succeeds.
300 The true "rootdn" of the target server ought not be used; an arbitrary
301 administrative DN should used instead.
304 .B pseudorootpw "<substitute password in case of rootdn bind>"
305 This directive sets the credential that will be used in case a bind
306 with the backend's "rootdn" succeeds, and the bind is propagated to
307 the target using the "pseudorootdn" DN.
309 Note: cleartext credentials must be supplied here; as a consequence,
310 using the pseudorootdn/pseudorootpw directives is inherently unsafe.
314 The rewrite options are described in the "REWRITING" section.
317 .B subtree-exclude "<DN>"
318 This directive instructs back-meta to ignore the current target
319 for operations whose requestDN is subordinate to
321 There may be multiple occurrences of the
323 directive for each of the targets.
326 .B suffixmassage "<virtual naming context>" "<real naming context>"
327 All the directives starting with "rewrite" refer to the rewrite engine
328 that has been added to slapd.
329 The "suffixmassage" directive was introduced in the LDAP backend to
330 allow suffix massaging while proxying.
331 It has been obsoleted by the rewriting tools.
332 However, both for backward compatibility and for ease of configuration
333 when simple suffix massage is required, it has been preserved.
334 It wraps the basic rewriting instructions that perform suffix
335 massaging. See the "REWRITING" section for a detailed list
336 of the rewrite rules it implies.
339 .B t-f-support {NO|yes|discover}
340 enable if the remote server supports absolute filters
341 (see \fIdraft-zeilenga-ldap-t-f\fP for details).
344 support is detected by reading the remote server's root DSE.
345 If set before any target specification, it affects all targets, unless
346 overridden by any per-target directive.
349 .B timeout [{add|delete|modify|modrdn}=]<seconds> [...]
350 This directive allows to set per-database, per-target and per-operation
352 If no operation is specified, it affects all.
353 Currently, only write operations are addressed, because searches
354 can already be limited by means of the
358 for details), and other operations are not supposed to incur into the
360 Note: if the timelimit is exceeded, the operation is abandoned;
361 the protocol does not provide any means to rollback the operation,
362 so the client will not know if the operation eventually succeeded or not.
363 If set before any target specification, it affects all targets, unless
364 overridden by any per-target directive.
367 .B tls {[try-]start|[try-]propagate}
368 execute the StartTLS extended operation when the connection is initialized;
369 only works if the URI directive protocol scheme is not \fBldaps://\fP.
370 \fBpropagate\fP issues the StartTLS operation only if the original
372 The \fBtry-\fP prefix instructs the proxy to continue operations
373 if the StartTLS operation failed; its use is highly deprecated.
374 If set before any target specification, it affects all targets, unless
375 overridden by any per-target directive.
378 A powerful (and in some sense dangerous) rewrite engine has been added
379 to both the LDAP and Meta backends.
380 While the former can gain limited beneficial effects from rewriting
381 stuff, the latter can become an amazingly powerful tool.
383 Consider a couple of scenarios first.
385 1) Two directory servers share two levels of naming context;
386 say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
387 Then, an unambiguous Meta database can be configured as:
392 suffix "\fBdc=foo,dc=com\fP"
393 uri "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
394 uri "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
398 Operations directed to a specific target can be easily resolved
399 because there are no ambiguities.
400 The only operation that may resolve to multiple targets is a search
401 with base "dc=foo,dc=com" and scope at least "one", which results in
402 spawning two searches to the targets.
404 2a) Two directory servers don't share any portion of naming context,
405 but they'd present as a single DIT
406 [Caveat: uniqueness of (massaged) entries among the two servers is
407 assumed; integrity checks risk to incur in excessive overhead and have
408 not been implemented].
409 Say we have "dc=bar,dc=org" and "o=Foo,c=US",
410 and we'd like them to appear as branches of "dc=foo,dc=com", say
411 "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
412 Then we need to configure our Meta backend as:
417 suffix "dc=foo,dc=com"
419 uri "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
420 suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"
422 uri "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
423 suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
427 Again, operations can be resolved without ambiguity, although
428 some rewriting is required.
429 Notice that the virtual naming context of each target is a branch of
430 the database's naming context; it is rewritten back and forth when
431 operations are performed towards the target servers.
432 What "back and forth" means will be clarified later.
434 When a search with base "dc=foo,dc=com" is attempted, if the
435 scope is "base" it fails with "no such object"; in fact, the
436 common root of the two targets (prior to massaging) does not
438 If the scope is "one", both targets are contacted with the base
439 replaced by each target's base; the scope is derated to "base".
440 In general, a scope "one" search is honored, and the scope is derated,
441 only when the incoming base is at most one level lower of a target's
442 naming context (prior to massaging).
444 Finally, if the scope is "sub" the incoming base is replaced
445 by each target's unmassaged naming context, and the scope
448 2b) Consider the above reported scenario with the two servers
449 sharing the same naming context:
454 suffix "\fBdc=foo,dc=com\fP"
456 uri "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
457 suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"
459 uri "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
460 suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
464 All the previous considerations hold, except that now there is
465 no way to unambiguously resolve a DN.
466 In this case, all the operations that require an unambiguous target
467 selection will fail unless the DN is already cached or a default
469 Practical configurations may result as a combination of all the
472 Note on ACLs: at present you may add whatever ACL rule you desire
473 to to the Meta (and LDAP) backends.
474 However, the meaning of an ACL on a proxy may require some
476 Two philosophies may be considered:
478 a) the remote server dictates the permissions; the proxy simply passes
479 back what it gets from the remote server.
481 b) the remote server unveils "everything"; the proxy is responsible
482 for protecting data from unauthorized access.
484 Of course the latter sounds unreasonable, but it is not.
485 It is possible to imagine scenarios in which a remote host discloses
486 data that can be considered "public" inside an intranet, and a proxy
487 that connects it to the internet may impose additional constraints.
488 To this purpose, the proxy should be able to comply with all the ACL
489 matching criteria that the server supports.
490 This has been achieved with regard to all the criteria supported by
491 slapd except a special subtle case (please drop me a note if you can
492 find other exceptions: <ando@openldap.org>).
497 access to dn="<dn>" attr=<attr>
498 by dnattr=<dnattr> read
503 cannot be matched iff the attribute that is being requested, <attr>,
504 is NOT <dnattr>, and the attribute that determines membership,
505 <dnattr>, has not been requested (e.g. in a search)
507 In fact this ACL is resolved by slapd using the portion of entry it
508 retrieved from the remote server without requiring any further
509 intervention of the backend, so, if the <dnattr> attribute has not
510 been fetched, the match cannot be assessed because the attribute is
511 not present, not because no value matches the requirement!
513 Note on ACLs and attribute mapping: ACLs are applied to the mapped
514 attributes; for instance, if the attribute locally known as "foo" is
515 mapped to "bar" on a remote server, then local ACLs apply to attribute
516 "foo" and are totally unaware of its remote name.
517 The remote server will check permissions for "bar", and the local
518 server will possibly enforce additional restrictions to "foo".
520 .\" If this section is moved, also update the reference in
521 .\" libraries/librewrite/RATIONALE.
524 A string is rewritten according to a set of rules, called a `rewrite
526 The rules are based on POSIX (''extended'') regular expressions (regex)
527 with substring matching; basic variable substitution and map resolution
528 of substrings is allowed by specific mechanisms detailed in the following.
529 The behavior of pattern matching/substitution can be altered by a set
532 The underlying concept is to build a lightweight rewrite module
533 for the slapd server (initially dedicated to the LDAP backend).
535 An incoming string is matched against a set of rules.
536 Rules are made of a regex match pattern, a substitution pattern
537 and a set of actions, described by a set of flags.
538 In case of match a string rewriting is performed according to the
539 substitution pattern that allows to refer to substrings matched in the
541 The actions, if any, are finally performed.
542 The substitution pattern allows map resolution of substrings.
543 A map is a generic object that maps a substitution pattern to a value.
544 The flags are divided in "Pattern matching Flags" and "Action Flags";
545 the former alter the regex match pattern behavior while the latter
546 alter the action that is taken after substitution.
547 .SH "Pattern Matching Flags"
550 honors case in matching (default is case insensitive)
553 use POSIX ''basic'' regular expressions (default is ''extended'')
558 recursive passes for a specific rule; does not alter the max total count
559 of passes, so it can only enforce a stricter limit for a specific rule.
563 apply the rule once only (default is recursive)
566 stop applying rules in case of match; the current rule is still applied
567 recursively; combine with `:' to apply the current rule only once
571 stop current operation if the rule matches, and issue an `unwilling to
577 rules back and forth (watch for loops!).
578 Note that `G{1}' is implicit in every rule.
581 ignores errors in rule; this means, in case of error, e.g. issued by a
582 map, the error is treated as a missed match.
583 The `unwilling to perform' is not overridden.
589 as return code if the rule matches; the flag does not alter the recursive
590 behavior of the rule, so, to have it performed only once, it must be used
591 in combination with `:', e.g.
593 returns the value `16' after exactly one execution of the rule, if the
595 As a consequence, its behavior is equivalent to `@', with the return
598 or, in other words, `@' is equivalent to `U{0}'.
599 By convention, the freely available codes are above 16 included;
600 the others are reserved.
602 The ordering of the flags can be significant.
603 For instance: `IG{2}' means ignore errors and jump two lines ahead
604 both in case of match and in case of error, while `G{2}I' means ignore
605 errors, but jump two lines ahead only in case of match.
607 More flags (mainly Action Flags) will be added as needed.
608 .SH "Pattern matching:"
613 .SH "Substitution Pattern Syntax:"
614 Everything starting with `%' requires substitution;
616 the only obvious exception is `%%', which is left as is;
618 the basic substitution is `%d', where `d' is a digit;
619 0 means the whole string, while 1-9 is a submatch;
621 a `%' followed by a `{' invokes an advanced substitution.
625 `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
628 where <name> must be a legal name for the map, i.e.
632 <name> ::= [a-z][a-z0-9]* (case insensitive)
633 <op> ::= `>' `|' `&' `&&' `*' `**' `$'
637 and <substitution> must be a legal substitution
638 pattern, with no limits on the nesting level.
643 sub context invocation; <name> must be a legal, already defined
647 external command invocation; <name> must refer to a legal, already
648 defined command name (NOT IMPL.)
651 variable assignment; <name> defines a variable in the running
652 operation structure which can be dereferenced later; operator
654 assigns a variable in the rewrite context scope; operator
656 assigns a variable that scopes the entire session, e.g. its value
657 can be dereferenced later by other rewrite contexts
660 variable dereferencing; <name> must refer to a variable that is
661 defined and assigned for the running operation; operator
663 dereferences a variable scoping the rewrite context; operator
665 dereferences a variable scoping the whole session, e.g. the value
666 is passed across rewrite contexts
669 parameter dereferencing; <name> must refer to an existing parameter;
670 the idea is to make some run-time parameters set by the system
671 available to the rewrite engine, as the client host name, the bind DN
672 if any, constant parameters initialized at config time, and so on;
673 no parameter is currently set by either
677 but constant parameters can be defined in the configuration file
682 Substitution escaping has been delegated to the `%' symbol,
683 which is used instead of `\e' in string substitution patterns
684 because `\e' is already escaped by slapd's low level parsing routines;
685 as a consequence, regex escaping requires two `\e' symbols,
686 e.g. `\fB.*\e.foo\e.bar\fP' must be written as `\fB.*\e\e.foo\e\e.bar\fP'.
688 .\" The symbol can be altered at will by redefining the related macro in
691 .SH "Rewrite context:"
692 A rewrite context is a set of rules which are applied in sequence.
693 The basic idea is to have an application initialize a rewrite
694 engine (think of Apache's mod_rewrite ...) with a set of rewrite
695 contexts; when string rewriting is required, one invokes the
696 appropriate rewrite context with the input string and obtains the
697 newly rewritten one if no errors occur.
699 Each basic server operation is associated to a rewrite context;
700 they are divided in two main groups: client \-> server and
701 server \-> client rewriting.
707 (default) if defined and no specific context
712 searchFilterAttrDN search
714 compareAttrDN compare AVA
718 modifyAttrDN modify AVA
722 exopPasswdDN password modify extended operation DN if proxy
730 searchResult search (only if defined; no default;
731 acts on DN and DN-syntax attributes
733 searchAttrDN search AVA
734 matchedDN all ops (only if applicable)
738 .SH "Basic configuration syntax"
740 .B rewriteEngine { on | off }
741 If `on', the requested rewriting is performed; if `off', no
742 rewriting takes place (an easy way to stop rewriting without
743 altering too much the configuration file).
745 .B rewriteContext <context name> "[ alias <aliased context name> ]"
746 <Context name> is the name that identifies the context, i.e. the name
747 used by the application to refer to the set of rules it contains.
748 It is used also to reference sub contexts in string rewriting.
749 A context may alias another one.
750 In this case the alias context contains no rule, and any reference to
751 it will result in accessing the aliased one.
753 .B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
754 Determines how a string can be rewritten if a pattern is matched.
755 Examples are reported below.
756 .SH "Additional configuration syntax:"
758 .B rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"
759 Allows to define a map that transforms substring rewriting into
761 The map is referenced inside the substitution pattern of a rule.
763 .B rewriteParam <param name> <param value>
764 Sets a value with global scope, that can be dereferenced by the
765 command `%{$paramName}'.
767 .B rewriteMaxPasses <number of passes> [<number of passes per rule>]
768 Sets the maximum number of total rewriting passes that can be
769 performed in a single rewrite operation (to avoid loops).
770 A safe default is set to 100; note that reaching this limit is still
771 treated as a success; recursive invocation of rules is simply
773 The count applies to the rewriting operation as a whole, not
774 to any single rule; an optional per-rule limit can be set.
775 This limit is overridden by setting specific per-rule limits
776 with the `M{n}' flag.
777 .SH "Configuration examples:"
779 # set to `off' to disable rewriting
782 # the rules the "suffixmassage" directive implies
784 # all dataflow from client to server referring to DNs
785 rewriteContext default
786 rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
788 rewriteContext searchFilter
789 # all dataflow from server to client
790 rewriteContext searchResult
791 rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
792 rewriteContext searchAttrDN alias searchResult
793 rewriteContext matchedDN alias searchResult
795 # Everything defined here goes into the `default' context.
796 # This rule changes the naming context of anything sent
797 # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
799 rewriteRule "(.*)dc=home,[ ]?dc=net"
800 "%1dc=OpenLDAP, dc=org" ":"
802 # since a pretty/normalized DN does not include spaces
803 # after rdn separators, e.g. `,', this rule suffices:
805 rewriteRule "(.*)dc=home,dc=net"
806 "%1dc=OpenLDAP,dc=org" ":"
808 # Start a new context (ends input of the previous one).
809 # This rule adds blanks between DN parts if not present.
810 rewriteContext addBlanks
811 rewriteRule "(.*),([^ ].*)" "%1, %2"
813 # This one eats blanks
814 rewriteContext eatBlanks
815 rewriteRule "(.*),[ ](.*)" "%1,%2"
817 # Here control goes back to the default rewrite
818 # context; rules are appended to the existing ones.
819 # anything that gets here is piped into rule `addBlanks'
820 rewriteContext default
821 rewriteRule ".*" "%{>addBlanks(%0)}" ":"
823 .\" # Anything with `uid=username' is looked up in
824 .\" # /etc/passwd for gecos (I know it's nearly useless,
825 .\" # but it is there just as a guideline to implementing
827 .\" # Note the `I' flag that leaves `uid=username' in place
828 .\" # if `username' does not have a valid account, and the
829 .\" # `:' that forces the rule to be processed exactly once.
830 .\" rewriteContext uid2Gecos
831 .\" rewriteRule "(.*)uid=([a-z0-9]+),(.+)"
832 .\" "%1cn=%2{xpasswd},%3" "I:"
834 .\" # Finally, in a bind, if one uses a `uid=username' DN,
835 .\" # it is rewritten in `cn=name surname' if possible.
836 .\" rewriteContext bindDN
837 .\" rewriteRule ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
839 # Rewrite the search base according to `default' rules.
840 rewriteContext searchBase alias default
842 # Search results with OpenLDAP DN are rewritten back with
843 # `dc=home,dc=net' naming context, with spaces eaten.
844 rewriteContext searchResult
845 rewriteRule "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
846 "%{>eatBlanks(%1)}dc=home,dc=net" ":"
848 # Bind with email instead of full DN: we first need
849 # an ldap map that turns attributes into a DN (the
850 # argument used when invoking the map is appended to
851 # the URI and acts as the filter portion)
852 rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
854 # Then we need to detect DN made up of a single email,
855 # e.g. `mail=someone@example.com'; note that the rule
856 # in case of match stops rewriting; in case of error,
857 # it is ignored. In case we are mapping virtual
858 # to real naming contexts, we also need to rewrite
859 # regular DNs, because the definition of a bindDn
860 # rewrite context overrides the default definition.
861 rewriteContext bindDN
862 rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
864 # This is a rather sophisticated example. It massages a
865 # search filter in case who performs the search has
866 # administrative privileges. First we need to keep
867 # track of the bind DN of the incoming request, which is
868 # stored in a variable called `binddn' with session scope,
869 # and left in place to allow regular binding:
870 rewriteContext bindDN
871 rewriteRule ".+" "%{&&binddn(%0)}%0" ":"
873 # A search filter containing `uid=' is rewritten only
874 # if an appropriate DN is bound.
875 # To do this, in the first rule the bound DN is
876 # dereferenced, while the filter is decomposed in a
877 # prefix, in the value of the `uid=<arg>' AVA, and
878 # in a suffix. A tag `<>' is appended to the DN.
879 # If the DN refers to an entry in the `ou=admin' subtree,
880 # the filter is rewritten OR-ing the `uid=<arg>' with
881 # `cn=<arg>'; otherwise it is left as is. This could be
882 # useful, for instance, to allow apache's auth_ldap-1.4
883 # module to authenticate users with both `uid' and
884 # `cn', but only if the request comes from a possible
885 # `cn=Web auth,ou=admin,dc=home,dc=net' user.
886 rewriteContext searchFilter
887 rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
888 "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
890 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
891 "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
892 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
894 # This example shows how to strip unwanted DN-valued
895 # attribute values from a search result; the first rule
896 # matches DN values below "ou=People,dc=example,dc=com";
897 # in case of match the rewriting exits successfully.
898 # The second rule matches everything else and causes
899 # the value to be rejected.
900 rewriteContext searchResult
901 rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
902 rewriteRule ".*" "" "#"
904 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
905 In case the rewritten DN is an LDAP URI, the operation is initiated
906 towards the host[:port] indicated in the uri, if it does not refer
911 rewriteRule '^cn=root,.*' '%0' 'G{3}'
912 rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
913 rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
914 rewriteRule '.*' 'ldap://ldap3.my.org/%0' ':@'
917 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
921 rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
924 with the advantage of saving one rewrite pass ...)
929 backend does not honor all ACL semantics as described in
930 .BR slapd.access (5).
931 In general, access checking is delegated to the remote server(s).
936 pseudo-attribute and to the other attribute values of the entries
939 operation is honored, which is performed by the frontend.
941 .SH PROXY CACHE OVERLAY
942 The proxy cache overlay
943 allows caching of LDAP search requests (queries) in a local database.
950 default slapd configuration file
954 .BR slapo\-pcache (5),
959 Pierangelo Masarati, based on back-ldap by Howard Chu