1SLAPD-META(5)                 File Formats Manual                SLAPD-META(5)
2
3
4

NAME

6       slapd-meta - metadirectory backend
7

SYNOPSIS

9       /etc/openldap/slapd.conf
10

DESCRIPTION

12       The  meta backend to slapd(8) performs basic LDAP proxying with respect
13       to a set of remote LDAP servers,  called  "targets".   The  information
14       contained  in  these  servers can be presented as belonging to a single
15       Directory Information Tree (DIT).
16
17       A basic knowledge of the functionality of the slapd-ldap(5) backend  is
18       recommended.   This  backend has been designed as an enhancement of the
19       ldap backend.  The two backends share many features (actually they also
20       share  portions  of code).  While the ldap backend is intended to proxy
21       operations directed to a single server,  the  meta  backend  is  mainly
22       intended  for  proxying of multiple servers and possibly naming context
23       masquerading.  These features, although useful in many  scenarios,  may
24       result  in  excessive overhead for some applications, so its use should
25       be carefully considered.  In the examples section, some typical scenar‐
26       ios will be discussed.
27
28
29       Note:  When looping back to the same instance of slapd(8), each connec‐
30       tion requires a new thread; as a consequence, slapd(8) must be compiled
31       with thread support, and the threads parameter may need some tuning; in
32       those cases, unless the multiple target feature is  required,  one  may
33       consider using slapd-relay(5) instead, which performs the relayed oper‐
34       ation internally and thus reuses the same connection.
35
36

EXAMPLES

38       There are examples in various places in this document, as  well  as  in
39       the slapd/back-meta/data/ directory in the OpenLDAP source tree.
40

CONFIGURATION

42       These  slapd.conf options apply to the META backend database.  That is,
43       they must follow a "database meta" line and come before any  subsequent
44       "backend" or "database" lines.  Other database options are described in
45       the slapd.conf(5) manual page.
46
47       Note: In early versions of back-ldap and back-meta it  was  recommended
48       to always set
49
50              lastmod  off
51
52       for  every  ldap  and  meta  database.   This  is  because  operational
53       attributes related to entry creation and  modification  should  not  be
54       proxied,  as  they could be mistakenly written to the target server(s),
55       generating an error.  The  current  implementation  automatically  sets
56       lastmod  to off, so its use is redundant and should be omitted, because
57       the lastmod directive will be deprecated in the future.
58
59

SPECIAL CONFIGURATION DIRECTIVES

61       Target configuration starts with the "uri" directive.  All the configu‐
62       ration  directives  that  are not specific to targets should be defined
63       first for clarity, including those that are  common  to  all  backends.
64       They are:
65
66
67       default-target none
68              This directive forces the backend to reject all those operations
69              that must resolve to a single target in case  none  or  multiple
70              targets  are  selected.  They include: add, delete, modify, mod‐
71              rdn; compare is not included, as well as  bind  since,  as  they
72              don't  alter  entries, in case of multiple matches an attempt is
73              made to perform the operation on any candidate target, with  the
74              constraint  that  at  most one must succeed.  This directive can
75              also be used when processing targets to mark a  specific  target
76              as default.
77
78
79       dncache-ttl {DISABLED|forever|<ttl>}
80              This  directive  sets  the  time-to-live  of the DN cache.  This
81              caches the target that holds a  given  DN  to  speed  up  target
82              selection in case multiple targets would result from an uncached
83              search; forever means cache never expires; disabled means no  DN
84              caching;  otherwise a valid ( > 0 ) ttl is required, in the for‐
85              mat illustrated for the idle-timeout directive.
86
87
88       conn-ttl <time>
89              This directive causes a  cached  connection  to  be  dropped  an
90              recreated after a given ttl, regardless of being idle or not.
91
92
93       onerr {CONTINUE|stop}
94              This directive allows to select the behavior in case an error is
95              returned by one target during a search.  The default,  continue,
96              consists  in  continuing the operation, trying to return as much
97              data as possible.  If this statement is set to stop, the  search
98              is terminated as soon as an error is returned by one target, and
99              the error is immediately propagated to the client.
100
101
102       protocol-version {0,2,3}
103              This directive indicates what protocol version must be  used  to
104              contact the remote server.  If set to 0 (the default), the proxy
105              uses the same protocol version used by the client, otherwise the
106              requested  protocol  is used.  The proxy returns unwillingToPer‐
107              form if an operation that is  incompatible  with  the  requested
108              protocol  is attempted.  If set before any target specification,
109              it affects all targets,  unless  overridden  by  any  per-target
110              directive.
111
112
113       pseudoroot-bind-defer {NO|yes}
114              This  directive,  when  set to yes, causes the authentication to
115              the remote servers with the pseudo-root identity to be  deferred
116              until actually needed by subsequent operations.
117
118
119       rebind-as-user {NO|yes}
120              If  this  option  is  given,  the  client's bind credentials are
121              remembered for rebinds, when trying  to  re-establish  a  broken
122              connection,  or  when  chasing a referral, if chase-referrals is
123              set to yes.
124
125

