1 .TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" Copyright 1998-2007 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 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 single\-conn {NO|yes}
177 Discards current cached connection when the client rebinds.
180 .B use-temporary-conn {NO|yes}
183 create a temporary connection whenever competing with other threads
184 for a shared one; otherwise, wait until the shared connection is available.
186 .SH TARGET SPECIFICATION
187 Target specification starts with a "uri" directive:
190 .B uri <protocol>://[<host>[:<port>]]/<naming context>
191 The "server" directive that was allowed in the LDAP backend (although
192 deprecated) has been completely discarded in the Meta backend.
193 The <protocol> part can be anything
194 .BR ldap_initialize (3)
195 accepts ({ldap|ldaps|ldapi} and variants); <host> and <port> may be
196 omitted, defaulting to whatever is set in
198 The <naming context> part is mandatory.
199 It must end with one of the naming contexts defined for the backend,
204 suffix "\fBdc=foo,dc=com\fP"
205 uri "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
210 The <naming context> part doesn't need to be unique across the targets;
211 it may also match one of the values of the "suffix" directive.
212 Multiple URIs may be defined in a single argument. The URIs must
213 be separated by TABs (e.g. '\\t'; commas or spaces, unlike back-ldap,
215 because they are legal in the <naming context>, and we don't want to use
216 URL-encoded <naming context>s), and the additional URIs must have
217 no <naming context> part. This causes the underlying library
218 to contact the first server of the list that responds.
219 For example, if \fIl1.foo.com\fP and \fIl2.foo.com\fP are shadows
220 of the same server, the directive
223 suffix "\fBdc=foo,dc=com\fP"
224 uri "ldap://l1.foo.com/\fBdc=foo,dc=com\fP ldap://l2.foo.com/"
229 causes \fIl2.foo.com\fP to be contacted whenever \fIl1.foo.com\fP
234 .B acl-authcDN "<administrative DN for access control purposes>"
235 DN which is used to query the target server for acl checking,
236 as in the LDAP backend; it is supposed to have read access
237 on the target server to attributes used on the proxy for acl checking.
238 There is no risk of giving away such values; they are only used to
240 .B The acl-authcDN identity is by no means implicitly used by the proxy
241 .B when the client connects anonymously.
244 .B acl-passwd <password>
245 Password used with the
251 .B bind-timeout <microseconds>
252 This directive defines the timeout, in microseconds, used when polling
253 for response after an asynchronous bind connection. The initial call
254 to ldap_result(3) is performed with a trade-off timeout of 100000 us;
255 if that results in a timeout exceeded, subsequent calls use the value
258 The default value is used also for subsequent calls if
261 If set before any target specification, it affects all targets, unless
262 overridden by any per-target directive.
265 .B chase-referrals {YES|no}
266 enable/disable automatic referral chasing, which is delegated to the
267 underlying libldap, with rebinding eventually performed if the
268 \fBrebind-as-user\fP directive is used. The default is to chase referrals.
269 If set before any target specification, it affects all targets, unless
270 overridden by any per-target directive.
273 .B default-target [<target>]
274 The "default-target" directive can also be used during target specification.
275 With no arguments it marks the current target as the default.
276 The optional number marks target <target> as the default one, starting
278 Target <target> must be defined.
281 .B idle-timeout <time>
282 This directive causes a cached connection to be dropped an recreated
283 after it has been idle for the specified time.
284 The value can be specified as
286 [<d>d][<h>h][<m>m][<s>[s]]
288 where <d>, <h>, <m> and <s> are respectively treated as days, hours,
290 If set before any target specification, it affects all targets, unless
291 overridden by any per-target directive.
294 .B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
295 This maps object classes and attributes as in the LDAP backend.
300 .B network-timeout <time>
301 Sets the network timeout value after which
302 .BR poll (2)/ select (2)
305 returns in case of no activity.
306 The value is in seconds, and it can be specified as for
308 If set before any target specification, it affects all targets, unless
309 overridden by any per-target directive.
312 .B nretries {forever|never|<nretries>}
313 This directive defines how many times a bind should be retried
314 in case of temporary failure in contacting a target. If defined
315 before any target specification, it applies to all targets (by default,
318 the global value can be overridden by redefinitions inside each target
322 .B pseudorootdn "<substitute DN in case of rootdn bind>"
323 This directive, if present, sets the DN that will be substituted to
324 the bind DN if a bind with the backend's "rootdn" succeeds.
325 The true "rootdn" of the target server ought not be used; an arbitrary
326 administrative DN should used instead.
329 .B pseudorootpw "<substitute password in case of rootdn bind>"
330 This directive sets the credential that will be used in case a bind
331 with the backend's "rootdn" succeeds, and the bind is propagated to
332 the target using the "pseudorootdn" DN.
334 Note: cleartext credentials must be supplied here; as a consequence,
335 using the pseudorootdn/pseudorootpw directives is inherently unsafe.
339 The rewrite options are described in the "REWRITING" section.
342 .B subtree-exclude "<DN>"
343 This directive instructs back-meta to ignore the current target
344 for operations whose requestDN is subordinate to
346 There may be multiple occurrences of the
348 directive for each of the targets.
351 .B suffixmassage "<virtual naming context>" "<real naming context>"
352 All the directives starting with "rewrite" refer to the rewrite engine
353 that has been added to slapd.
354 The "suffixmassage" directive was introduced in the LDAP backend to
355 allow suffix massaging while proxying.
356 It has been obsoleted by the rewriting tools.
357 However, both for backward compatibility and for ease of configuration
358 when simple suffix massage is required, it has been preserved.
359 It wraps the basic rewriting instructions that perform suffix
360 massaging. See the "REWRITING" section for a detailed list
361 of the rewrite rules it implies.
364 .B t-f-support {NO|yes|discover}
365 enable if the remote server supports absolute filters
366 (see \fIdraft-zeilenga-ldap-t-f\fP for details).
369 support is detected by reading the remote server's root DSE.
370 If set before any target specification, it affects all targets, unless
371 overridden by any per-target directive.
374 .B timeout [{add|delete|modify|modrdn}=]<seconds> [...]
375 This directive allows to set per-database, per-target and per-operation
377 If no operation is specified, it affects all.
378 Currently, only write operations are addressed, because searches
379 can already be limited by means of the
383 for details), and other operations are not supposed to incur into the
385 Note: if the timelimit is exceeded, the operation is abandoned;
386 the protocol does not provide any means to rollback the operation,
387 so the client will not know if the operation eventually succeeded or not.
388 If set before any target specification, it affects all targets, unless
389 overridden by any per-target directive.
392 .B tls {[try-]start|[try-]propagate}
393 execute the StartTLS extended operation when the connection is initialized;
394 only works if the URI directive protocol scheme is not \fBldaps://\fP.
395 \fBpropagate\fP issues the StartTLS operation only if the original
397 The \fBtry-\fP prefix instructs the proxy to continue operations
398 if the StartTLS operation failed; its use is highly deprecated.
399 If set before any target specification, it affects all targets, unless
400 overridden by any per-target directive.
403 A powerful (and in some sense dangerous) rewrite engine has been added
404 to both the LDAP and Meta backends.
405 While the former can gain limited beneficial effects from rewriting
406 stuff, the latter can become an amazingly powerful tool.
408 Consider a couple of scenarios first.
410 1) Two directory servers share two levels of naming context;
411 say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
412 Then, an unambiguous Meta database can be configured as:
417 suffix "\fBdc=foo,dc=com\fP"
418 uri "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
419 uri "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
423 Operations directed to a specific target can be easily resolved
424 because there are no ambiguities.
425 The only operation that may resolve to multiple targets is a search
426 with base "dc=foo,dc=com" and scope at least "one", which results in
427 spawning two searches to the targets.
429 2a) Two directory servers don't share any portion of naming context,
430 but they'd present as a single DIT
431 [Caveat: uniqueness of (massaged) entries among the two servers is
432 assumed; integrity checks risk to incur in excessive overhead and have
433 not been implemented].
434 Say we have "dc=bar,dc=org" and "o=Foo,c=US",
435 and we'd like them to appear as branches of "dc=foo,dc=com", say
436 "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
437 Then we need to configure our Meta backend as:
442 suffix "dc=foo,dc=com"
444 uri "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
445 suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"
447 uri "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
448 suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
452 Again, operations can be resolved without ambiguity, although
453 some rewriting is required.
454 Notice that the virtual naming context of each target is a branch of
455 the database's naming context; it is rewritten back and forth when
456 operations are performed towards the target servers.
457 What "back and forth" means will be clarified later.
459 When a search with base "dc=foo,dc=com" is attempted, if the
460 scope is "base" it fails with "no such object"; in fact, the
461 common root of the two targets (prior to massaging) does not
463 If the scope is "one", both targets are contacted with the base
464 replaced by each target's base; the scope is derated to "base".
465 In general, a scope "one" search is honored, and the scope is derated,
466 only when the incoming base is at most one level lower of a target's
467 naming context (prior to massaging).
469 Finally, if the scope is "sub" the incoming base is replaced
470 by each target's unmassaged naming context, and the scope
473 2b) Consider the above reported scenario with the two servers
474 sharing the same naming context:
479 suffix "\fBdc=foo,dc=com\fP"
481 uri "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
482 suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"
484 uri "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
485 suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
489 All the previous considerations hold, except that now there is
490 no way to unambiguously resolve a DN.
491 In this case, all the operations that require an unambiguous target
492 selection will fail unless the DN is already cached or a default
494 Practical configurations may result as a combination of all the
497 Note on ACLs: at present you may add whatever ACL rule you desire
498 to to the Meta (and LDAP) backends.
499 However, the meaning of an ACL on a proxy may require some
501 Two philosophies may be considered:
503 a) the remote server dictates the permissions; the proxy simply passes
504 back what it gets from the remote server.
506 b) the remote server unveils "everything"; the proxy is responsible
507 for protecting data from unauthorized access.
509 Of course the latter sounds unreasonable, but it is not.
510 It is possible to imagine scenarios in which a remote host discloses
511 data that can be considered "public" inside an intranet, and a proxy
512 that connects it to the internet may impose additional constraints.
513 To this purpose, the proxy should be able to comply with all the ACL
514 matching criteria that the server supports.
515 This has been achieved with regard to all the criteria supported by
516 slapd except a special subtle case (please drop me a note if you can
517 find other exceptions: <ando@openldap.org>).
522 access to dn="<dn>" attr=<attr>
523 by dnattr=<dnattr> read
528 cannot be matched iff the attribute that is being requested, <attr>,
529 is NOT <dnattr>, and the attribute that determines membership,
530 <dnattr>, has not been requested (e.g. in a search)
532 In fact this ACL is resolved by slapd using the portion of entry it
533 retrieved from the remote server without requiring any further
534 intervention of the backend, so, if the <dnattr> attribute has not
535 been fetched, the match cannot be assessed because the attribute is
536 not present, not because no value matches the requirement!
538 Note on ACLs and attribute mapping: ACLs are applied to the mapped
539 attributes; for instance, if the attribute locally known as "foo" is
540 mapped to "bar" on a remote server, then local ACLs apply to attribute
541 "foo" and are totally unaware of its remote name.
542 The remote server will check permissions for "bar", and the local
543 server will possibly enforce additional restrictions to "foo".
545 .\" If this section is moved, also update the reference in
546 .\" libraries/librewrite/RATIONALE.
549 A string is rewritten according to a set of rules, called a `rewrite
551 The rules are based on POSIX (''extended'') regular expressions (regex)
552 with substring matching; basic variable substitution and map resolution
553 of substrings is allowed by specific mechanisms detailed in the following.
554 The behavior of pattern matching/substitution can be altered by a set
557 The underlying concept is to build a lightweight rewrite module
558 for the slapd server (initially dedicated to the LDAP backend).
560 An incoming string is matched against a set of rules.
561 Rules are made of a regex match pattern, a substitution pattern
562 and a set of actions, described by a set of flags.
563 In case of match a string rewriting is performed according to the
564 substitution pattern that allows to refer to substrings matched in the
566 The actions, if any, are finally performed.
567 The substitution pattern allows map resolution of substrings.
568 A map is a generic object that maps a substitution pattern to a value.
569 The flags are divided in "Pattern matching Flags" and "Action Flags";
570 the former alter the regex match pattern behavior while the latter
571 alter the action that is taken after substitution.
572 .SH "Pattern Matching Flags"
575 honors case in matching (default is case insensitive)
578 use POSIX ''basic'' regular expressions (default is ''extended'')
583 recursive passes for a specific rule; does not alter the max total count
584 of passes, so it can only enforce a stricter limit for a specific rule.
588 apply the rule once only (default is recursive)
591 stop applying rules in case of match; the current rule is still applied
592 recursively; combine with `:' to apply the current rule only once
596 stop current operation if the rule matches, and issue an `unwilling to
602 rules back and forth (watch for loops!).
603 Note that `G{1}' is implicit in every rule.
606 ignores errors in rule; this means, in case of error, e.g. issued by a
607 map, the error is treated as a missed match.
608 The `unwilling to perform' is not overridden.
614 as return code if the rule matches; the flag does not alter the recursive
615 behavior of the rule, so, to have it performed only once, it must be used
616 in combination with `:', e.g.
618 returns the value `16' after exactly one execution of the rule, if the
620 As a consequence, its behavior is equivalent to `@', with the return
623 or, in other words, `@' is equivalent to `U{0}'.
624 By convention, the freely available codes are above 16 included;
625 the others are reserved.
627 The ordering of the flags can be significant.
628 For instance: `IG{2}' means ignore errors and jump two lines ahead
629 both in case of match and in case of error, while `G{2}I' means ignore
630 errors, but jump two lines ahead only in case of match.
632 More flags (mainly Action Flags) will be added as needed.
633 .SH "Pattern matching:"
638 .SH "Substitution Pattern Syntax:"
639 Everything starting with `%' requires substitution;
641 the only obvious exception is `%%', which is left as is;
643 the basic substitution is `%d', where `d' is a digit;
644 0 means the whole string, while 1-9 is a submatch;
646 a `%' followed by a `{' invokes an advanced substitution.
650 `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
653 where <name> must be a legal name for the map, i.e.
657 <name> ::= [a-z][a-z0-9]* (case insensitive)
658 <op> ::= `>' `|' `&' `&&' `*' `**' `$'
662 and <substitution> must be a legal substitution
663 pattern, with no limits on the nesting level.
668 sub context invocation; <name> must be a legal, already defined
672 external command invocation; <name> must refer to a legal, already
673 defined command name (NOT IMPL.)
676 variable assignment; <name> defines a variable in the running
677 operation structure which can be dereferenced later; operator
679 assigns a variable in the rewrite context scope; operator
681 assigns a variable that scopes the entire session, e.g. its value
682 can be dereferenced later by other rewrite contexts
685 variable dereferencing; <name> must refer to a variable that is
686 defined and assigned for the running operation; operator
688 dereferences a variable scoping the rewrite context; operator
690 dereferences a variable scoping the whole session, e.g. the value
691 is passed across rewrite contexts
694 parameter dereferencing; <name> must refer to an existing parameter;
695 the idea is to make some run-time parameters set by the system
696 available to the rewrite engine, as the client host name, the bind DN
697 if any, constant parameters initialized at config time, and so on;
698 no parameter is currently set by either
702 but constant parameters can be defined in the configuration file
707 Substitution escaping has been delegated to the `%' symbol,
708 which is used instead of `\e' in string substitution patterns
709 because `\e' is already escaped by slapd's low level parsing routines;
710 as a consequence, regex escaping requires two `\e' symbols,
711 e.g. `\fB.*\e.foo\e.bar\fP' must be written as `\fB.*\e\e.foo\e\e.bar\fP'.
713 .\" The symbol can be altered at will by redefining the related macro in
716 .SH "Rewrite context:"
717 A rewrite context is a set of rules which are applied in sequence.
718 The basic idea is to have an application initialize a rewrite
719 engine (think of Apache's mod_rewrite ...) with a set of rewrite
720 contexts; when string rewriting is required, one invokes the
721 appropriate rewrite context with the input string and obtains the
722 newly rewritten one if no errors occur.
724 Each basic server operation is associated to a rewrite context;
725 they are divided in two main groups: client \-> server and
726 server \-> client rewriting.
732 (default) if defined and no specific context
737 searchFilterAttrDN search
739 compareAttrDN compare AVA
743 modifyAttrDN modify AVA
747 exopPasswdDN password modify extended operation DN if proxy
755 searchResult search (only if defined; no default;
756 acts on DN and DN-syntax attributes
758 searchAttrDN search AVA
759 matchedDN all ops (only if applicable)
763 .SH "Basic configuration syntax"
765 .B rewriteEngine { on | off }
766 If `on', the requested rewriting is performed; if `off', no
767 rewriting takes place (an easy way to stop rewriting without
768 altering too much the configuration file).
770 .B rewriteContext <context name> "[ alias <aliased context name> ]"
771 <Context name> is the name that identifies the context, i.e. the name
772 used by the application to refer to the set of rules it contains.
773 It is used also to reference sub contexts in string rewriting.
774 A context may alias another one.
775 In this case the alias context contains no rule, and any reference to
776 it will result in accessing the aliased one.
778 .B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
779 Determines how a string can be rewritten if a pattern is matched.
780 Examples are reported below.
781 .SH "Additional configuration syntax:"
783 .B rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"
784 Allows to define a map that transforms substring rewriting into
786 The map is referenced inside the substitution pattern of a rule.
788 .B rewriteParam <param name> <param value>
789 Sets a value with global scope, that can be dereferenced by the
790 command `%{$paramName}'.
792 .B rewriteMaxPasses <number of passes> [<number of passes per rule>]
793 Sets the maximum number of total rewriting passes that can be
794 performed in a single rewrite operation (to avoid loops).
795 A safe default is set to 100; note that reaching this limit is still
796 treated as a success; recursive invocation of rules is simply
798 The count applies to the rewriting operation as a whole, not
799 to any single rule; an optional per-rule limit can be set.
800 This limit is overridden by setting specific per-rule limits
801 with the `M{n}' flag.
802 .SH "Configuration examples:"
804 # set to `off' to disable rewriting
807 # the rules the "suffixmassage" directive implies
809 # all dataflow from client to server referring to DNs
810 rewriteContext default
811 rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
813 rewriteContext searchFilter
814 # all dataflow from server to client
815 rewriteContext searchResult
816 rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
817 rewriteContext searchAttrDN alias searchResult
818 rewriteContext matchedDN alias searchResult
820 # Everything defined here goes into the `default' context.
821 # This rule changes the naming context of anything sent
822 # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
824 rewriteRule "(.*)dc=home,[ ]?dc=net"
825 "%1dc=OpenLDAP, dc=org" ":"
827 # since a pretty/normalized DN does not include spaces
828 # after rdn separators, e.g. `,', this rule suffices:
830 rewriteRule "(.*)dc=home,dc=net"
831 "%1dc=OpenLDAP,dc=org" ":"
833 # Start a new context (ends input of the previous one).
834 # This rule adds blanks between DN parts if not present.
835 rewriteContext addBlanks
836 rewriteRule "(.*),([^ ].*)" "%1, %2"
838 # This one eats blanks
839 rewriteContext eatBlanks
840 rewriteRule "(.*),[ ](.*)" "%1,%2"
842 # Here control goes back to the default rewrite
843 # context; rules are appended to the existing ones.
844 # anything that gets here is piped into rule `addBlanks'
845 rewriteContext default
846 rewriteRule ".*" "%{>addBlanks(%0)}" ":"
848 .\" # Anything with `uid=username' is looked up in
849 .\" # /etc/passwd for gecos (I know it's nearly useless,
850 .\" # but it is there just as a guideline to implementing
852 .\" # Note the `I' flag that leaves `uid=username' in place
853 .\" # if `username' does not have a valid account, and the
854 .\" # `:' that forces the rule to be processed exactly once.
855 .\" rewriteContext uid2Gecos
856 .\" rewriteRule "(.*)uid=([a-z0-9]+),(.+)"
857 .\" "%1cn=%2{xpasswd},%3" "I:"
859 .\" # Finally, in a bind, if one uses a `uid=username' DN,
860 .\" # it is rewritten in `cn=name surname' if possible.
861 .\" rewriteContext bindDN
862 .\" rewriteRule ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
864 # Rewrite the search base according to `default' rules.
865 rewriteContext searchBase alias default
867 # Search results with OpenLDAP DN are rewritten back with
868 # `dc=home,dc=net' naming context, with spaces eaten.
869 rewriteContext searchResult
870 rewriteRule "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
871 "%{>eatBlanks(%1)}dc=home,dc=net" ":"
873 # Bind with email instead of full DN: we first need
874 # an ldap map that turns attributes into a DN (the
875 # argument used when invoking the map is appended to
876 # the URI and acts as the filter portion)
877 rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
879 # Then we need to detect DN made up of a single email,
880 # e.g. `mail=someone@example.com'; note that the rule
881 # in case of match stops rewriting; in case of error,
882 # it is ignored. In case we are mapping virtual
883 # to real naming contexts, we also need to rewrite
884 # regular DNs, because the definition of a bindDn
885 # rewrite context overrides the default definition.
886 rewriteContext bindDN
887 rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
889 # This is a rather sophisticated example. It massages a
890 # search filter in case who performs the search has
891 # administrative privileges. First we need to keep
892 # track of the bind DN of the incoming request, which is
893 # stored in a variable called `binddn' with session scope,
894 # and left in place to allow regular binding:
895 rewriteContext bindDN
896 rewriteRule ".+" "%{&&binddn(%0)}%0" ":"
898 # A search filter containing `uid=' is rewritten only
899 # if an appropriate DN is bound.
900 # To do this, in the first rule the bound DN is
901 # dereferenced, while the filter is decomposed in a
902 # prefix, in the value of the `uid=<arg>' AVA, and
903 # in a suffix. A tag `<>' is appended to the DN.
904 # If the DN refers to an entry in the `ou=admin' subtree,
905 # the filter is rewritten OR-ing the `uid=<arg>' with
906 # `cn=<arg>'; otherwise it is left as is. This could be
907 # useful, for instance, to allow apache's auth_ldap-1.4
908 # module to authenticate users with both `uid' and
909 # `cn', but only if the request comes from a possible
910 # `cn=Web auth,ou=admin,dc=home,dc=net' user.
911 rewriteContext searchFilter
912 rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
913 "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
915 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
916 "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
917 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
919 # This example shows how to strip unwanted DN-valued
920 # attribute values from a search result; the first rule
921 # matches DN values below "ou=People,dc=example,dc=com";
922 # in case of match the rewriting exits successfully.
923 # The second rule matches everything else and causes
924 # the value to be rejected.
925 rewriteContext searchResult
926 rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
927 rewriteRule ".*" "" "#"
929 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
930 In case the rewritten DN is an LDAP URI, the operation is initiated
931 towards the host[:port] indicated in the uri, if it does not refer
936 rewriteRule '^cn=root,.*' '%0' 'G{3}'
937 rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
938 rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
939 rewriteRule '.*' 'ldap://ldap3.my.org/%0' ':@'
942 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
946 rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
949 with the advantage of saving one rewrite pass ...)
954 backend does not honor all ACL semantics as described in
955 .BR slapd.access (5).
956 In general, access checking is delegated to the remote server(s).
961 pseudo-attribute and to the other attribute values of the entries
964 operation is honored, which is performed by the frontend.
966 .SH PROXY CACHE OVERLAY
967 The proxy cache overlay
968 allows caching of LDAP search requests (queries) in a local database.
975 default slapd configuration file
979 .BR slapo\-pcache (5),
984 Pierangelo Masarati, based on back-ldap by Howard Chu