]> git.sur5r.net Git - openldap/blob - doc/man/man5/slapd-meta.5
document the multiple URI feature
[openldap] / doc / man / man5 / slapd-meta.5
1 .TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" Copyright 1998-2003 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: as with the
54 .B ldap
55 backend, operational attributes related to entry creation/modification
56 should not be used, as they would be passed to the target servers,
57 generating an error.
58 Moreover, it makes little sense to use such attributes in proxying, as
59 the proxy server doesn't actually store data, so it should have no
60 knowledge of such attributes.
61 While code to strip the modification attributes has been put in place
62 (and #ifdef'd), it implies unmotivated overhead.
63 So it is strongly recommended to set
64 .RS
65 lastmod  off
66 .RE
67 for every
68 .B ldap
69 and
70 .B meta
71 backend.
72 .SH SPECIAL CONFIGURATION DIRECTIVES
73 Target configuration starts with the "uri" directive.
74 All the configuration directives that are not specific to targets
75 should be defined first for clarity, including those that are common
76 to all backends.
77 They are:
78 .TP
79 .B default-target none
80 This directive forces the backend to reject all those operations
81 that must resolve to a single target in case none or multiple
82 targets are selected.
83 They include: add, delete, modify, modrdn; compare is not included, as
84 well as bind since, as they don't alter entries, in case of multiple
85 matches an attempt is made to perform the operation on any candidate
86 target, with the constraint that at most one must succeed.
87 This directive can also be used when processing targets to mark a
88 specific target as default.
89 .TP
90 .B dncache-ttl {forever|disabled|<ttl>}
91 This directive sets the time-to-live of the DN cache.
92 This caches the target that holds a given DN to speed up target
93 selection in case multiple targets would result from an uncached
94 search; forever means cache never expires; disabled means no DN
95 caching; otherwise a valid ( > 0 ) ttl in seconds is required.
96 .SH TARGET SPECIFICATION
97 Target specification starts with a "uri" directive:
98 .TP
99 .B uri <protocol>://[<host>[:<port>]]/<naming context>
100 The "server" directive that was allowed in the LDAP backend (although
101 deprecated) has been discarded in the Meta backend.
102 The <protocol> part can be anything
103 .BR ldap_initialize (3)
104 accepts ({ldap|ldaps|ldapi} and variants); <host> and <port> may be
105 omitted, defaulting to whatever is set in /etc/ldap.conf.
106 The <naming context> part is mandatory.
107 It must end with one of the naming contexts defined for the backend,
108 e.g.:
109 .LP
110 .RS
111 .nf
112 suffix "\fBdc=foo,dc=com\fP"
113 uri    "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
114 .fi
115 .RE
116 .LP
117 The <naming context> part doesn't need to be unique across the targets;
118 it may also match one of the values of the "suffix" directive.
119 Multiple URIs may be defined in a single argument.  The URIs must
120 be separated by TABs (e.g. '\\t'), and the additional URIs must have
121 no <naming context> part.  This causes the underlying library
122 to contact the first server of the list that responds.
123 .TP
124 .B default-target [<target>]
125 The "default-target" directive can also be used during target specification.
126 With no arguments it marks the current target as the default.
127 The optional number marks target <target> as the default one, starting
128 from 1.
129 Target <target> must be defined.
130 .TP
131 .B binddn "<administrative DN for access control purposes>"
132 This directive, as in the LDAP backend, allows to define the DN that is
133 used to query the target server for acl checking; it should have read
134 access on the target server to attributes used on the proxy for acl
135 checking.
136 There is no risk of giving away such values; they are only used to
137 check permissions.
138 .TP
139 .B bindpw <password for access control purposes>
140 This directive sets the password for acl checking in conjunction
141 with the above mentioned "binddn" directive.
142 .TP
143 .B pseudorootdn "<substitute DN in case of rootdn bind>"
144 This directive, if present, sets the DN that will be substituted to
145 the bind DN if a bind with the backend's "rootdn" succeeds.
146 The true "rootdn" of the target server ought not be used; an arbitrary
147 administrative DN should used instead.
148 .TP
149 .B pseudorootpw "<substitute password in case of rootdn bind>"
150 This directive sets the credential that will be used in case a bind
151 with the backend's "rootdn" succeeds, and the bind is propagated to
152 the target using the "pseudorootdn" DN.
153 .LP
154 Note: cleartext credentials must be supplied here; as a consequence,
155 using the pseudorootdn/pseudorootpw directives is inherently unsafe.
156 .TP
157 .B rewrite* ...
158 The rewrite options are described in the "REWRITING" section.
159 .TP
160 .B suffixmassage "<virtual naming context>" "<real naming context>"
161 All the directives starting with "rewrite" refer to the rewrite engine
162 that has been added to slapd.
163 The "suffixmassage" directive was introduced in the LDAP backend to
164 allow suffix massaging while proxying.
165 It has been obsoleted by the rewriting tools.
166 However, both for backward compatibility and for ease of configuration
167 when simple suffix massage is required, it has been preserved.
168 It wraps the basic rewriting instructions that perform suffix
169 massaging.
170 .LP
171 Note: this also fixes a flaw in suffix massaging, which operated
172 on (case insensitive) DNs instead of normalized DNs,
173 so "dc=foo, dc=com" would not match "dc=foo,dc=com".
174 .LP
175 See the "REWRITING" section.
176 .TP
177 .B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
178 This maps object classes and attributes as in the LDAP backend.
179 See
180 .BR slapd-ldap (5).
181 .SH SCENARIOS
182 A powerful (and in some sense dangerous) rewrite engine has been added
183 to both the LDAP and Meta backends.
184 While the former can gain limited beneficial effects from rewriting
185 stuff, the latter can become an amazingly powerful tool.
186 .LP
187 Consider a couple of scenarios first.
188 .LP
189 1) Two directory servers share two levels of naming context;
190 say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
191 Then, an unambiguous Meta database can be configured as:
192 .LP
193 .RS
194 .nf
195 database meta
196 suffix   "\fBdc=foo,dc=com\fP"
197 uri      "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
198 uri      "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
199 .fi
200 .RE
201 .LP
202 Operations directed to a specific target can be easily resolved
203 because there are no ambiguities.
204 The only operation that may resolve to multiple targets is a search
205 with base "dc=foo,dc=com" and scope at least "one", which results in
206 spawning two searches to the targets.
207 .LP
208 2a) Two directory servers don't share any portion of naming context,
209 but they'd present as a single DIT
210 [Caveat: uniqueness of (massaged) entries among the two servers is
211 assumed; integrity checks risk to incur in excessive overhead and have
212 not been implemented].
213 Say we have "dc=bar,dc=org" and "o=Foo,c=US",
214 and we'd like them to appear as branches of "dc=foo,dc=com", say
215 "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
216 Then we need to configure our Meta backend as:
217 .LP
218 .RS
219 .nf
220 database      meta
221 suffix        "dc=foo,dc=com"
222
223 uri           "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
224 suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"
225
226 uri           "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
227 suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
228 .fi
229 .RE
230 .LP
231 Again, operations can be resolved without ambiguity, although
232 some rewriting is required.
233 Notice that the virtual naming context of each target is a branch of
234 the database's naming context; it is rewritten back and forth when
235 operations are performed towards the target servers.
236 What "back and forth" means will be clarified later.
237 .LP
238 When a search with base "dc=foo,dc=com" is attempted, if the 
239 scope is "base" it fails with "no such object"; in fact, the
240 common root of the two targets (prior to massaging) does not
241 exist.
242 If the scope is "one", both targets are contacted with the base
243 replaced by each target's base; the scope is derated to "base".
244 In general, a scope "one" search is honored, and the scope is derated,
245 only when the incoming base is at most one level lower of a target's
246 naming context (prior to massaging).
247 .LP
248 Finally, if the scope is "sub" the incoming base is replaced
249 by each target's unmassaged naming context, and the scope
250 is not altered.
251 .LP
252 2b) Consider the above reported scenario with the two servers
253 sharing the same naming context:
254 .LP
255 .RS
256 .nf
257 database      meta
258 suffix        "\fBdc=foo,dc=com\fP"
259
260 uri           "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
261 suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"
262
263 uri           "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
264 suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
265 .fi
266 .RE
267 .LP
268 All the previous considerations hold, except that now there is
269 no way to unambiguously resolve a DN.
270 In this case, all the operations that require an unambiguous target
271 selection will fail unless the DN is already cached or a default
272 target has been set.
273 Practical configurations may result as a combination of all the
274 above scenarios.
275 .SH ACLs
276 Note on ACLs: at present you may add whatever ACL rule you desire
277 to to the Meta (and LDAP) backends.
278 However, the meaning of an ACL on a proxy may require some
279 considerations.
280 Two philosophies may be considered:
281 .LP
282 a) the remote server dictates the permissions; the proxy simply passes
283 back what it gets from the remote server.
284 .LP
285 b) the remote server unveils "everything"; the proxy is responsible
286 for protecting data from unauthorized access.
287 .LP
288 Of course the latter sounds unreasonable, but it is not.
289 It is possible to imagine scenarios in which a remote host discloses
290 data that can be considered "public" inside an intranet, and a proxy
291 that connects it to the internet may impose additional constraints.
292 To this purpose, the proxy should be able to comply with all the ACL
293 matching criteria that the server supports.
294 This has been achieved with regard to all the criteria supported by
295 slapd except a special subtle case (please drop me a note if you can
296 find other exceptions: <ando@openldap.org>).
297 The rule
298 .LP
299 .RS
300 .nf
301 access to dn="<dn>" attr=<attr>
302        by dnattr=<dnattr> read
303        by * none
304 .fi
305 .RE
306 .LP
307 cannot be matched iff the attribute that is being requested, <attr>,
308 is NOT <dnattr>, and the attribute that determines membership,
309 <dnattr>, has not been requested (e.g. in a search)
310 .LP
311 In fact this ACL is resolved by slapd using the portion of entry it
312 retrieved from the remote server without requiring any further
313 intervention of the backend, so, if the <dnattr> attribute has not
314 been fetched, the match cannot be assessed because the attribute is
315 not present, not because no value matches the requirement!
316 .LP
317 Note on ACLs and attribute mapping: ACLs are applied to the mapped
318 attributes; for instance, if the attribute locally known as "foo" is
319 mapped to "bar" on a remote server, then local ACLs apply to attribute
320 "foo" and are totally unaware of its remote name.
321 The remote server will check permissions for "bar", and the local
322 server will possibly enforce additional restrictions to "foo".
323 .\"
324 .\" If this section is moved, also update the reference in
325 .\" libraries/librewrite/RATIONALE.
326 .\"
327 .SH REWRITING
328 A string is rewritten according to a set of rules, called a `rewrite
329 context'.
330 The rules are based on Regular Expressions (POSIX regex) with
331 substring matching; extensions are planned to allow basic variable
332 substitution and map resolution of substrings.
333 The behavior of pattern matching/substitution can be altered by a set
334 of flags.
335 .LP
336 The underlying concept is to build a lightweight rewrite module
337 for the slapd server (initially dedicated to the LDAP backend).
338 .SH Passes
339 An incoming string is matched agains a set of rules.
340 Rules are made of a match pattern, a substitution pattern and a set of
341 actions.
342 In case of match a string rewriting is performed according to the
343 substitution pattern that allows to refer to substrings matched in the
344 incoming string.
345 The actions, if any, are finally performed.
346 The substitution pattern allows map resolution of substrings.
347 A map is a generic object that maps a substitution pattern to a value.
348 .SH "Pattern Matching Flags"
349 .TP
350 .B `C'
351 honors case in matching (default is case insensitive)
352 .TP
353 .B `R'
354 use POSIX Basic Regular Expressions (default is Extended)
355 .SH "Action Flags"
356 .TP
357 .B `:'
358 apply the rule once only (default is recursive)
359 .TP
360 .B `@'
361 stop applying rules in case of match.
362 .TP
363 .B `#'
364 stop current operation if the rule matches, and issue an `unwilling to
365 perform' error.
366 .TP
367 .B `G{n}'
368 jump n rules back and forth (watch for loops!).
369 Note that `G{1}' is implicit in every rule.
370 .TP
371 .B `I'
372 ignores errors in rule; this means, in case of error, e.g. issued by a
373 map, the error is treated as a missed match.
374 The `unwilling to perform' is not overridden.
375 .LP
376 The ordering of the flags is significant.
377 For instance: `IG{2}' means ignore errors and jump two lines ahead
378 both in case of match and in case of error, while `G{2}I' means ignore
379 errors, but jump thwo lines ahead only in case of match.
380 .LP
381 More flags (mainly Action Flags) will be added as needed.
382 .SH "Pattern matching:"
383 See
384 .BR regex (7).
385 .SH "Substitution Pattern Syntax:"
386 Everything starting with `%' requires substitution;
387 .LP
388 the only obvious exception is `%%', which is left as is;
389 .LP
390 the basic substitution is `%d', where `d' is a digit;
391 0 means the whole string, while 1-9 is a submatch, as discussed in 
392 .BR regex (7);
393 .LP
394 a `%' followed by a `{' invokes an advanced substitution.
395 The pattern is:
396 .LP
397 .RS
398 `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
399 .RE
400 .LP
401 where <name> must be a legal name for the map, i.e.
402 .LP
403 .RS
404 .nf
405 <name> ::= [a-z][a-z0-9]* (case insensitive)
406 <op> ::= `>' `|' `&' `&&' `*' `**' `$'
407 .fi
408 .RE
409 .LP
410 and <substitution> must be a legal substitution
411 pattern, with no limits on the nesting level.
412 .LP
413 The operators are:
414 .TP
415 .B >
416 sub context invocation; <name> must be a legal, already defined
417 rewrite context name
418 .TP
419 .B |
420 external command invocation; <name> must refer to a legal, already
421 defined command name (NOT IMPL.)
422 .TP
423 .B &
424 variable assignment; <name> defines a variable in the running
425 operation structure which can be dereferenced later; operator
426 .B &
427 assigns a variable in the rewrite context scope; operator
428 .B &&
429 assigns a variable that scopes the entire session, e.g. its value
430 can be derefenced later by other rewrite contexts
431 .TP
432 .B *
433 variable dereferencing; <name> must refer to a variable that is
434 defined and assigned for the running operation; operator
435 .B *
436 dereferences a variable scoping the rewrite context; operator
437 .B **
438 dereferences a variable scoping the whole session, e.g. the value
439 is passed across rewrite contexts
440 .TP
441 .B $
442 parameter dereferencing; <name> must refer to an existing parameter;
443 the idea is to make some run-time parameters set by the system
444 available to the rewrite engine, as the client host name, the bind DN
445 if any, constant parameters initialized at config time, and so on;
446 no parameter is currently set by either 
447 .B back\-ldap
448 or
449 .BR back\-meta ,
450 but constant parameters can be defined in the configuration file
451 by using the
452 .B rewriteParam
453 directive.
454 .LP
455 Substitution escaping has been delegated to the `%' symbol, 
456 which is used instead of `\e' in string substitution patterns
457 because `\e' is already escaped by slapd's low level parsing routines;
458 as a consequence, 
459 .BR regex (7)
460 escaping requires two `\e' symbols, e.g. `\fB.*\e.foo\e.bar\fP' must
461 be written as `\fB.*\e\e.foo\e\e.bar\fP'.
462 .\"
463 .\" The symbol can be altered at will by redefining the related macro in
464 .\" "rewrite-int.h".
465 .\"
466 .SH "Rewrite context:"
467 A rewrite context is a set of rules which are applied in sequence.
468 The basic idea is to have an application initialize a rewrite
469 engine (think of Apache's mod_rewrite ...) with a set of rewrite
470 contexts; when string rewriting is required, one invokes the
471 appropriate rewrite context with the input string and obtains the
472 newly rewritten one if no errors occur.
473 .LP
474 Each basic server operation is associated to a rewrite context;
475 they are divided in two main groups: client \-> server and
476 server \-> client rewriting.
477 .LP
478 client -> server:
479 .LP
480 .RS
481 .nf
482 (default)      if defined and no specific context 
483                is available
484 bindDn         bind
485 searchBase     search
486 searchFilter   search
487 compareDn      compare
488 addDn          add
489 modifyDn       modify
490 modrDn         modrdn
491 newSuperiorDn  modrdn
492 deleteDn       delete
493 .fi
494 .RE
495 .LP
496 server -> client:
497 .LP
498 .RS
499 .nf
500 searchResult   search (only if defined; no default;
501                acts on DN and DN-syntax attributes 
502                of search results)
503 matchedDn      all ops (only if defined; no default;
504                NOT IMPL. except in search)
505 .fi
506 .RE
507 .LP
508 .SH "Basic configuration syntax"
509 .TP
510 .B rewriteEngine { on | off }
511 If `on', the requested rewriting is performed; if `off', no
512 rewriting takes place (an easy way to stop rewriting without
513 altering too much the configuration file).
514 .TP
515 .B rewriteContext <context name> "[ alias <aliased context name> ]"
516 <Context name> is the name that identifies the context, i.e. the name
517 used by the application to refer to the set of rules it contains.
518 It is used also to reference sub contexts in string rewriting.
519 A context may aliase another one.
520 In this case the alias context contains no rule, and any reference to
521 it will result in accessing the aliased one.
522 .TP
523 .B rewriteRule "<regex pattern>" "<substitution pattern>" "[ <flags> ]"
524 Determines how a tring can be rewritten if a pattern is matched.
525 Examples are reported below.
526 .SH "Additional configuration syntax:"
527 .TP
528 .B rewriteMap "<map name>" "<map type>" "[ <map attrs> ]"
529 Allows to define a map that transforms substring rewriting into
530 something else.
531 The map is referenced inside the substitution pattern of a rule.
532 .TP
533 .B rewriteParam <param name> <param value>
534 Sets a value with global scope, that can be dereferenced by the
535 command `%{$paramName}'.
536 .TP
537 .B rewriteMaxPasses <number of passes>
538 Sets the maximum number of total rewriting passes that can be
539 performed in a single rewrite operation (to avoid loops).
540 .SH "Configuration examples:"
541 .nf
542 # set to `off' to disable rewriting
543 rewriteEngine on
544
545 # Everything defined here goes into the `default' context.
546 # This rule changes the naming context of anything sent
547 # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
548
549 rewriteRule "(.*)dc=home,[ ]?dc=net"
550             "%1dc=OpenLDAP, dc=org"  ":"
551
552 # since a pretty/normalized DN does not include spaces
553 # after rdn separators, e.g. `,', this rule suffices:
554
555 rewriteRule "(.*)dc=home,dc=net"
556             "%1dc=OpenLDAP,dc=org"  ":"
557
558 # Start a new context (ends input of the previous one).
559 # This rule adds blanks between DN parts if not present.
560 rewriteContext  addBlanks
561 rewriteRule     "(.*),([^ ].*)" "%1, %2"
562
563 # This one eats blanks
564 rewriteContext  eatBlanks
565 rewriteRule     "(.*),[ ](.*)" "%1,%2"
566
567 # Here control goes back to the default rewrite
568 # context; rules are appended to the existing ones.
569 # anything that gets here is piped into rule `addBlanks'
570 rewriteContext  default
571 rewriteRule     ".*" "%{>addBlanks(%0)}" ":"
572
573 .\" # Anything with `uid=username' is looked up in
574 .\" # /etc/passwd for gecos (I know it's nearly useless,
575 .\" # but it is there just as a guideline to implementing
576 .\" # custom maps).
577 .\" # Note the `I' flag that leaves `uid=username' in place 
578 .\" # if `username' does not have a valid account, and the
579 .\" # `:' that forces the rule to be processed exactly once.
580 .\" rewriteContext  uid2Gecos
581 .\" rewriteRule     "(.*)uid=([a-z0-9]+),(.+)"
582 .\"                 "%1cn=%2{xpasswd},%3"      "I:"
583 .\" 
584 .\" # Finally, in a bind, if one uses a `uid=username' DN,
585 .\" # it is rewritten in `cn=name surname' if possible.
586 .\" rewriteContext  bindDn
587 .\" rewriteRule     ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
588 .\" 
589 # Rewrite the search base  according to `default' rules.
590 rewriteContext  searchBase alias default
591
592 # Search results with OpenLDAP DN are rewritten back with
593 # `dc=home,dc=net' naming context, with spaces eaten.
594 rewriteContext  searchResult
595 rewriteRule     "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
596                 "%{>eatBlanks(%1)}dc=home,dc=net"    ":"
597
598 # Bind with email instead of full DN: we first need
599 # an ldap map that turns attributes into a DN (the
600 # argument used when invoking the map is appended to 
601 # the URI and acts as the filter portion)
602 rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
603
604 # Then we need to detect DN made up of a single email,
605 # e.g. `mail=someone@example.com'; note that the rule
606 # in case of match stops rewriting; in case of error,
607 # it is ignored.  In case we are mapping virtual
608 # to real naming contexts, we also need to rewrite
609 # regular DNs, because the definition of a bindDn
610 # rewrite context overrides the default definition.
611 rewriteContext bindDn
612 rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" "@I"
613
614 # This is a rather sophisticated example. It massages a
615 # search filter in case who performs the search has
616 # administrative privileges.  First we need to keep
617 # track of the bind DN of the incoming request, which is
618 # stored in a variable called `binddn' with session scope,
619 # and left in place to allow regular binding:
620 rewriteContext  bindDn
621 rewriteRule     ".+" "%{&&binddn(%0)}%0" ":"
622
623 # A search filter containing `uid=' is rewritten only
624 # if an appropriate DN is bound.
625 # To do this, in the first rule the bound DN is
626 # dereferenced, while the filter is decomposed in a
627 # prefix, in the value of the `uid=<arg>' AVA, and 
628 # in a suffix. A tag `<>' is appended to the DN. 
629 # If the DN refers to an entry in the `ou=admin' subtree, 
630 # the filter is rewritten OR-ing the `uid=<arg>' with
631 # `cn=<arg>'; otherwise it is left as is. This could be
632 # useful, for instance, to allow apache's auth_ldap-1.4
633 # module to authenticate users with both `uid' and
634 # `cn', but only if the request comes from a possible
635 # `cn=Web auth,ou=admin,dc=home,dc=net' user.
636 rewriteContext searchFilter
637 rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
638   "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
639   ":I"
640 rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
641   "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" "@I"
642 rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
643 .fi
644 .SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
645 In case the rewritten DN is an LDAP URI, the operation is initiated
646 towards the host[:port] indicated in the uri, if it does not refer
647 to the local server.
648 E.g.:
649 .LP
650 .nf
651   rewriteRule '^cn=root,.*' '%0'                     'G{3}'
652   rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' '@'
653   rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' '@'
654   rewriteRule '.*'          'ldap://ldap3.my.org/%0' '@'
655 .fi
656 .LP
657 (Rule 1 is simply there to illustrate the `G{n}' action; it could have
658 been written:
659 .LP
660 .nf
661   rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' '@'
662 .fi
663 .LP
664 with the advantage of saving one rewrite pass ...)
665 .SH FILES
666 .TP
667 ETCDIR/slapd.conf
668 default slapd configuration file
669 .SH SEE ALSO
670 .BR slapd.conf (5),
671 .BR slapd\-ldap (5),
672 .BR slapd (8),
673 .BR regex (7).