TARGET SPECIFICATION

127       Target specification starts with a "uri" directive:
128
129
130       uri <protocol>://[<host>[:<port>]]/<naming context>
131              The "server" directive that was  allowed  in  the  LDAP  backend
132              (although  deprecated) has been completely discarded in the Meta
133              backend.  The <protocol> part can be anything ldap_initialize(3)
134              accepts ({ldap|ldaps|ldapi} and variants); <host> and <port> may
135              be omitted, defaulting to whatever is set in ldap.conf(5).   The
136              <naming context> part is mandatory.  It must end with one of the
137              naming contexts defined for the backend, e.g.:
138
139              suffix "dc=foo,dc=com"
140              uri    "ldap://x.foo.com/dc=x,dc=foo,dc=com"
141
142              The <naming context> part doesn't need to be unique  across  the
143              targets;  it  may  also  match one of the values of the "suffix"
144              directive.  Multiple URIs may be defined in a  single  argument.
145              The URIs must be separated by TABs (e.g. '\t'; commas or spaces,
146              unlike back-ldap, will not work, because they are legal  in  the
147              <naming  context>,  and we don't want to use URL-encoded <naming
148              context>s), and the additional URIs must have  no  <naming  con‐
149              text>  part.   This causes the underlying library to contact the
150              first server  of  the  list  that  responds.   For  example,  if
151              l1.foo.com  and  l2.foo.com  are shadows of the same server, the
152              directive
153
154              suffix "dc=foo,dc=com"
155              uri    "ldap://l1.foo.com/dc=foo,dc=com ldap://l2.foo.com/"
156
157              causes l2.foo.com to be contacted whenever l1.foo.com  does  not
158              respond.
159
160
161       acl-authcDN <administrative DN for access control purposes>
162              DN which is used to query the target server for acl checking, as
163              in the LDAP backend; it is supposed to have read access  on  the
164              target  server to attributes used on the proxy for acl checking.
165              There is no risk of giving away such values; they are only  used
166              to  check  permissions.  The acl-authcDN identity is by no means
167              implicitly used by the proxy when  the  client  connects  anony‐
168              mously.
169
170
171       acl-passwd <password>
172              Password used with the acl-authcDN above.
173
174
175       bind-timeout <microseconds>
176              This  directive  defines the timeout, in microseconds, used when
177              polling for response after an asynchronous bind connection.  The
178              initial  call  to  ldap_result(3)  is performed with a trade-off
179              timeout of 100000 us; if that results  in  a  timeout  exceeded,
180              subsequent  calls use the value provided with bind-timeout.  The
181              default value is used also for subsequent calls if  bind-timeout
182              is  not  specified.   If set before any target specification, it
183              affects all targets, unless overridden by any per-target  direc‐
184              tive.
185
186
187       chase-referrals {YES|no}
188              enable/disable automatic referral chasing, which is delegated to
189              the underlying libldap, with rebinding eventually  performed  if
190              the  rebind-as-user  directive is used.  The default is to chase
191              referrals.  If set before any target specification,  it  affects
192              all targets, unless overridden by any per-target directive.
193
194
195       default-target [<target>]
196              The  "default-target"  directive  can also be used during target
197              specification.  With no arguments it marks the current target as
198              the  default.   The optional number marks target <target> as the
199              default one, starting from 1.  Target <target> must be defined.
200
201
202       idle-timeout <time>
203              This directive causes a  cached  connection  to  be  dropped  an
204              recreated  after  it  has been idle for the specified time.  The
205              value can be specified as
206
207              [<d>d][<h>h][<m>m][<s>[s]]
208
209              where <d>, <h>, <m> and <s> are respectively  treated  as  days,
210              hours, minutes and seconds.  If set before any target specifica‐
211              tion, it affects all targets, unless overridden by any  per-tar‐
212              get directive.
213
214
215       map {attribute|objectclass} [<local name>|*] {<foreign name>|*}
216              This  maps object classes and attributes as in the LDAP backend.
217              See slapd-ldap(5).
218
219
220       network-timeout <time>
221              Sets the network timeout  value  after  which  poll(2)/select(2)
222              following  a  connect(2)  returns  in  case of no activity.  The
223              value is in seconds, and it can be specified as  for  idle-time‐
224              out.   If  set  before  any target specification, it affects all
225              targets, unless overridden by any per-target directive.
226
227
228       nretries {forever|never|<nretries>}
229              This directive defines how many times a bind should  be  retried
230              in case of temporary failure in contacting a target.  If defined
231              before any target specification, it applies to all  targets  (by
232              default, 3 times); the global value can be overridden by redefi‐
233              nitions inside each target specification.
234
235
236       pseudorootdn <substitute DN in case of rootdn bind>
237              This directive, if present, sets the DN that will be substituted
238              to  the  bind DN if a bind with the backend's "rootdn" succeeds.
239              The true "rootdn" of the target server ought  not  be  used;  an
240              arbitrary administrative DN should used instead.
241
242
243       pseudorootpw <substitute password in case of rootdn bind>
244              This  directive  sets the credential that will be used in case a
245              bind with the backend's "rootdn" succeeds, and the bind is prop‐
246              agated to the target using the "pseudorootdn" DN.
247
248              Note:  cleartext  credentials must be supplied here; as a conse‐
249              quence, using the pseudorootdn/pseudorootpw directives is inher‐
250              ently unsafe.
251
252
253       rewrite* ...
254              The rewrite options are described in the "REWRITING" section.
255
256
257       subtree-exclude <DN>
258              This  directive instructs back-meta to ignore the current target
259              for operations whose requestDN is subordinate to DN.  There  may
260              be  multiple  occurrences  of  the subtree-exclude directive for
261              each of the targets.
262
263
264       suffixmassage <virtual naming context> <real naming context>
265              All the directives starting with "rewrite" refer to the  rewrite
266              engine that has been added to slapd.  The "suffixmassage" direc‐
267              tive was introduced in the LDAP backend to allow suffix  massag‐
268              ing  while  proxying.   It  has  been obsoleted by the rewriting
269              tools.  However, both for backward compatibility and for ease of
270              configuration  when  simple  suffix  massage is required, it has
271              been preserved.  It wraps the basic rewriting instructions  that
272              perform  suffix  massaging.   See  the "REWRITING" section for a
273              detailed list of the rewrite rules it implies.
274
275
276       t-f-support {NO|yes|discover}
277              enable if the  remote  server  supports  absolute  filters  (see
278              draft-zeilenga-ldap-t-f  for details).  If set to discover, sup‐
279              port is detected by reading the remote server's  root  DSE.   If
280              set  before  any  target  specification, it affects all targets,
281              unless overridden by any per-target directive.
282
283
284       timeout [{add|delete|modify|modrdn}=]<seconds> [...]
285              This directive allows to set per-database, per-target  and  per-
286              operation  timeouts.   If  no operation is specified, it affects
287              all.  Currently, only write operations  are  addressed,  because
288              searches can already be limited by means of the limits directive
289              (see slapd.conf(5) for details), and other  operations  are  not
290              supposed  to  incur  into  the  need for timeouts.  Note: if the
291              timelimit is exceeded, the operation is abandoned; the  protocol
292              does  not  provide  any  means to rollback the operation, so the
293              client will not know if the operation  eventually  succeeded  or
294              not.   If  set  before  any target specification, it affects all
295              targets, unless overridden by any per-target directive.
296
297
298       tls {[try-]start|[try-]propagate}
299              execute the StartTLS extended operation when the  connection  is
300              initialized;  only works if the URI directive protocol scheme is
301              not ldaps://.  propagate issues the StartTLS operation  only  if
302              the  original  connection  did.   The  try- prefix instructs the
303              proxy to continue operations if the StartTLS  operation  failed;
304              its use is highly deprecated.  If set before any target specifi‐
305              cation, it affects all targets, unless overridden  by  any  per-
306              target directive.
307
308

