]> git.sur5r.net Git - openldap/blob - doc/man/man5/slapd-meta.5
ITS#7294 reference RFC4526 instead of draft
[openldap] / doc / man / man5 / slapd-meta.5
1 .TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" Copyright 1998-2012 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 to slapd
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
41 The proxy instance of
42 .BR slapd (8)
43 must contain schema information for the attributes and objectClasses
44 used in filters, request DN and request-related data in general.
45 It should also contain schema information for the data returned
46 by the proxied server.
47 It is the responsibility of the proxy administrator to keep the schema
48 of the proxy lined up with that of the proxied server.
49
50 .LP
51 Note: When looping back to the same instance of \fBslapd\fP(8), 
52 each connection requires a new thread; as a consequence, \fBslapd\fP(8)
53 must be compiled with thread support, and the \fBthreads\fP parameter 
54 may need some tuning; in those cases, unless the multiple target feature
55 is required, one may consider using \fBslapd\-relay\fP(5) instead, 
56 which performs the relayed operation internally and thus reuses 
57 the same connection.
58
59 .SH EXAMPLES
60 There are examples in various places in this document, as well as in the
61 slapd/back\-meta/data/ directory in the OpenLDAP source tree.
62 .SH CONFIGURATION
63 These
64 .B slapd.conf
65 options apply to the META backend database.
66 That is, they must follow a "database meta" line and come before any
67 subsequent "backend" or "database" lines.
68 Other database options are described in the
69 .BR slapd.conf (5)
70 manual page.
71 .LP
72 Note: In early versions of back-ldap and back-meta it was recommended to always set
73 .LP
74 .RS
75 .nf
76 lastmod  off
77 .fi
78 .RE
79 .LP
80 for 
81 .B ldap
82 and
83 .B meta
84 databases.
85 This was required because operational attributes related to entry creation 
86 and modification should not be proxied, as they could be mistakenly written
87 to the target server(s), generating an error.
88 The current implementation automatically sets lastmod to \fBoff\fP, 
89 so its use is redundant and should be omitted.
90
91 .SH SPECIAL CONFIGURATION DIRECTIVES
92 Target configuration starts with the "uri" directive.
93 All the configuration directives that are not specific to targets
94 should be defined first for clarity, including those that are common
95 to all backends.
96 They are:
97
98 .TP
99 .B conn\-ttl <time>
100 This directive causes a cached connection to be dropped an recreated
101 after a given ttl, regardless of being idle or not.
102
103 .TP
104 .B default\-target none
105 This directive forces the backend to reject all those operations
106 that must resolve to a single target in case none or multiple
107 targets are selected.
108 They include: add, delete, modify, modrdn; compare is not included, as
109 well as bind since, as they don't alter entries, in case of multiple
110 matches an attempt is made to perform the operation on any candidate
111 target, with the constraint that at most one must succeed.
112 This directive can also be used when processing targets to mark a
113 specific target as default.
114
115 .TP
116 .B dncache\-ttl {DISABLED|forever|<ttl>}
117 This directive sets the time-to-live of the DN cache.
118 This caches the target that holds a given DN to speed up target
119 selection in case multiple targets would result from an uncached
120 search; forever means cache never expires; disabled means no DN
121 caching; otherwise a valid ( > 0 ) ttl is required, in the format
122 illustrated for the 
123 .B idle\-timeout
124 directive.
125
126 .TP
127 .B onerr {CONTINUE|report|stop}
128 This directive allows to select the behavior in case an error is returned
129 by one target during a search.
130 The default, \fBcontinue\fP, consists in continuing the operation, 
131 trying to return as much data as possible.
132 If the value is set to \fBstop\fP, the search is terminated as soon 
133 as an error is returned by one target, and the error is immediately 
134 propagated to the client.
135 If the value is set to \fBreport\fP, the search is continuated to the end
136 but, in case at least one target returned an error code, the first
137 non-success error code is returned.
138
139 .TP
140 .B norefs <NO|yes>
141 If
142 .BR yes ,
143 do not return search reference responses.
144 By default, they are returned unless request is LDAPv2.
145 If set before any target specification, it affects all targets, unless
146 overridden by any per-target directive.
147
148 .TP
149 .B noundeffilter <NO|yes>
150 If
151 .BR yes ,
152 return success instead of searching if a filter is undefined or contains
153 undefined portions.
154 By default, the search is propagated after replacing undefined portions
155 with
156 .BR (!(objectClass=*)) ,
157 which corresponds to the empty result set.
158 If set before any target specification, it affects all targets, unless
159 overridden by any per-target directive.
160
161 .TP
162 .B protocol\-version {0,2,3}
163 This directive indicates what protocol version must be used to contact
164 the remote server.
165 If set to 0 (the default), the proxy uses the same protocol version 
166 used by the client, otherwise the requested protocol is used.
167 The proxy returns \fIunwillingToPerform\fP if an operation that is 
168 incompatible with the requested protocol is attempted.
169 If set before any target specification, it affects all targets, unless
170 overridden by any per-target directive.
171
172 .TP
173 .B pseudoroot\-bind\-defer {YES|no}
174 This directive, when set to 
175 .BR yes ,
176 causes the authentication to the remote servers with the pseudo-root
177 identity (the identity defined in each
178 .B idassert-bind
179 directive) to be deferred until actually needed by subsequent operations.
180 Otherwise, all binds as the rootdn are propagated to the targets.
181
182 .TP
183 .B quarantine <interval>,<num>[;<interval>,<num>[...]]
184 Turns on quarantine of URIs that returned
185 .IR LDAP_UNAVAILABLE ,
186 so that an attempt to reconnect only occurs at given intervals instead
187 of any time a client requests an operation.
188 The pattern is: retry only after at least
189 .I interval
190 seconds elapsed since last attempt, for exactly
191 .I num
192 times; then use the next pattern.
193 If
194 .I num
195 for the last pattern is "\fB+\fP", it retries forever; otherwise, 
196 no more retries occur.
197 This directive must appear before any target specification;
198 it affects all targets with the same pattern.
199
200 .TP
201 .B rebind\-as\-user {NO|yes}
202 If this option is given, the client's bind credentials are remembered
203 for rebinds, when trying to re-establish a broken connection,
204 or when chasing a referral, if 
205 .B chase\-referrals
206 is set to
207 .IR yes .
208
209 .TP
210 .B session\-tracking\-request {NO|yes}
211 Adds session tracking control for all requests.
212 The client's IP and hostname, and the identity associated to each request,
213 if known, are sent to the remote server for informational purposes.
214 This directive is incompatible with setting \fIprotocol\-version\fP to 2.
215 If set before any target specification, it affects all targets, unless
216 overridden by any per-target directive.
217
218 .TP
219 .B single\-conn {NO|yes}
220 Discards current cached connection when the client rebinds.
221
222 .TP
223 .B use\-temporary\-conn {NO|yes}
224 when set to 
225 .BR yes ,
226 create a temporary connection whenever competing with other threads
227 for a shared one; otherwise, wait until the shared connection is available.
228
229 .SH TARGET SPECIFICATION
230 Target specification starts with a "uri" directive:
231
232 .TP
233 .B uri <protocol>://[<host>]/<naming context> [...]
234 The <protocol> part can be anything
235 .BR ldap_initialize (3)
236 accepts ({ldap|ldaps|ldapi} and variants); the <host> may be
237 omitted, defaulting to whatever is set in
238 .BR ldap.conf (5).
239 The <naming context> part is \fImandatory\fP for the first URI,
240 but it \fImust be omitted\fP for subsequent ones, if any.
241 The naming context part must be within the naming context defined for the backend,
242 e.g.:
243 .LP
244 .RS
245 .nf
246 suffix "\fBdc=foo,dc=com\fP"
247 uri    "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
248 .fi
249
250 .RE
251 .RS
252 The <naming context> part doesn't need to be unique across the targets;
253 it may also match one of the values of the "suffix" directive.
254 Multiple URIs may be defined in a single URI statement.
255 The additional URIs must be separate arguments and must not have any
256 <naming context> part.  This causes the underlying library
257 to contact the first server of the list that responds.
258 For example, if \fIl1.foo.com\fP and \fIl2.foo.com\fP are shadows
259 of the same server, the directive
260 .LP
261 .nf
262 suffix "\fBdc=foo,dc=com\fP"
263 uri    "ldap://l1.foo.com/\fBdc=foo,dc=com\fP" "ldap://l2.foo.com/"
264 .fi
265
266 .RE
267 .RS
268 causes \fIl2.foo.com\fP to be contacted whenever \fIl1.foo.com\fP
269 does not respond.
270 In that case, the URI list is internally rearranged, by moving unavailable
271 URIs to the end, so that further connection attempts occur with respect to
272 the last URI that succeeded.
273 .RE
274
275 .TP
276 .B acl\-authcDN "<administrative DN for access control purposes>"
277 DN which is used to query the target server for acl checking,
278 as in the LDAP backend; it is supposed to have read access 
279 on the target server to attributes used on the proxy for acl checking.
280 There is no risk of giving away such values; they are only used to
281 check permissions.
282 .B The acl\-authcDN identity is by no means implicitly used by the proxy 
283 .B when the client connects anonymously.
284
285 .TP
286 .B acl\-passwd <password>
287 Password used with the
288 .B 
289 acl\-authcDN
290 above.
291
292 .TP
293 .B bind\-timeout <microseconds>
294 This directive defines the timeout, in microseconds, used when polling
295 for response after an asynchronous bind connection.  The initial call
296 to ldap_result(3) is performed with a trade-off timeout of 100000 us;
297 if that results in a timeout exceeded, subsequent calls use the value
298 provided with
299 .BR bind\-timeout .
300 The default value is used also for subsequent calls if
301 .B bind\-timeout
302 is not specified.
303 If set before any target specification, it affects all targets, unless
304 overridden by any per-target directive.
305
306 .TP
307 .B chase\-referrals {YES|no}
308 enable/disable automatic referral chasing, which is delegated to the
309 underlying libldap, with rebinding eventually performed if the
310 \fBrebind\-as\-user\fP directive is used.  The default is to chase referrals.
311 If set before any target specification, it affects all targets, unless
312 overridden by any per-target directive.
313
314 .TP
315 .B client\-pr {accept-unsolicited|DISABLE|<size>}
316 This feature allows to use RFC 2696 Paged Results control when performing
317 search operations with a specific target,
318 irrespective of the client's request.
319 When set to a numeric value, Paged Results control is always
320 used with \fIsize\fP as the page size.
321 When set to \fIaccept-unsolicited\fP, unsolicited Paged Results
322 control responses are accepted and honored
323 for compatibility with broken remote DSAs.
324 The client is not exposed to paged results handling
325 between
326 .BR slapd\-meta (5)
327 and the remote servers.
328 By default (disabled), Paged Results control is not used
329 and responses are not accepted.
330 If set before any target specification, it affects all targets, unless
331 overridden by any per-target directive.
332
333 .TP
334 .B default\-target [<target>]
335 The "default\-target" directive can also be used during target specification.
336 With no arguments it marks the current target as the default.
337 The optional number marks target <target> as the default one, starting
338 from 1.
339 Target <target> must be defined.
340
341 .TP
342 .B idassert\-authzFrom <authz-regexp>
343 if defined, selects what
344 .I local
345 identities are authorized to exploit the identity assertion feature.
346 The string
347 .B <authz-regexp>
348 follows the rules defined for the
349 .I authzFrom
350 attribute.
351 See 
352 .BR slapd.conf (5),
353 section related to
354 .BR authz\-policy ,
355 for details on the syntax of this field.
356
357 .HP
358 .hy 0
359 .B idassert\-bind
360 .B bindmethod=none|simple|sasl [binddn=<simple DN>] [credentials=<simple password>]
361 .B [saslmech=<SASL mech>] [secprops=<properties>] [realm=<realm>]
362 .B [authcId=<authentication ID>] [authzId=<authorization ID>]
363 .B [authz={native|proxyauthz}] [mode=<mode>] [flags=<flags>]
364 .B [starttls=no|yes|critical]
365 .B [tls_cert=<file>]
366 .B [tls_key=<file>]
367 .B [tls_cacert=<file>]
368 .B [tls_cacertdir=<path>]
369 .B [tls_reqcert=never|allow|try|demand]
370 .B [tls_ciphersuite=<ciphers>]
371 .B [tls_protocol_min=<version>]
372 .B [tls_crlcheck=none|peer|all]
373 .RS
374 Allows to define the parameters of the authentication method that is 
375 internally used by the proxy to authorize connections that are 
376 authenticated by other databases.
377 The identity defined by this directive, according to the properties
378 associated to the authentication method, is supposed to have auth access 
379 on the target server to attributes used on the proxy for authentication
380 and authorization, and to be allowed to authorize the users.
381 This requires to have
382 .B proxyAuthz
383 privileges on a wide set of DNs, e.g.
384 .BR authzTo=dn.subtree:"" ,
385 and the remote server to have
386 .B authz\-policy
387 set to
388 .B to
389 or
390 .BR both .
391 See
392 .BR slapd.conf (5)
393 for details on these statements and for remarks and drawbacks about
394 their usage.
395 The supported bindmethods are
396
397 \fBnone|simple|sasl\fP
398
399 where
400 .B none
401 is the default, i.e. no \fIidentity assertion\fP is performed.
402
403 The authz parameter is used to instruct the SASL bind to exploit 
404 .B native 
405 SASL authorization, if available; since connections are cached,
406 this should only be used when authorizing with a fixed identity
407 (e.g. by means of the 
408 .B authzDN
409 or
410 .B authzID
411 parameters).
412 Otherwise, the default
413 .B proxyauthz
414 is used, i.e. the proxyAuthz control (Proxied Authorization, RFC 4370)
415 is added to all operations.
416
417 The supported modes are:
418
419 \fB<mode> := {legacy|anonymous|none|self}\fP
420
421 If 
422 .B <mode>
423 is not present, and 
424 .B authzId
425 is given, the proxy always authorizes that identity.
426 .B <authorization ID>
427 can be 
428
429 \fBu:<user>\fP
430
431 \fB[dn:]<DN>\fP
432
433 The former is supposed to be expanded by the remote server according 
434 to the authz rules; see
435 .BR slapd.conf (5)
436 for details.
437 In the latter case, whether or not the 
438 .B dn:
439 prefix is present, the string must pass DN validation and normalization.
440
441 The default mode is 
442 .BR legacy ,
443 which implies that the proxy will either perform a simple bind as the
444 .I authcDN
445 or a SASL bind as the
446 .I authcID
447 and assert the client's identity when it is not anonymous.
448 Direct binds are always proxied.
449 The other modes imply that the proxy will always either perform a simple bind 
450 as the
451 .IR authcDN
452 or a SASL bind as the
453 .IR authcID ,
454 unless restricted by
455 .BR idassert\-authzFrom
456 rules (see below), in which case the operation will fail;
457 eventually, it will assert some other identity according to
458 .BR <mode> .
459 Other identity assertion modes are
460 .BR anonymous
461 and
462 .BR self ,
463 which respectively mean that the 
464 .I empty 
465 or the 
466 .IR client 's 
467 identity
468 will be asserted;
469 .BR none ,
470 which means that no proxyAuthz control will be used, so the
471 .I authcDN
472 or the
473 .I authcID
474 identity will be asserted.
475 For all modes that require the use of the
476 .I proxyAuthz 
477 control, on the remote server the proxy identity must have appropriate 
478 .I authzTo
479 permissions, or the asserted identities must have appropriate
480 .I authzFrom 
481 permissions.  Note, however, that the ID assertion feature is mostly 
482 useful when the asserted identities do not exist on the remote server.
483 When
484 .I bindmethod
485 is
486 .BR SASL ,
487 the 
488 .I authcDN
489 must be specified in addition to the
490 .IR authcID ,
491 although it is not used within the authentication process.
492
493 Flags can be
494
495 \fBoverride,[non\-]prescriptive,proxy\-authz\-[non\-]critical\fP
496
497 When the 
498 .B override
499 flag is used, identity assertion takes place even when the database
500 is authorizing for the identity of the client, i.e. after binding
501 with the provided identity, and thus authenticating it, the proxy
502 performs the identity assertion using the configured identity and
503 authentication method.
504
505 When the
506 .B prescriptive
507 flag is used (the default), operations fail with
508 \fIinappropriateAuthentication\fP
509 for those identities whose assertion is not allowed by the
510 .B idassert\-authzFrom
511 patterns.
512 If the 
513 .B non\-prescriptive
514 flag is used, operations are performed anonymously for those identities 
515 whose assertion is not allowed by the
516 .B idassert\-authzFrom
517 patterns.
518
519 When the
520 .B proxy\-authz\-non\-critical
521 flag is used (the default), the proxyAuthz control is not marked as critical,
522 in violation of RFC 4370.  Use of
523 .B proxy\-authz\-critical
524 is recommended.
525
526 The TLS settings default to the same as the main slapd TLS settings,
527 except for
528 .B tls_reqcert
529 which defaults to "demand".
530
531 The identity associated to this directive is also used for privileged
532 operations whenever \fBidassert\-bind\fP is defined and \fBacl\-bind\fP
533 is not.  See \fBacl\-bind\fP for details.
534 .RE
535
536 .TP
537 .B idle\-timeout <time>
538 This directive causes a cached connection to be dropped an recreated
539 after it has been idle for the specified time.
540 The value can be specified as
541
542 [<d>d][<h>h][<m>m][<s>[s]]
543
544 where <d>, <h>, <m> and <s> are respectively treated as days, hours, 
545 minutes and seconds.
546 If set before any target specification, it affects all targets, unless
547 overridden by any per-target directive.
548
549 .TP
550 .B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
551 This maps object classes and attributes as in the LDAP backend.
552 See
553 .BR slapd\-ldap (5).
554
555 .TP
556 .B network\-timeout <time>
557 Sets the network timeout value after which
558 .BR poll (2)/ select (2) 
559 following a 
560 .BR connect (2) 
561 returns in case of no activity.
562 The value is in seconds, and it can be specified as for
563 .BR idle\-timeout .
564 If set before any target specification, it affects all targets, unless
565 overridden by any per-target directive.
566
567 .TP
568 .B nretries {forever|never|<nretries>}
569 This directive defines how many times a bind should be retried
570 in case of temporary failure in contacting a target.  If defined
571 before any target specification, it applies to all targets (by default,
572 .BR 3
573 times);
574 the global value can be overridden by redefinitions inside each target
575 specification.
576
577 .TP
578 .B rewrite* ...
579 The rewrite options are described in the "REWRITING" section.
580
581 .TP
582 .B subtree\-{exclude|include} "<rule>"
583 This directive allows to indicate what subtrees are actually served
584 by a target.
585 The syntax of the supported rules is
586
587 \fB<rule>: [dn[.<style>]:]<pattern>\fP
588
589 \fB<style>: subtree|children|regex\fP
590
591 When \fB<style>\fP is either \fBsubtree\fP or \fBchildren\fP
592 the \fB<pattern>\fP is a DN that must be within the naming context
593 served by the target.
594 When \fB<style>\fP is \fBregex\fP the \fB<pattern>\fP is a
595 .BR regex (5)
596 pattern.
597 If the \fBdn.<style>:\fP prefix is omitted, \fBdn.subtree:\fP
598 is implicitly assumed for backward compatibility.
599
600 In the
601 .B subtree\-exclude
602 form if the \fIrequest DN\fP matches at least one rule,
603 the target is not considered while fulfilling the request;
604 otherwise, the target is considered based on the value of the \fIrequest DN\fP.
605 When the request is a search, also the \fIscope\fP is considered.
606
607 In the
608 .B subtree\-include
609 form if the \fIrequest DN\fP matches at least one rule,
610 the target is considered while fulfilling the request;
611 otherwise the target is ignored.
612
613 .LP
614 .RS
615 .nf
616     |  match  | exclude |
617     +---------+---------+-------------------+
618     |    T    |    T    | not candidate     |
619     |    F    |    T    | continue checking |
620     +---------+---------+-------------------+
621     |    T    |    F    | candidate         |
622     |    F    |    F    | not candidate     |
623     +---------+---------+-------------------+
624 .fi
625
626 .RE
627 .RS
628 There may be multiple occurrences of the
629 .B subtree\-exclude
630 or
631 .B subtree\-include
632 directive for each of the targets, but they are mutually exclusive.
633 .RE
634
635 .TP
636 .B suffixmassage "<virtual naming context>" "<real naming context>"
637 All the directives starting with "rewrite" refer to the rewrite engine
638 that has been added to slapd.
639 The "suffixmassage" directive was introduced in the LDAP backend to
640 allow suffix massaging while proxying.
641 It has been obsoleted by the rewriting tools.
642 However, both for backward compatibility and for ease of configuration
643 when simple suffix massage is required, it has been preserved.
644 It wraps the basic rewriting instructions that perform suffix
645 massaging.  See the "REWRITING" section for a detailed list 
646 of the rewrite rules it implies.
647
648 .TP
649 .B t\-f\-support {NO|yes|discover}
650 enable if the remote server supports absolute filters
651 (see \fIRFC 4526\fP for details).
652 If set to
653 .BR discover ,
654 support is detected by reading the remote server's root DSE.
655 If set before any target specification, it affects all targets, unless
656 overridden by any per-target directive.
657
658 .TP
659 .B timeout [<op>=]<val> [...]
660 This directive allows to set per-operation timeouts.
661 Operations can be
662
663 \fB<op> ::= bind, add, delete, modrdn, modify, compare, search\fP
664
665 The overall duration of the \fBsearch\fP operation is controlled either
666 by the \fBtimelimit\fP parameter or by server-side enforced
667 time limits (see \fBtimelimit\fP and \fBlimits\fP in
668 .BR slapd.conf (5)
669 for details).
670 This \fBtimeout\fP parameter controls how long the target can be 
671 irresponsive before the operation is aborted.
672 Timeout is meaningless for the remaining operations,
673 \fBunbind\fP and \fBabandon\fP, which do not imply any response,
674 while it is not yet implemented in currently supported \fBextended\fP 
675 operations.
676 If no operation is specified, the timeout \fBval\fP affects all
677 supported operations.
678 If specified before any target definition, it affects all targets
679 unless overridden by per-target directives.
680
681 Note: if the timeout is exceeded, the operation is cancelled
682 (according to the \fBcancel\fP directive);
683 the protocol does not provide any means to rollback operations,
684 so the client will not be notified about the result of the operation,
685 which may eventually succeeded or not.
686 In case the timeout is exceeded during a bind operation, the connection
687 is destroyed, according to RFC4511.
688
689 .TP
690 .B tls {[try\-]start|[try\-]propagate}
691 execute the StartTLS extended operation when the connection is initialized;
692 only works if the URI directive protocol scheme is not \fBldaps://\fP.
693 \fBpropagate\fP issues the StartTLS operation only if the original
694 connection did.
695 The \fBtry\-\fP prefix instructs the proxy to continue operations
696 if the StartTLS operation failed; its use is highly deprecated.
697 If set before any target specification, it affects all targets, unless
698 overridden by any per-target directive.
699
700 .SH SCENARIOS
701 A powerful (and in some sense dangerous) rewrite engine has been added
702 to both the LDAP and Meta backends.
703 While the former can gain limited beneficial effects from rewriting
704 stuff, the latter can become an amazingly powerful tool.
705 .LP
706 Consider a couple of scenarios first.
707 .LP
708 1) Two directory servers share two levels of naming context;
709 say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
710 Then, an unambiguous Meta database can be configured as:
711 .LP
712 .RS
713 .nf
714 database meta
715 suffix   "\fBdc=foo,dc=com\fP"
716 uri      "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
717 uri      "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
718 .fi
719 .RE
720 .LP
721 Operations directed to a specific target can be easily resolved
722 because there are no ambiguities.
723 The only operation that may resolve to multiple targets is a search
724 with base "dc=foo,dc=com" and scope at least "one", which results in
725 spawning two searches to the targets.
726 .LP
727 2a) Two directory servers don't share any portion of naming context,
728 but they'd present as a single DIT
729 [Caveat: uniqueness of (massaged) entries among the two servers is
730 assumed; integrity checks risk to incur in excessive overhead and have
731 not been implemented].
732 Say we have "dc=bar,dc=org" and "o=Foo,c=US",
733 and we'd like them to appear as branches of "dc=foo,dc=com", say
734 "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
735 Then we need to configure our Meta backend as:
736 .LP
737 .RS
738 .nf
739 database      meta
740 suffix        "dc=foo,dc=com"
741
742 uri           "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
743 suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"
744
745 uri           "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
746 suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
747 .fi
748 .RE
749 .LP
750 Again, operations can be resolved without ambiguity, although
751 some rewriting is required.
752 Notice that the virtual naming context of each target is a branch of
753 the database's naming context; it is rewritten back and forth when
754 operations are performed towards the target servers.
755 What "back and forth" means will be clarified later.
756 .LP
757 When a search with base "dc=foo,dc=com" is attempted, if the 
758 scope is "base" it fails with "no such object"; in fact, the
759 common root of the two targets (prior to massaging) does not
760 exist.
761 If the scope is "one", both targets are contacted with the base
762 replaced by each target's base; the scope is derated to "base".
763 In general, a scope "one" search is honored, and the scope is derated,
764 only when the incoming base is at most one level lower of a target's
765 naming context (prior to massaging).
766 .LP
767 Finally, if the scope is "sub" the incoming base is replaced
768 by each target's unmassaged naming context, and the scope
769 is not altered.
770 .LP
771 2b) Consider the above reported scenario with the two servers
772 sharing the same naming context:
773 .LP
774 .RS
775 .nf
776 database      meta
777 suffix        "\fBdc=foo,dc=com\fP"
778
779 uri           "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
780 suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"
781
782 uri           "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
783 suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
784 .fi
785 .RE
786 .LP
787 All the previous considerations hold, except that now there is
788 no way to unambiguously resolve a DN.
789 In this case, all the operations that require an unambiguous target
790 selection will fail unless the DN is already cached or a default
791 target has been set.
792 Practical configurations may result as a combination of all the
793 above scenarios.
794 .SH ACLs
795 Note on ACLs: at present you may add whatever ACL rule you desire
796 to to the Meta (and LDAP) backends.
797 However, the meaning of an ACL on a proxy may require some
798 considerations.
799 Two philosophies may be considered:
800 .LP
801 a) the remote server dictates the permissions; the proxy simply passes
802 back what it gets from the remote server.
803 .LP
804 b) the remote server unveils "everything"; the proxy is responsible
805 for protecting data from unauthorized access.
806 .LP
807 Of course the latter sounds unreasonable, but it is not.
808 It is possible to imagine scenarios in which a remote host discloses
809 data that can be considered "public" inside an intranet, and a proxy
810 that connects it to the internet may impose additional constraints.
811 To this purpose, the proxy should be able to comply with all the ACL
812 matching criteria that the server supports.
813 This has been achieved with regard to all the criteria supported by
814 slapd except a special subtle case (please file an ITS if you can
815 find other exceptions: <http://www.openldap.org/its/>).
816 The rule
817 .LP
818 .RS
819 .nf
820 access to dn="<dn>" attrs=<attr>
821        by dnattr=<dnattr> read
822        by * none
823 .fi
824 .RE
825 .LP
826 cannot be matched iff the attribute that is being requested, <attr>,
827 is NOT <dnattr>, and the attribute that determines membership,
828 <dnattr>, has not been requested (e.g. in a search)
829 .LP
830 In fact this ACL is resolved by slapd using the portion of entry it
831 retrieved from the remote server without requiring any further
832 intervention of the backend, so, if the <dnattr> attribute has not
833 been fetched, the match cannot be assessed because the attribute is
834 not present, not because no value matches the requirement!
835 .LP
836 Note on ACLs and attribute mapping: ACLs are applied to the mapped
837 attributes; for instance, if the attribute locally known as "foo" is
838 mapped to "bar" on a remote server, then local ACLs apply to attribute
839 "foo" and are totally unaware of its remote name.
840 The remote server will check permissions for "bar", and the local
841 server will possibly enforce additional restrictions to "foo".
842 .\"
843 .\" If this section is moved, also update the reference in
844 .\" libraries/librewrite/RATIONALE.
845 .\"
846 .SH REWRITING
847 A string is rewritten according to a set of rules, called a `rewrite
848 context'.
849 The rules are based on POSIX (''extended'') regular expressions (regex)
850 with substring matching; basic variable substitution and map resolution 
851 of substrings is allowed by specific mechanisms detailed in the following.
852 The behavior of pattern matching/substitution can be altered by a set
853 of flags.
854 .LP
855 The underlying concept is to build a lightweight rewrite module
856 for the slapd server (initially dedicated to the LDAP backend).
857 .SH Passes
858 An incoming string is matched against a set of rules.
859 Rules are made of a regex match pattern, a substitution pattern
860 and a set of actions, described by a set of flags.
861 In case of match a string rewriting is performed according to the
862 substitution pattern that allows to refer to substrings matched in the
863 incoming string.
864 The actions, if any, are finally performed.
865 The substitution pattern allows map resolution of substrings.
866 A map is a generic object that maps a substitution pattern to a value.
867 The flags are divided in "Pattern matching Flags" and "Action Flags";
868 the former alter the regex match pattern behavior while the latter
869 alter the action that is taken after substitution.
870 .SH "Pattern Matching Flags"
871 .TP
872 .B `C'
873 honors case in matching (default is case insensitive)
874 .TP
875 .B `R'
876 use POSIX ''basic'' regular expressions (default is ''extended'')
877 .TP
878 .B `M{n}'
879 allow no more than
880 .B n
881 recursive passes for a specific rule; does not alter the max total count
882 of passes, so it can only enforce a stricter limit for a specific rule.
883 .SH "Action Flags"
884 .TP
885 .B `:'
886 apply the rule once only (default is recursive)
887 .TP
888 .B `@'
889 stop applying rules in case of match; the current rule is still applied 
890 recursively; combine with `:' to apply the current rule only once 
891 and then stop.
892 .TP
893 .B `#'
894 stop current operation if the rule matches, and issue an `unwilling to
895 perform' error.
896 .TP
897 .B `G{n}'
898 jump
899 .B n
900 rules back and forth (watch for loops!).
901 Note that `G{1}' is implicit in every rule.
902 .TP
903 .B `I'
904 ignores errors in rule; this means, in case of error, e.g. issued by a
905 map, the error is treated as a missed match.
906 The `unwilling to perform' is not overridden.
907 .TP
908 .B `U{n}'
909 uses
910 .B
911 n
912 as return code if the rule matches; the flag does not alter the recursive
913 behavior of the rule, so, to have it performed only once, it must be used 
914 in combination with `:', e.g.
915 .B `:U{16}'
916 returns the value `16' after exactly one execution of the rule, if the
917 pattern matches.
918 As a consequence, its behavior is equivalent to `@', with the return
919 code set to
920 .BR n ;
921 or, in other words, `@' is equivalent to `U{0}'.
922 By convention, the freely available codes are above 16 included;
923 the others are reserved.
924 .LP
925 The ordering of the flags can be significant.
926 For instance: `IG{2}' means ignore errors and jump two lines ahead
927 both in case of match and in case of error, while `G{2}I' means ignore
928 errors, but jump two lines ahead only in case of match.
929 .LP
930 More flags (mainly Action Flags) will be added as needed.
931 .SH "Pattern matching:"
932 See
933 .BR regex (7)
934 and/or
935 .BR re_format (7).
936 .SH "Substitution Pattern Syntax:"
937 Everything starting with `%' requires substitution;
938 .LP
939 the only obvious exception is `%%', which is left as is;
940 .LP
941 the basic substitution is `%d', where `d' is a digit;
942 0 means the whole string, while 1-9 is a submatch;
943 .LP
944 a `%' followed by a `{' invokes an advanced substitution.
945 The pattern is:
946 .LP
947 .RS
948 `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
949 .RE
950 .LP
951 where <name> must be a legal name for the map, i.e.
952 .LP
953 .RS
954 .nf
955 <name> ::= [a-z][a-z0-9]* (case insensitive)
956 <op> ::= `>' `|' `&' `&&' `*' `**' `$'
957 .fi
958 .RE
959 .LP
960 and <substitution> must be a legal substitution
961 pattern, with no limits on the nesting level.
962 .LP
963 The operators are:
964 .TP
965 .B >
966 sub context invocation; <name> must be a legal, already defined
967 rewrite context name
968 .TP
969 .B |
970 external command invocation; <name> must refer to a legal, already
971 defined command name (NOT IMPL.)
972 .TP
973 .B &
974 variable assignment; <name> defines a variable in the running
975 operation structure which can be dereferenced later; operator
976 .B &
977 assigns a variable in the rewrite context scope; operator
978 .B &&
979 assigns a variable that scopes the entire session, e.g. its value
980 can be dereferenced later by other rewrite contexts
981 .TP
982 .B *
983 variable dereferencing; <name> must refer to a variable that is
984 defined and assigned for the running operation; operator
985 .B *
986 dereferences a variable scoping the rewrite context; operator
987 .B **
988 dereferences a variable scoping the whole session, e.g. the value
989 is passed across rewrite contexts
990 .TP
991 .B $
992 parameter dereferencing; <name> must refer to an existing parameter;
993 the idea is to make some run-time parameters set by the system
994 available to the rewrite engine, as the client host name, the bind DN
995 if any, constant parameters initialized at config time, and so on;
996 no parameter is currently set by either 
997 .B back\-ldap
998 or
999 .BR back\-meta ,
1000 but constant parameters can be defined in the configuration file
1001 by using the
1002 .B rewriteParam
1003 directive.
1004 .LP
1005 Substitution escaping has been delegated to the `%' symbol, 
1006 which is used instead of `\e' in string substitution patterns
1007 because `\e' is already escaped by slapd's low level parsing routines;
1008 as a consequence, regex escaping requires two `\e' symbols,
1009 e.g. `\fB.*\e.foo\e.bar\fP' must be written as `\fB.*\e\e.foo\e\e.bar\fP'.
1010 .\"
1011 .\" The symbol can be altered at will by redefining the related macro in
1012 .\" "rewrite-int.h".
1013 .\"
1014 .SH "Rewrite context:"
1015 A rewrite context is a set of rules which are applied in sequence.
1016 The basic idea is to have an application initialize a rewrite
1017 engine (think of Apache's mod_rewrite ...) with a set of rewrite
1018 contexts; when string rewriting is required, one invokes the
1019 appropriate rewrite context with the input string and obtains the
1020 newly rewritten one if no errors occur.
1021 .LP
1022 Each basic server operation is associated to a rewrite context;
1023 they are divided in two main groups: client \-> server and
1024 server \-> client rewriting.
1025 .LP
1026 client \-> server:
1027 .LP
1028 .RS
1029 .nf
1030 (default)            if defined and no specific context 
1031                      is available
1032 bindDN               bind
1033 searchBase           search
1034 searchFilter         search
1035 searchFilterAttrDN   search
1036 compareDN            compare
1037 compareAttrDN        compare AVA
1038 addDN                add
1039 addAttrDN            add AVA
1040 modifyDN             modify
1041 modifyAttrDN         modify AVA
1042 modrDN               modrdn
1043 newSuperiorDN        modrdn
1044 deleteDN             delete
1045 exopPasswdDN         password modify extended operation DN if proxy
1046 .fi
1047 .RE
1048 .LP
1049 server \-> client:
1050 .LP
1051 .RS
1052 .nf
1053 searchResult         search (only if defined; no default;
1054                      acts on DN and DN-syntax attributes 
1055                      of search results)
1056 searchAttrDN         search AVA
1057 matchedDN            all ops (only if applicable)
1058 .fi
1059 .RE
1060 .LP
1061 .SH "Basic configuration syntax"
1062 .TP
1063 .B rewriteEngine { on | off }
1064 If `on', the requested rewriting is performed; if `off', no
1065 rewriting takes place (an easy way to stop rewriting without
1066 altering too much the configuration file).
1067 .TP
1068 .B rewriteContext <context name> "[ alias <aliased context name> ]"
1069 <Context name> is the name that identifies the context, i.e. the name
1070 used by the application to refer to the set of rules it contains.
1071 It is used also to reference sub contexts in string rewriting.
1072 A context may alias another one.
1073 In this case the alias context contains no rule, and any reference to
1074 it will result in accessing the aliased one.
1075 .TP
1076 .B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
1077 Determines how a string can be rewritten if a pattern is matched.
1078 Examples are reported below.
1079 .SH "Additional configuration syntax:"
1080 .TP
1081 .B rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"
1082 Allows to define a map that transforms substring rewriting into
1083 something else.
1084 The map is referenced inside the substitution pattern of a rule.
1085 .TP
1086 .B rewriteParam <param name> <param value>
1087 Sets a value with global scope, that can be dereferenced by the
1088 command `%{$paramName}'.
1089 .TP
1090 .B rewriteMaxPasses <number of passes> [<number of passes per rule>]
1091 Sets the maximum number of total rewriting passes that can be
1092 performed in a single rewrite operation (to avoid loops).
1093 A safe default is set to 100; note that reaching this limit is still
1094 treated as a success; recursive invocation of rules is simply 
1095 interrupted.
1096 The count applies to the rewriting operation as a whole, not 
1097 to any single rule; an optional per-rule limit can be set.
1098 This limit is overridden by setting specific per-rule limits
1099 with the `M{n}' flag.
1100 .SH "Configuration examples:"
1101 .nf
1102 # set to `off' to disable rewriting
1103 rewriteEngine on
1104
1105 # the rules the "suffixmassage" directive implies
1106 rewriteEngine on
1107 # all dataflow from client to server referring to DNs
1108 rewriteContext default
1109 rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
1110 # empty filter rule
1111 rewriteContext searchFilter
1112 # all dataflow from server to client
1113 rewriteContext searchResult
1114 rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
1115 rewriteContext searchAttrDN alias searchResult
1116 rewriteContext matchedDN alias searchResult
1117
1118 # Everything defined here goes into the `default' context.
1119 # This rule changes the naming context of anything sent
1120 # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
1121
1122 rewriteRule "(.*)dc=home,[ ]?dc=net"
1123             "%1dc=OpenLDAP, dc=org"  ":"
1124
1125 # since a pretty/normalized DN does not include spaces
1126 # after rdn separators, e.g. `,', this rule suffices:
1127
1128 rewriteRule "(.*)dc=home,dc=net"
1129             "%1dc=OpenLDAP,dc=org"  ":"
1130
1131 # Start a new context (ends input of the previous one).
1132 # This rule adds blanks between DN parts if not present.
1133 rewriteContext  addBlanks
1134 rewriteRule     "(.*),([^ ].*)" "%1, %2"
1135
1136 # This one eats blanks
1137 rewriteContext  eatBlanks
1138 rewriteRule     "(.*),[ ](.*)" "%1,%2"
1139
1140 # Here control goes back to the default rewrite
1141 # context; rules are appended to the existing ones.
1142 # anything that gets here is piped into rule `addBlanks'
1143 rewriteContext  default
1144 rewriteRule     ".*" "%{>addBlanks(%0)}" ":"
1145
1146 .\" # Anything with `uid=username' is looked up in
1147 .\" # /etc/passwd for gecos (I know it's nearly useless,
1148 .\" # but it is there just as a guideline to implementing
1149 .\" # custom maps).
1150 .\" # Note the `I' flag that leaves `uid=username' in place 
1151 .\" # if `username' does not have a valid account, and the
1152 .\" # `:' that forces the rule to be processed exactly once.
1153 .\" rewriteContext  uid2Gecos
1154 .\" rewriteRule     "(.*)uid=([a-z0-9]+),(.+)"
1155 .\"                 "%1cn=%2{xpasswd},%3"      "I:"
1156 .\" 
1157 .\" # Finally, in a bind, if one uses a `uid=username' DN,
1158 .\" # it is rewritten in `cn=name surname' if possible.
1159 .\" rewriteContext  bindDN
1160 .\" rewriteRule     ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
1161 .\" 
1162 # Rewrite the search base according to `default' rules.
1163 rewriteContext  searchBase alias default
1164
1165 # Search results with OpenLDAP DN are rewritten back with
1166 # `dc=home,dc=net' naming context, with spaces eaten.
1167 rewriteContext  searchResult
1168 rewriteRule     "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
1169                 "%{>eatBlanks(%1)}dc=home,dc=net"    ":"
1170
1171 # Bind with email instead of full DN: we first need
1172 # an ldap map that turns attributes into a DN (the
1173 # argument used when invoking the map is appended to 
1174 # the URI and acts as the filter portion)
1175 rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
1176
1177 # Then we need to detect DN made up of a single email,
1178 # e.g. `mail=someone@example.com'; note that the rule
1179 # in case of match stops rewriting; in case of error,
1180 # it is ignored.  In case we are mapping virtual
1181 # to real naming contexts, we also need to rewrite
1182 # regular DNs, because the definition of a bindDn
1183 # rewrite context overrides the default definition.
1184 rewriteContext bindDN
1185 rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
1186
1187 # This is a rather sophisticated example. It massages a
1188 # search filter in case who performs the search has
1189 # administrative privileges.  First we need to keep
1190 # track of the bind DN of the incoming request, which is
1191 # stored in a variable called `binddn' with session scope,
1192 # and left in place to allow regular binding:
1193 rewriteContext  bindDN
1194 rewriteRule     ".+" "%{&&binddn(%0)}%0" ":"
1195
1196 # A search filter containing `uid=' is rewritten only
1197 # if an appropriate DN is bound.
1198 # To do this, in the first rule the bound DN is
1199 # dereferenced, while the filter is decomposed in a
1200 # prefix, in the value of the `uid=<arg>' AVA, and 
1201 # in a suffix. A tag `<>' is appended to the DN. 
1202 # If the DN refers to an entry in the `ou=admin' subtree, 
1203 # the filter is rewritten OR-ing the `uid=<arg>' with
1204 # `cn=<arg>'; otherwise it is left as is. This could be
1205 # useful, for instance, to allow apache's auth_ldap-1.4
1206 # module to authenticate users with both `uid' and
1207 # `cn', but only if the request comes from a possible
1208 # `cn=Web auth,ou=admin,dc=home,dc=net' user.
1209 rewriteContext searchFilter
1210 rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
1211   "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
1212   ":I"
1213 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
1214   "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
1215 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
1216
1217 # This example shows how to strip unwanted DN-valued
1218 # attribute values from a search result; the first rule
1219 # matches DN values below "ou=People,dc=example,dc=com";
1220 # in case of match the rewriting exits successfully.
1221 # The second rule matches everything else and causes
1222 # the value to be rejected.
1223 rewriteContext searchResult
1224 rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
1225 rewriteRule ".*" "" "#"
1226 .fi
1227 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
1228 In case the rewritten DN is an LDAP URI, the operation is initiated
1229 towards the host[:port] indicated in the uri, if it does not refer
1230 to the local server.
1231 E.g.:
1232 .LP
1233 .nf
1234   rewriteRule '^cn=root,.*' '%0'                     'G{3}'
1235   rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
1236   rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
1237   rewriteRule '.*'          'ldap://ldap3.my.org/%0' ':@'
1238 .fi
1239 .LP
1240 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
1241 been written:
1242 .LP
1243 .nf
1244   rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
1245 .fi
1246 .LP
1247 with the advantage of saving one rewrite pass ...)
1248
1249 .SH ACCESS CONTROL
1250 The
1251 .B meta
1252 backend does not honor all ACL semantics as described in
1253 .BR slapd.access (5).
1254 In general, access checking is delegated to the remote server(s).
1255 Only
1256 .B read (=r)
1257 access to the
1258 .B entry
1259 pseudo-attribute and to the other attribute values of the entries
1260 returned by the
1261 .B search
1262 operation is honored, which is performed by the frontend.
1263
1264 .SH PROXY CACHE OVERLAY
1265 The proxy cache overlay 
1266 allows caching of LDAP search requests (queries) in a local database.
1267 See 
1268 .BR slapo\-pcache (5)
1269 for details.
1270
1271 .SH DEPRECATED STATEMENTS
1272 The following statements have been deprecated and should no longer be used.
1273
1274 .TP
1275 .B pseudorootdn "<substitute DN in case of rootdn bind>"
1276 Use
1277 .B idassert\-bind
1278 instead.
1279
1280 .TP
1281 .B pseudorootpw "<substitute password in case of rootdn bind>"
1282 Use
1283 .B idassert\-bind
1284 instead.
1285
1286
1287
1288 .SH FILES
1289 .TP
1290 ETCDIR/slapd.conf
1291 default slapd configuration file
1292 .SH SEE ALSO
1293 .BR slapd.conf (5),
1294 .BR slapd\-ldap (5),
1295 .BR slapo\-pcache (5),
1296 .BR slapd (8),
1297 .BR regex (7),
1298 .BR re_format (7).
1299 .SH AUTHOR
1300 Pierangelo Masarati, based on back-ldap by Howard Chu