]> git.sur5r.net Git - openldap/blob - doc/man/man5/slapd-meta.5
Fix typos
[openldap] / doc / man / man5 / slapd-meta.5
1 .TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" Copyright 1998-2005 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>
5 .\" $OpenLDAP$
6 .\"
7 .\" Portions of this document should probably be moved to slapd-ldap(5)
8 .\" and maybe manual pages for librewrite.
9 .\"
10 .SH NAME
11 slapd-meta \- metadirectory backend
12 .SH SYNOPSIS
13 ETCDIR/slapd.conf
14 .SH DESCRIPTION
15 The
16 .B meta
17 backend to
18 .BR slapd (8)
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).
23 .LP
24 A basic knowledge of the functionality of the
25 .BR slapd\-ldap (5)
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
29 portions of code).
30 While the
31 .B ldap
32 backend is intended to proxy operations directed to a single server, the
33 .B meta
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
38 carefully considered.
39 In the examples section, some typical scenarios will be discussed.
40 .SH EXAMPLES
41 There are examples in various places in this document, as well as in the
42 slapd/back-meta/data/ directory in the OpenLDAP source tree.
43 .SH CONFIGURATION
44 These
45 .B slapd.conf
46 options apply to the META backend database.
47 That is, they must follow a "database meta" line and come before any
48 subsequent "backend" or "database" lines.
49 Other database options are described in the
50 .BR slapd.conf (5)
51 manual page.
52 .LP
53 Note: In early versions of back-ldap and back-meta it was recommended to always set
54 .LP
55 .RS
56 .nf
57 lastmod  off
58 .fi
59 .RE
60 .LP
61 for every
62 .B ldap
63 and
64 .B meta
65 database.
66 This is because operational attributes related to entry creation and
67 modification should not be proxied, as they could be mistakenly written
68 to the target server(s), generating an error.
69 The current implementation automatically sets lastmod to off, so its use
70 is redundant and should be omitted, because the lastmod directive will
71 be deprecated in the future.
72
73 .SH SPECIAL CONFIGURATION DIRECTIVES
74 Target configuration starts with the "uri" directive.
75 All the configuration directives that are not specific to targets
76 should be defined first for clarity, including those that are common
77 to all backends.
78 They are:
79
80 .TP
81 .B default-target none
82 This directive forces the backend to reject all those operations
83 that must resolve to a single target in case none or multiple
84 targets are selected.
85 They include: add, delete, modify, modrdn; compare is not included, as
86 well as bind since, as they don't alter entries, in case of multiple
87 matches an attempt is made to perform the operation on any candidate
88 target, with the constraint that at most one must succeed.
89 This directive can also be used when processing targets to mark a
90 specific target as default.
91
92 .TP
93 .B dncache-ttl {forever|disabled|<ttl>}
94 This directive sets the time-to-live of the DN cache.
95 This caches the target that holds a given DN to speed up target
96 selection in case multiple targets would result from an uncached
97 search; forever means cache never expires; disabled means no DN
98 caching; otherwise a valid ( > 0 ) ttl in seconds is required.
99
100 .TP
101 .B nretries {forever|never|<nretries>}
102 This directive defines how many times a bind should be retried
103 in case of temporary failure in contacting a target.  If defined
104 before any target specification, it applies to all targets (by default,
105 .BR never );
106 the global value can be overridden by redefinitions inside each target
107 specification.
108
109 .TP
110 .B onerr {CONTINUE|stop}
111 This directive allows to select the behavior in case an error is returned
112 by one target during a search.
113 The default, \fBcontinue\fP, consists in continuing the operation, 
114 trying to return as much data as possible.
115 If this statement is set to \fBstop\fP, the search is terminated as soon 
116 as an error is returned by one target, and the error is immediately 
117 propagated to the client.
118
119 .TP
120 .B rebind-as-user {NO|yes}
121 If this option is given, the client's bind credentials are remembered
122 for rebinds when chasing referrals.
123
124 .SH TARGET SPECIFICATION
125 Target specification starts with a "uri" directive:
126
127 .TP
128 .B uri <protocol>://[<host>[:<port>]]/<naming context>
129 The "server" directive that was allowed in the LDAP backend (although
130 deprecated) has been completely discarded in the Meta backend.
131 The <protocol> part can be anything
132 .BR ldap_initialize (3)
133 accepts ({ldap|ldaps|ldapi} and variants); <host> and <port> may be
134 omitted, defaulting to whatever is set in
135 .BR ldap.conf (5).
136 The <naming context> part is mandatory.
137 It must end with one of the naming contexts defined for the backend,
138 e.g.:
139 .LP
140 .RS
141 .nf
142 suffix "\fBdc=foo,dc=com\fP"
143 uri    "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
144 .fi
145
146 .RE
147 .RS
148 The <naming context> part doesn't need to be unique across the targets;
149 it may also match one of the values of the "suffix" directive.
150 Multiple URIs may be defined in a single argument.  The URIs must
151 be separated by TABs (e.g. '\\t'; commas or spaces, unlike back-ldap,
152 will not work,
153 because they are legal in the <naming context>, and we don't want to use
154 URL-encoded <naming context>s), and the additional URIs must have
155 no <naming context> part.  This causes the underlying library
156 to contact the first server of the list that responds.
157 .RE
158
159 .TP
160 .B default-target [<target>]
161 The "default-target" directive can also be used during target specification.
162 With no arguments it marks the current target as the default.
163 The optional number marks target <target> as the default one, starting
164 from 1.
165 Target <target> must be defined.
166
167 .TP
168 .B acl-authcDN "<administrative DN for access control purposes>"
169 DN which is used to query the target server for acl checking,
170 as in the LDAP backend; it is supposed to have read access 
171 on the target server to attributes used on the proxy for acl checking.
172 There is no risk of giving away such values; they are only used to
173 check permissions.
174 .B The acl-authcDN identity is by no means implicitly used by the proxy 
175 .B when the client connects anonymously.
176
177 .TP
178 .B acl-passwd <password>
179 Password used with the
180 .B 
181 acl-authcDN
182 above.
183
184 .TP
185 .B chase-referrals {YES|no}
186 enable/disable automatic referral chasing, which is delegated to the
187 underlying libldap, with rebinding eventually performed if the
188 \fBrebind-as-user\fP directive is used.  The default is to chase referrals.
189 If set before any target specification, it affects all targets, unless
190 overridden by any per-target directive.
191
192 .TP
193 .B tls {[try-]start|[try-]propagate}
194 execute the start TLS extended operation when the connection is initialized;
195 only works if the URI directive protocol scheme is not \fBldaps://\fP.
196 \fBpropagate\fP issues the Start TLS exop only if the original
197 connection did.
198 The \fBtry-\fP prefix instructs the proxy to continue operations
199 if start TLS failed; its use is highly deprecated.
200 If set before any target specification, it affects all targets, unless
201 overridden by any per-target directive.
202
203 .TP
204 .B t-f-support {NO|yes|discover}
205 enable if the remote server supports absolute filters
206 (see \fIdraft-zeilenga-ldap-t-f\fP for details).
207 If set to
208 .BR discover ,
209 support is detected by reading the remote server's root DSE.
210 If set before any target specification, it affects all targets, unless
211 overridden by any per-target directive.
212
213 .TP
214 .B timeout [{add|delete|modify|modrdn}=]<val> [...]
215 This directive allows to set per-database, per-target and per-operation
216 timeouts.
217 If no operation is specified, it affects all.
218 Currently, only write operations are addressed, because searches
219 can already be limited by means of the
220 .B limits
221 directive (see 
222 .BR slapd.conf (5)
223 for details), and other operations are not supposed to incur into the
224 need for timeouts.
225 Note: if the timelimit is exceeded, the operation is abandoned;
226 the protocol does not provide any means to rollback the operation,
227 so the client will not know if the operation eventually succeeded or not.
228 If set before any target specification, it affects all targets, unless
229 overridden by any per-target directive.
230
231 .TP
232 .B pseudorootdn "<substitute DN in case of rootdn bind>"
233 This directive, if present, sets the DN that will be substituted to
234 the bind DN if a bind with the backend's "rootdn" succeeds.
235 The true "rootdn" of the target server ought not be used; an arbitrary
236 administrative DN should used instead.
237
238 .TP
239 .B pseudorootpw "<substitute password in case of rootdn bind>"
240 This directive sets the credential that will be used in case a bind
241 with the backend's "rootdn" succeeds, and the bind is propagated to
242 the target using the "pseudorootdn" DN.
243
244 Note: cleartext credentials must be supplied here; as a consequence,
245 using the pseudorootdn/pseudorootpw directives is inherently unsafe.
246
247 .TP
248 .B rewrite* ...
249 The rewrite options are described in the "REWRITING" section.
250
251 .TP
252 .B suffixmassage "<virtual naming context>" "<real naming context>"
253 All the directives starting with "rewrite" refer to the rewrite engine
254 that has been added to slapd.
255 The "suffixmassage" directive was introduced in the LDAP backend to
256 allow suffix massaging while proxying.
257 It has been obsoleted by the rewriting tools.
258 However, both for backward compatibility and for ease of configuration
259 when simple suffix massage is required, it has been preserved.
260 It wraps the basic rewriting instructions that perform suffix
261 massaging.  See the "REWRITING" section for a detailed list 
262 of the rewrite rules it implies.
263 .LP
264 Note: this also fixes a flaw in suffix massaging, which operated
265 on (case insensitive) DNs instead of normalized DNs,
266 so "dc=foo, dc=com" would not match "dc=foo,dc=com".
267 .LP
268 See the "REWRITING" section.
269
270 .TP
271 .B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
272 This maps object classes and attributes as in the LDAP backend.
273 See
274 .BR slapd-ldap (5).
275 .SH SCENARIOS
276 A powerful (and in some sense dangerous) rewrite engine has been added
277 to both the LDAP and Meta backends.
278 While the former can gain limited beneficial effects from rewriting
279 stuff, the latter can become an amazingly powerful tool.
280 .LP
281 Consider a couple of scenarios first.
282 .LP
283 1) Two directory servers share two levels of naming context;
284 say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
285 Then, an unambiguous Meta database can be configured as:
286 .LP
287 .RS
288 .nf
289 database meta
290 suffix   "\fBdc=foo,dc=com\fP"
291 uri      "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
292 uri      "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
293 .fi
294 .RE
295 .LP
296 Operations directed to a specific target can be easily resolved
297 because there are no ambiguities.
298 The only operation that may resolve to multiple targets is a search
299 with base "dc=foo,dc=com" and scope at least "one", which results in
300 spawning two searches to the targets.
301 .LP
302 2a) Two directory servers don't share any portion of naming context,
303 but they'd present as a single DIT
304 [Caveat: uniqueness of (massaged) entries among the two servers is
305 assumed; integrity checks risk to incur in excessive overhead and have
306 not been implemented].
307 Say we have "dc=bar,dc=org" and "o=Foo,c=US",
308 and we'd like them to appear as branches of "dc=foo,dc=com", say
309 "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
310 Then we need to configure our Meta backend as:
311 .LP
312 .RS
313 .nf
314 database      meta
315 suffix        "dc=foo,dc=com"
316
317 uri           "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
318 suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"
319
320 uri           "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
321 suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
322 .fi
323 .RE
324 .LP
325 Again, operations can be resolved without ambiguity, although
326 some rewriting is required.
327 Notice that the virtual naming context of each target is a branch of
328 the database's naming context; it is rewritten back and forth when
329 operations are performed towards the target servers.
330 What "back and forth" means will be clarified later.
331 .LP
332 When a search with base "dc=foo,dc=com" is attempted, if the 
333 scope is "base" it fails with "no such object"; in fact, the
334 common root of the two targets (prior to massaging) does not
335 exist.
336 If the scope is "one", both targets are contacted with the base
337 replaced by each target's base; the scope is derated to "base".
338 In general, a scope "one" search is honored, and the scope is derated,
339 only when the incoming base is at most one level lower of a target's
340 naming context (prior to massaging).
341 .LP
342 Finally, if the scope is "sub" the incoming base is replaced
343 by each target's unmassaged naming context, and the scope
344 is not altered.
345 .LP
346 2b) Consider the above reported scenario with the two servers
347 sharing the same naming context:
348 .LP
349 .RS
350 .nf
351 database      meta
352 suffix        "\fBdc=foo,dc=com\fP"
353
354 uri           "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
355 suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"
356
357 uri           "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
358 suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
359 .fi
360 .RE
361 .LP
362 All the previous considerations hold, except that now there is
363 no way to unambiguously resolve a DN.
364 In this case, all the operations that require an unambiguous target
365 selection will fail unless the DN is already cached or a default
366 target has been set.
367 Practical configurations may result as a combination of all the
368 above scenarios.
369 .SH ACLs
370 Note on ACLs: at present you may add whatever ACL rule you desire
371 to to the Meta (and LDAP) backends.
372 However, the meaning of an ACL on a proxy may require some
373 considerations.
374 Two philosophies may be considered:
375 .LP
376 a) the remote server dictates the permissions; the proxy simply passes
377 back what it gets from the remote server.
378 .LP
379 b) the remote server unveils "everything"; the proxy is responsible
380 for protecting data from unauthorized access.
381 .LP
382 Of course the latter sounds unreasonable, but it is not.
383 It is possible to imagine scenarios in which a remote host discloses
384 data that can be considered "public" inside an intranet, and a proxy
385 that connects it to the internet may impose additional constraints.
386 To this purpose, the proxy should be able to comply with all the ACL
387 matching criteria that the server supports.
388 This has been achieved with regard to all the criteria supported by
389 slapd except a special subtle case (please drop me a note if you can
390 find other exceptions: <ando@openldap.org>).
391 The rule
392 .LP
393 .RS
394 .nf
395 access to dn="<dn>" attr=<attr>
396        by dnattr=<dnattr> read
397        by * none
398 .fi
399 .RE
400 .LP
401 cannot be matched iff the attribute that is being requested, <attr>,
402 is NOT <dnattr>, and the attribute that determines membership,
403 <dnattr>, has not been requested (e.g. in a search)
404 .LP
405 In fact this ACL is resolved by slapd using the portion of entry it
406 retrieved from the remote server without requiring any further
407 intervention of the backend, so, if the <dnattr> attribute has not
408 been fetched, the match cannot be assessed because the attribute is
409 not present, not because no value matches the requirement!
410 .LP
411 Note on ACLs and attribute mapping: ACLs are applied to the mapped
412 attributes; for instance, if the attribute locally known as "foo" is
413 mapped to "bar" on a remote server, then local ACLs apply to attribute
414 "foo" and are totally unaware of its remote name.
415 The remote server will check permissions for "bar", and the local
416 server will possibly enforce additional restrictions to "foo".
417 .\"
418 .\" If this section is moved, also update the reference in
419 .\" libraries/librewrite/RATIONALE.
420 .\"
421 .SH REWRITING
422 A string is rewritten according to a set of rules, called a `rewrite
423 context'.
424 The rules are based on POSIX (''extended'') regular expressions (regex)
425 with substring matching; basic variable substitution and map resolution 
426 of substrings is allowed by specific mechanisms detailed in the following.
427 The behavior of pattern matching/substitution can be altered by a set
428 of flags.
429 .LP
430 The underlying concept is to build a lightweight rewrite module
431 for the slapd server (initially dedicated to the LDAP backend).
432 .SH Passes
433 An incoming string is matched against a set of rules.
434 Rules are made of a regex match pattern, a substitution pattern
435 and a set of actions, described by a set of flags.
436 In case of match a string rewriting is performed according to the
437 substitution pattern that allows to refer to substrings matched in the
438 incoming string.
439 The actions, if any, are finally performed.
440 The substitution pattern allows map resolution of substrings.
441 A map is a generic object that maps a substitution pattern to a value.
442 The flags are divided in "Pattern matching Flags" and "Action Flags";
443 the former alter the regex match pattern behavior while the latter
444 alter the action that is taken after substitution.
445 .SH "Pattern Matching Flags"
446 .TP
447 .B `C'
448 honors case in matching (default is case insensitive)
449 .TP
450 .B `R'
451 use POSIX ''basic'' regular expressions (default is ''extended'')
452 .TP
453 .B `M{n}'
454 allow no more than
455 .B n
456 recursive passes for a specific rule; does not alter the max total count
457 of passes, so it can only enforce a stricter limit for a specific rule.
458 .SH "Action Flags"
459 .TP
460 .B `:'
461 apply the rule once only (default is recursive)
462 .TP
463 .B `@'
464 stop applying rules in case of match; the current rule is still applied 
465 recursively; combine with `:' to apply the current rule only once 
466 and then stop.
467 .TP
468 .B `#'
469 stop current operation if the rule matches, and issue an `unwilling to
470 perform' error.
471 .TP
472 .B `G{n}'
473 jump
474 .B n
475 rules back and forth (watch for loops!).
476 Note that `G{1}' is implicit in every rule.
477 .TP
478 .B `I'
479 ignores errors in rule; this means, in case of error, e.g. issued by a
480 map, the error is treated as a missed match.
481 The `unwilling to perform' is not overridden.
482 .TP
483 .B `U{n}'
484 uses
485 .B
486 n
487 as return code if the rule matches; the flag does not alter the recursive
488 behavior of the rule, so, to have it performed only once, it must be used 
489 in combination with `:', e.g.
490 .B `:U{16}'
491 returns the value `16' after exactly one execution of the rule, if the
492 pattern matches.
493 As a consequence, its behavior is equivalent to `@', with the return
494 code set to
495 .BR n ;
496 or, in other words, `@' is equivalent to `U{0}'.
497 By convention, the freely available codes are above 16 included;
498 the others are reserved.
499 .LP
500 The ordering of the flags can be significant.
501 For instance: `IG{2}' means ignore errors and jump two lines ahead
502 both in case of match and in case of error, while `G{2}I' means ignore
503 errors, but jump two lines ahead only in case of match.
504 .LP
505 More flags (mainly Action Flags) will be added as needed.
506 .SH "Pattern matching:"
507 See
508 .BR regex (7)
509 and/or
510 .BR re_format (7).
511 .SH "Substitution Pattern Syntax:"
512 Everything starting with `%' requires substitution;
513 .LP
514 the only obvious exception is `%%', which is left as is;
515 .LP
516 the basic substitution is `%d', where `d' is a digit;
517 0 means the whole string, while 1-9 is a submatch;
518 .LP
519 a `%' followed by a `{' invokes an advanced substitution.
520 The pattern is:
521 .LP
522 .RS
523 `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
524 .RE
525 .LP
526 where <name> must be a legal name for the map, i.e.
527 .LP
528 .RS
529 .nf
530 <name> ::= [a-z][a-z0-9]* (case insensitive)
531 <op> ::= `>' `|' `&' `&&' `*' `**' `$'
532 .fi
533 .RE
534 .LP
535 and <substitution> must be a legal substitution
536 pattern, with no limits on the nesting level.
537 .LP
538 The operators are:
539 .TP
540 .B >
541 sub context invocation; <name> must be a legal, already defined
542 rewrite context name
543 .TP
544 .B |
545 external command invocation; <name> must refer to a legal, already
546 defined command name (NOT IMPL.)
547 .TP
548 .B &
549 variable assignment; <name> defines a variable in the running
550 operation structure which can be dereferenced later; operator
551 .B &
552 assigns a variable in the rewrite context scope; operator
553 .B &&
554 assigns a variable that scopes the entire session, e.g. its value
555 can be dereferenced later by other rewrite contexts
556 .TP
557 .B *
558 variable dereferencing; <name> must refer to a variable that is
559 defined and assigned for the running operation; operator
560 .B *
561 dereferences a variable scoping the rewrite context; operator
562 .B **
563 dereferences a variable scoping the whole session, e.g. the value
564 is passed across rewrite contexts
565 .TP
566 .B $
567 parameter dereferencing; <name> must refer to an existing parameter;
568 the idea is to make some run-time parameters set by the system
569 available to the rewrite engine, as the client host name, the bind DN
570 if any, constant parameters initialized at config time, and so on;
571 no parameter is currently set by either 
572 .B back\-ldap
573 or
574 .BR back\-meta ,
575 but constant parameters can be defined in the configuration file
576 by using the
577 .B rewriteParam
578 directive.
579 .LP
580 Substitution escaping has been delegated to the `%' symbol, 
581 which is used instead of `\e' in string substitution patterns
582 because `\e' is already escaped by slapd's low level parsing routines;
583 as a consequence, regex escaping requires two `\e' symbols,
584 e.g. `\fB.*\e.foo\e.bar\fP' must be written as `\fB.*\e\e.foo\e\e.bar\fP'.
585 .\"
586 .\" The symbol can be altered at will by redefining the related macro in
587 .\" "rewrite-int.h".
588 .\"
589 .SH "Rewrite context:"
590 A rewrite context is a set of rules which are applied in sequence.
591 The basic idea is to have an application initialize a rewrite
592 engine (think of Apache's mod_rewrite ...) with a set of rewrite
593 contexts; when string rewriting is required, one invokes the
594 appropriate rewrite context with the input string and obtains the
595 newly rewritten one if no errors occur.
596 .LP
597 Each basic server operation is associated to a rewrite context;
598 they are divided in two main groups: client \-> server and
599 server \-> client rewriting.
600 .LP
601 client -> server:
602 .LP
603 .RS
604 .nf
605 (default)            if defined and no specific context 
606                      is available
607 bindDN               bind
608 searchBase           search
609 searchFilter         search
610 searchFilterAttrDN   search
611 compareDN            compare
612 compareAttrDN        compare AVA
613 addDN                add
614 addAttrDN            add AVA
615 modifyDN             modify
616 modifyAttrDN         modify AVA
617 modrDN               modrdn
618 newSuperiorDN        modrdn
619 deleteDN             delete
620 exopPasswdDN         passwd exop DN if proxy
621 .fi
622 .RE
623 .LP
624 server -> client:
625 .LP
626 .RS
627 .nf
628 searchResult         search (only if defined; no default;
629                      acts on DN and DN-syntax attributes 
630                      of search results)
631 searchAttrDN         search AVA
632 matchedDN            all ops (only if applicable)
633 .fi
634 .RE
635 .LP
636 .SH "Basic configuration syntax"
637 .TP
638 .B rewriteEngine { on | off }
639 If `on', the requested rewriting is performed; if `off', no
640 rewriting takes place (an easy way to stop rewriting without
641 altering too much the configuration file).
642 .TP
643 .B rewriteContext <context name> "[ alias <aliased context name> ]"
644 <Context name> is the name that identifies the context, i.e. the name
645 used by the application to refer to the set of rules it contains.
646 It is used also to reference sub contexts in string rewriting.
647 A context may alias another one.
648 In this case the alias context contains no rule, and any reference to
649 it will result in accessing the aliased one.
650 .TP
651 .B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
652 Determines how a string can be rewritten if a pattern is matched.
653 Examples are reported below.
654 .SH "Additional configuration syntax:"
655 .TP
656 .B rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"
657 Allows to define a map that transforms substring rewriting into
658 something else.
659 The map is referenced inside the substitution pattern of a rule.
660 .TP
661 .B rewriteParam <param name> <param value>
662 Sets a value with global scope, that can be dereferenced by the
663 command `%{$paramName}'.
664 .TP
665 .B rewriteMaxPasses <number of passes> [<number of passes per rule>]
666 Sets the maximum number of total rewriting passes that can be
667 performed in a single rewrite operation (to avoid loops).
668 A safe default is set to 100; note that reaching this limit is still
669 treated as a success; recursive invocation of rules is simply 
670 interrupted.
671 The count applies to the rewriting operation as a whole, not 
672 to any single rule; an optional per-rule limit can be set.
673 This limit is overridden by setting specific per-rule limits
674 with the `M{n}' flag.
675 .SH "Configuration examples:"
676 .nf
677 # set to `off' to disable rewriting
678 rewriteEngine on
679
680 # the rules the "suffixmassage" directive implies
681 rewriteEngine on
682 # all dataflow from client to server referring to DNs
683 rewriteContext default
684 rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
685 # empty filter rule
686 rewriteContext searchFilter
687 # all dataflow from server to client
688 rewriteContext searchResult
689 rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
690 rewriteContext searchAttrDN alias searchResult
691 rewriteContext matchedDN alias searchResult
692
693 # Everything defined here goes into the `default' context.
694 # This rule changes the naming context of anything sent
695 # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
696
697 rewriteRule "(.*)dc=home,[ ]?dc=net"
698             "%1dc=OpenLDAP, dc=org"  ":"
699
700 # since a pretty/normalized DN does not include spaces
701 # after rdn separators, e.g. `,', this rule suffices:
702
703 rewriteRule "(.*)dc=home,dc=net"
704             "%1dc=OpenLDAP,dc=org"  ":"
705
706 # Start a new context (ends input of the previous one).
707 # This rule adds blanks between DN parts if not present.
708 rewriteContext  addBlanks
709 rewriteRule     "(.*),([^ ].*)" "%1, %2"
710
711 # This one eats blanks
712 rewriteContext  eatBlanks
713 rewriteRule     "(.*),[ ](.*)" "%1,%2"
714
715 # Here control goes back to the default rewrite
716 # context; rules are appended to the existing ones.
717 # anything that gets here is piped into rule `addBlanks'
718 rewriteContext  default
719 rewriteRule     ".*" "%{>addBlanks(%0)}" ":"
720
721 .\" # Anything with `uid=username' is looked up in
722 .\" # /etc/passwd for gecos (I know it's nearly useless,
723 .\" # but it is there just as a guideline to implementing
724 .\" # custom maps).
725 .\" # Note the `I' flag that leaves `uid=username' in place 
726 .\" # if `username' does not have a valid account, and the
727 .\" # `:' that forces the rule to be processed exactly once.
728 .\" rewriteContext  uid2Gecos
729 .\" rewriteRule     "(.*)uid=([a-z0-9]+),(.+)"
730 .\"                 "%1cn=%2{xpasswd},%3"      "I:"
731 .\" 
732 .\" # Finally, in a bind, if one uses a `uid=username' DN,
733 .\" # it is rewritten in `cn=name surname' if possible.
734 .\" rewriteContext  bindDN
735 .\" rewriteRule     ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
736 .\" 
737 # Rewrite the search base according to `default' rules.
738 rewriteContext  searchBase alias default
739
740 # Search results with OpenLDAP DN are rewritten back with
741 # `dc=home,dc=net' naming context, with spaces eaten.
742 rewriteContext  searchResult
743 rewriteRule     "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
744                 "%{>eatBlanks(%1)}dc=home,dc=net"    ":"
745
746 # Bind with email instead of full DN: we first need
747 # an ldap map that turns attributes into a DN (the
748 # argument used when invoking the map is appended to 
749 # the URI and acts as the filter portion)
750 rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
751
752 # Then we need to detect DN made up of a single email,
753 # e.g. `mail=someone@example.com'; note that the rule
754 # in case of match stops rewriting; in case of error,
755 # it is ignored.  In case we are mapping virtual
756 # to real naming contexts, we also need to rewrite
757 # regular DNs, because the definition of a bindDn
758 # rewrite context overrides the default definition.
759 rewriteContext bindDN
760 rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
761
762 # This is a rather sophisticated example. It massages a
763 # search filter in case who performs the search has
764 # administrative privileges.  First we need to keep
765 # track of the bind DN of the incoming request, which is
766 # stored in a variable called `binddn' with session scope,
767 # and left in place to allow regular binding:
768 rewriteContext  bindDN
769 rewriteRule     ".+" "%{&&binddn(%0)}%0" ":"
770
771 # A search filter containing `uid=' is rewritten only
772 # if an appropriate DN is bound.
773 # To do this, in the first rule the bound DN is
774 # dereferenced, while the filter is decomposed in a
775 # prefix, in the value of the `uid=<arg>' AVA, and 
776 # in a suffix. A tag `<>' is appended to the DN. 
777 # If the DN refers to an entry in the `ou=admin' subtree, 
778 # the filter is rewritten OR-ing the `uid=<arg>' with
779 # `cn=<arg>'; otherwise it is left as is. This could be
780 # useful, for instance, to allow apache's auth_ldap-1.4
781 # module to authenticate users with both `uid' and
782 # `cn', but only if the request comes from a possible
783 # `cn=Web auth,ou=admin,dc=home,dc=net' user.
784 rewriteContext searchFilter
785 rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
786   "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
787   ":I"
788 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
789   "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
790 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
791
792 # This example shows how to strip unwanted DN-valued
793 # attribute values from a search result; the first rule
794 # matches DN values below "ou=People,dc=example,dc=com";
795 # in case of match the rewriting exits successfully.
796 # The second rule matches everything else and causes
797 # the value to be rejected.
798 rewriteContext searchResult
799 rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
800 rewriteRule ".*" "" "#"
801 .fi
802 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
803 In case the rewritten DN is an LDAP URI, the operation is initiated
804 towards the host[:port] indicated in the uri, if it does not refer
805 to the local server.
806 E.g.:
807 .LP
808 .nf
809   rewriteRule '^cn=root,.*' '%0'                     'G{3}'
810   rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
811   rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
812   rewriteRule '.*'          'ldap://ldap3.my.org/%0' ':@'
813 .fi
814 .LP
815 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
816 been written:
817 .LP
818 .nf
819   rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
820 .fi
821 .LP
822 with the advantage of saving one rewrite pass ...)
823
824 .SH ACCESS CONTROL
825 The
826 .B meta
827 backend does not honor all ACL semantics as described in
828 .BR slapd.access (5).
829 In general, access checking is delegated to the remote server(s).
830 Only
831 .B read (=r)
832 access to the
833 .B entry
834 pseudo-attribute and to the other attribute values of the entries
835 returned by the
836 .B search
837 operation is honored, which is performed by the frontend.
838
839 .SH PROXY CACHE OVERLAY
840 The proxy cache overlay 
841 allows caching of LDAP search requests (queries) in a local database.
842 See 
843 .BR slapo-pcache (5)
844 for details.
845 .SH FILES
846 .TP
847 ETCDIR/slapd.conf
848 default slapd configuration file
849 .SH SEE ALSO
850 .BR slapd.conf (5),
851 .BR slapd\-ldap (5),
852 .BR slapo\-pcache (5),
853 .BR slapd (8),
854 .BR regex (7),
855 .BR re_format (7).
856 .SH AUTHOR
857 Pierangelo Masarati, based on back-ldap by Howard Chu