SCENARIOS

310       A  powerful (and in some sense dangerous) rewrite engine has been added
311       to both the LDAP and Meta backends.  While the former can gain  limited
312       beneficial effects from rewriting stuff, the latter can become an amaz‐
313       ingly powerful tool.
314
315       Consider a couple of scenarios first.
316
317       1) Two directory servers  share  two  levels  of  naming  context;  say
318       "dc=a,dc=foo,dc=com"  and  "dc=b,dc=foo,dc=com".   Then, an unambiguous
319       Meta database can be configured as:
320
321              database meta
322              suffix   "dc=foo,dc=com"
323              uri      "ldap://a.foo.com/dc=a,dc=foo,dc=com"
324              uri      "ldap://b.foo.com/dc=b,dc=foo,dc=com"
325
326       Operations directed to a specific target can be easily resolved because
327       there  are no ambiguities.  The only operation that may resolve to mul‐
328       tiple targets is a search with base "dc=foo,dc=com" and scope at  least
329       "one", which results in spawning two searches to the targets.
330
331       2a)  Two  directory  servers don't share any portion of naming context,
332       but they'd present as a single DIT [Caveat:  uniqueness  of  (massaged)
333       entries  among  the  two  servers  is assumed; integrity checks risk to
334       incur in excessive overhead and have not  been  implemented].   Say  we
335       have  "dc=bar,dc=org" and "o=Foo,c=US", and we'd like them to appear as
336       branches   of    "dc=foo,dc=com",    say    "dc=a,dc=foo,dc=com"    and
337       "dc=b,dc=foo,dc=com".  Then we need to configure our Meta backend as:
338
339              database      meta
340              suffix        "dc=foo,dc=com"
341
342              uri           "ldap://a.bar.com/dc=a,dc=foo,dc=com"
343              suffixmassage "dc=a,dc=foo,dc=com" "dc=bar,dc=org"
344
345              uri           "ldap://b.foo.com/dc=b,dc=foo,dc=com"
346              suffixmassage "dc=b,dc=foo,dc=com" "o=Foo,c=US"
347
348       Again,  operations  can  be  resolved  without ambiguity, although some
349       rewriting is required.  Notice that the virtual naming context of  each
350       target  is  a  branch of the database's naming context; it is rewritten
351       back and  forth  when  operations  are  performed  towards  the  target
352       servers.  What "back and forth" means will be clarified later.
353
354       When  a  search with base "dc=foo,dc=com" is attempted, if the scope is
355       "base" it fails with "no such object"; in fact, the common root of  the
356       two  targets  (prior  to  massaging)  does  not exist.  If the scope is
357       "one", both targets are contacted with the base replaced by  each  tar‐
358       get's  base; the scope is derated to "base".  In general, a scope "one"
359       search is honored, and the scope is derated,  only  when  the  incoming
360       base  is at most one level lower of a target's naming context (prior to
361       massaging).
362
363       Finally, if the scope is "sub" the incoming base is  replaced  by  each
364       target's unmassaged naming context, and the scope is not altered.
365
366       2b)  Consider  the above reported scenario with the two servers sharing
367       the same naming context:
368
369              database      meta
370              suffix        "dc=foo,dc=com"
371
372              uri           "ldap://a.bar.com/dc=foo,dc=com"
373              suffixmassage "dc=foo,dc=com" "dc=bar,dc=org"
374
375              uri           "ldap://b.foo.com/dc=foo,dc=com"
376              suffixmassage "dc=foo,dc=com" "o=Foo,c=US"
377
378       All the previous considerations hold, except that now there is  no  way
379       to  unambiguously  resolve a DN.  In this case, all the operations that
380       require an unambiguous target selection will  fail  unless  the  DN  is
381       already  cached or a default target has been set.  Practical configura‐
382       tions may result as a combination of all the above scenarios.
383

ACLs

385       Note on ACLs: at present you may add whatever ACL rule you desire to to
386       the  Meta  (and  LDAP)  backends.   However, the meaning of an ACL on a
387       proxy may require some considerations.  Two philosophies may be consid‐
388       ered:
389
390       a)  the remote server dictates the permissions; the proxy simply passes
391       back what it gets from the remote server.
392
393       b) the remote server unveils "everything"; the proxy is responsible for
394       protecting data from unauthorized access.
395
396       Of  course the latter sounds unreasonable, but it is not.  It is possi‐
397       ble to imagine scenarios in which a remote host discloses data that can
398       be considered "public" inside an intranet, and a proxy that connects it
399       to the internet may impose additional constraints.   To  this  purpose,
400       the  proxy  should be able to comply with all the ACL matching criteria
401       that the server supports.  This has been achieved with  regard  to  all
402       the  criteria  supported  by slapd except a special subtle case (please
403       drop me a note if you can find other exceptions:  <ando@openldap.org>).
404       The rule
405
406              access to dn="<dn>" attr=<attr>
407                     by dnattr=<dnattr> read
408                     by * none
409
410       cannot be matched iff the attribute that is being requested, <attr>, is
411       NOT <dnattr>, and the attribute that determines  membership,  <dnattr>,
412       has not been requested (e.g. in a search)
413
414       In  fact  this  ACL  is resolved by slapd using the portion of entry it
415       retrieved from the remote server without requiring any  further  inter‐
416       vention  of  the  backend,  so,  if the <dnattr> attribute has not been
417       fetched, the match cannot be assessed  because  the  attribute  is  not
418       present, not because no value matches the requirement!
419
420       Note  on  ACLs  and  attribute  mapping: ACLs are applied to the mapped
421       attributes; for instance, if the attribute locally known  as  "foo"  is
422       mapped  to "bar" on a remote server, then local ACLs apply to attribute
423       "foo" and are totally unaware of its remote name.   The  remote  server
424       will  check  permissions  for "bar", and the local server will possibly
425       enforce additional restrictions to "foo".
426

REWRITING

428       A string is rewritten according to a set of rules,  called  a  `rewrite
429       context'.   The rules are based on POSIX (''extended'') regular expres‐
430       sions (regex) with substring matching; basic variable substitution  and
431       map resolution of substrings is allowed by specific mechanisms detailed
432       in the following.  The behavior of pattern matching/substitution can be
433       altered by a set of flags.
434
435       The underlying concept is to build a lightweight rewrite module for the
436       slapd server (initially dedicated to the LDAP backend).
437

Passes

439       An incoming string is matched against a set of rules.  Rules  are  made
440       of  a regex match pattern, a substitution pattern and a set of actions,
441       described by a set of flags.  In case of match a  string  rewriting  is
442       performed according to the substitution pattern that allows to refer to
443       substrings matched in the incoming string.  The actions,  if  any,  are
444       finally  performed.   The substitution pattern allows map resolution of
445       substrings.  A map is a generic object that maps a substitution pattern
446       to  a  value.   The  flags  are divided in "Pattern matching Flags" and
447       "Action Flags"; the former alter the regex match pattern behavior while
448       the latter alter the action that is taken after substitution.
449

Pattern Matching Flags

451       `C'    honors case in matching (default is case insensitive)
452
453       `R'    use    POSIX   ''basic''   regular   expressions   (default   is
454              ''extended'')
455
456       `M{n}' allow no more than n recursive passes for a specific rule;  does
457              not  alter the max total count of passes, so it can only enforce
458              a stricter limit for a specific rule.
459

Action Flags

461       `:'    apply the rule once only (default is recursive)
462
463       `@'    stop applying rules in case of match; the current rule is  still
464              applied  recursively; combine with `:' to apply the current rule
465              only once and then stop.
466
467       `#'    stop current  operation  if  the  rule  matches,  and  issue  an
468              `unwilling to perform' error.
469
470       `G{n}' jump  n  rules  back  and  forth  (watch for loops!).  Note that
471              `G{1}' is implicit in every rule.
472
473       `I'    ignores errors in rule; this  means,  in  case  of  error,  e.g.
474              issued  by  a  map, the error is treated as a missed match.  The
475              `unwilling to perform' is not overridden.
476
477       `U{n}' uses n as return code if the rule matches;  the  flag  does  not
478              alter  the  recursive  behavior of the rule, so, to have it per‐
479              formed only once, it must be used in combination with `:',  e.g.
480              `:U{16}'  returns  the value `16' after exactly one execution of
481              the rule, if the pattern matches.  As a consequence, its  behav‐
482              ior  is equivalent to `@', with the return code set to n; or, in
483              other words, `@' is equivalent to `U{0}'.   By  convention,  the
484              freely  available  codes  are  above 16 included; the others are
485              reserved.
486
487       The ordering of the flags can be significant.   For  instance:  `IG{2}'
488       means  ignore errors and jump two lines ahead both in case of match and
489       in case of error, while `G{2}I' means ignore errors, but jump two lines
490       ahead only in case of match.
491
492       More flags (mainly Action Flags) will be added as needed.
493

Pattern matching:

495       See regex(7) and/or re_format(7).
496

Substitution Pattern Syntax:

498       Everything starting with `%' requires substitution;
499
500       the only obvious exception is `%%', which is left as is;
501
502       the basic substitution is `%d', where `d' is a digit; 0 means the whole
503       string, while 1-9 is a submatch;
504
505       a `%' followed by a `{' invokes an advanced substitution.  The  pattern
506       is:
507
508              `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
509
510       where <name> must be a legal name for the map, i.e.
511
512              <name> ::= [a-z][a-z0-9]* (case insensitive)
513              <op> ::= `>' `|' `&' `&&' `*' `**' `$'
514
515       and <substitution> must be a legal substitution pattern, with no limits
516       on the nesting level.
517
518       The operators are:
519
520       >      sub context invocation; <name> must be a legal, already  defined
521              rewrite context name
522
523       |      external  command  invocation;  <name>  must  refer  to a legal,
524              already defined command name (NOT IMPL.)
525
526       &      variable assignment; <name> defines a variable  in  the  running
527              operation  structure which can be dereferenced later; operator &
528              assigns a variable in the rewrite  context  scope;  operator  &&
529              assigns  a  variable  that  scopes  the entire session, e.g. its
530              value can be dereferenced later by other rewrite contexts
531
532       *      variable dereferencing; <name> must refer to a variable that  is
533              defined  and  assigned  for  the  running  operation; operator *
534              dereferences a variable scoping the rewrite context; operator **
535              dereferences  a  variable  scoping  the  whole session, e.g. the
536              value is passed across rewrite contexts
537
538       $      parameter dereferencing; <name> must refer to an existing param‐
539              eter;  the  idea  is to make some run-time parameters set by the
540              system available to the rewrite engine, as the client host name,
541              the  bind  DN  if any, constant parameters initialized at config
542              time, and so  on;  no  parameter  is  currently  set  by  either
543              back-ldap  or  back-meta, but constant parameters can be defined
544              in the configuration file by using the rewriteParam directive.
545
546       Substitution escaping has been delegated to the `%'  symbol,  which  is
547       used  instead  of  `\'  in  string substitution patterns because `\' is
548       already escaped by slapd's low level  parsing  routines;  as  a  conse‐
549       quence,  regex  escaping  requires two `\' symbols, e.g. `.*\.foo\.bar'
550       must be written as `.*\\.foo\\.bar'.
551

Rewrite context:

553       A rewrite context is a set of rules which are applied in sequence.  The
554       basic idea is to have an application initialize a rewrite engine (think
555       of Apache's mod_rewrite ...) with  a  set  of  rewrite  contexts;  when
556       string  rewriting is required, one invokes the appropriate rewrite con‐
557       text with the input string and obtains the newly rewritten  one  if  no
558       errors occur.
559
560       Each  basic  server  operation is associated to a rewrite context; they
561       are divided in two main groups: client -> server and server  ->  client
562       rewriting.
563
564       client -> server:
565
566              (default)            if defined and no specific context
567                                   is available
568              bindDN               bind
569              searchBase           search
570              searchFilter         search
571              searchFilterAttrDN   search
572              compareDN            compare
573              compareAttrDN        compare AVA
574              addDN                add
575              addAttrDN            add AVA
576              modifyDN             modify
577              modifyAttrDN         modify AVA
578              modrDN               modrdn
579              newSuperiorDN        modrdn
580              deleteDN             delete
581              exopPasswdDN         password modify extended operation DN if proxy
582
583       server -> client:
584
585              searchResult         search (only if defined; no default;
586                                   acts on DN and DN-syntax attributes
587                                   of search results)
588              searchAttrDN         search AVA
589              matchedDN            all ops (only if applicable)
590

Basic configuration syntax

592       rewriteEngine { on | off }
593              If  `on',  the  requested  rewriting  is performed; if `off', no
594              rewriting takes place (an easy way  to  stop  rewriting  without
595              altering too much the configuration file).
596
597       rewriteContext <context name> [ alias <aliased context name> ]
598              <Context name> is the name that identifies the context, i.e. the
599              name used by the application to refer to the  set  of  rules  it
600              contains.   It  is used also to reference sub contexts in string
601              rewriting.  A context may alias another one.  In this  case  the
602              alias  context  contains  no  rule, and any reference to it will
603              result in accessing the aliased one.
604
605       rewriteRule <regex match pattern> <substitution pattern> [ <flags> ]
606              Determines how a  string  can  be  rewritten  if  a  pattern  is
607              matched.  Examples are reported below.
608

Additional configuration syntax:

610       rewriteMap <map type> <map name> [ <map attrs> ]
611              Allows  to define a map that transforms substring rewriting into
612              something else.  The map is referenced inside  the  substitution
613              pattern of a rule.
614
615       rewriteParam <param name> <param value>
616              Sets  a value with global scope, that can be dereferenced by the
617              command `%{$paramName}'.
618
619       rewriteMaxPasses <number of passes> [<number of passes per rule>]
620              Sets the maximum number of total rewriting passes  that  can  be
621              performed  in  a  single  rewrite operation (to avoid loops).  A
622              safe default is set to 100; note that  reaching  this  limit  is
623              still  treated  as  a  success; recursive invocation of rules is
624              simply interrupted.  The count applies to the  rewriting  opera‐
625              tion  as  a  whole, not to any single rule; an optional per-rule
626              limit can be set.  This limit is overridden by setting  specific
627              per-rule limits with the `M{n}' flag.
628

Configuration examples:

630       # set to `off' to disable rewriting
631       rewriteEngine on
632
633       # the rules the "suffixmassage" directive implies
634       rewriteEngine on
635       # all dataflow from client to server referring to DNs
636       rewriteContext default
637       rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
638       # empty filter rule
639       rewriteContext searchFilter
640       # all dataflow from server to client
641       rewriteContext searchResult
642       rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
643       rewriteContext searchAttrDN alias searchResult
644       rewriteContext matchedDN alias searchResult
645
646       # Everything defined here goes into the `default' context.
647       # This rule changes the naming context of anything sent
648       # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
649
650       rewriteRule "(.*)dc=home,[ ]?dc=net"
651                   "%1dc=OpenLDAP, dc=org"  ":"
652
653       # since a pretty/normalized DN does not include spaces
654       # after rdn separators, e.g. `,', this rule suffices:
655
656       rewriteRule "(.*)dc=home,dc=net"
657                   "%1dc=OpenLDAP,dc=org"  ":"
658
659       # Start a new context (ends input of the previous one).
660       # This rule adds blanks between DN parts if not present.
661       rewriteContext  addBlanks
662       rewriteRule     "(.*),([^ ].*)" "%1, %2"
663
664       # This one eats blanks
665       rewriteContext  eatBlanks
666       rewriteRule     "(.*),[ ](.*)" "%1,%2"
667
668       # Here control goes back to the default rewrite
669       # context; rules are appended to the existing ones.
670       # anything that gets here is piped into rule `addBlanks'
671       rewriteContext  default
672       rewriteRule     ".*" "%{>addBlanks(%0)}" ":"
673
674       # Rewrite the search base according to `default' rules.
675       rewriteContext  searchBase alias default
676
677       # Search results with OpenLDAP DN are rewritten back with
678       # `dc=home,dc=net' naming context, with spaces eaten.
679       rewriteContext  searchResult
680       rewriteRule     "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
681                       "%{>eatBlanks(%1)}dc=home,dc=net"    ":"
682
683       # Bind with email instead of full DN: we first need
684       # an ldap map that turns attributes into a DN (the
685       # argument used when invoking the map is appended to
686       # the URI and acts as the filter portion)
687       rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
688
689       # Then we need to detect DN made up of a single email,
690       # e.g. `mail=someone@example.com'; note that the rule
691       # in case of match stops rewriting; in case of error,
692       # it is ignored.  In case we are mapping virtual
693       # to real naming contexts, we also need to rewrite
694       # regular DNs, because the definition of a bindDn
695       # rewrite context overrides the default definition.
696       rewriteContext bindDN
697       rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
698
699       # This is a rather sophisticated example. It massages a
700       # search filter in case who performs the search has
701       # administrative privileges.  First we need to keep
702       # track of the bind DN of the incoming request, which is
703       # stored in a variable called `binddn' with session scope,
704       # and left in place to allow regular binding:
705       rewriteContext  bindDN
706       rewriteRule     ".+" "%{&&binddn(%0)}%0" ":"
707
708       # A search filter containing `uid=' is rewritten only
709       # if an appropriate DN is bound.
710       # To do this, in the first rule the bound DN is
711       # dereferenced, while the filter is decomposed in a
712       # prefix, in the value of the `uid=<arg>' AVA, and
713       # in a suffix. A tag `<>' is appended to the DN.
714       # If the DN refers to an entry in the `ou=admin' subtree,
715       # the filter is rewritten OR-ing the `uid=<arg>' with
716       # `cn=<arg>'; otherwise it is left as is. This could be
717       # useful, for instance, to allow apache's auth_ldap-1.4
718       # module to authenticate users with both `uid' and
719       # `cn', but only if the request comes from a possible
720       # `cn=Web auth,ou=admin,dc=home,dc=net' user.
721       rewriteContext searchFilter
722       rewriteRule "(.*\\()uid=([a-z0-9_]+)(\\).*)"
723         "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
724         ":I"
725       rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
726         "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
727       rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
728
729       # This example shows how to strip unwanted DN-valued
730       # attribute values from a search result; the first rule
731       # matches DN values below "ou=People,dc=example,dc=com";
732       # in case of match the rewriting exits successfully.
733       # The second rule matches everything else and causes
734       # the value to be rejected.
735       rewriteContext searchResult
736       rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
737       rewriteRule ".*" "" "#"
738

LDAP Proxy resolution (a possible evolution of slapd-ldap(5)):

740       In  case  the  rewritten  DN is an LDAP URI, the operation is initiated
741       towards the host[:port] indicated in the uri, if it does not  refer  to
742       the local server.  E.g.:
743
744         rewriteRule '^cn=root,.*' '%0'                     'G{3}'
745         rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
746         rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
747         rewriteRule '.*'          'ldap://ldap3.my.org/%0' ':@'
748
749       (Rule  1 is simply there to illustrate the `G{n}' action; it could have
750       been written:
751
752         rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
753
754       with the advantage of saving one rewrite pass ...)
755
756

ACCESS CONTROL

758       The meta backend does not honor  all  ACL  semantics  as  described  in
759       slapd.access(5).   In  general,  access  checking  is  delegated to the
760       remote server(s).  Only read (=r) access to the entry  pseudo-attribute
761       and to the other attribute values of the entries returned by the search
762       operation is honored, which is performed by the frontend.
763
764

PROXY CACHE OVERLAY

766       The  proxy  cache  overlay  allows  caching  of  LDAP  search  requests
767       (queries) in a local database.  See slapo-pcache(5) for details.
768

FILES

770       /etc/openldap/slapd.conf
771              default slapd configuration file
772

SEE ALSO

774       slapd.conf(5),   slapd-ldap(5),  slapo-pcache(5),  slapd(8),  regex(7),
775       re_format(7).
776

AUTHOR

778       Pierangelo Masarati, based on back-ldap by Howard Chu
779
780
781
782OpenLDAP 2.3.34                    2007/2/16                     SLAPD-META(5)
Impressum