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

NAME

6       slapd-meta - metadirectory backend to slapd
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       The  proxy instance of slapd(8) must contain schema information for the
29       attributes and objectClasses used in filters, request DN  and  request-
30       related data in general.  It should also contain schema information for
31       the data returned by the proxied server.  It is the  responsibility  of
32       the  proxy  administrator to keep the schema of the proxy lined up with
33       that of the proxied server.
34
35
36       Note: When looping back to the same instance of slapd(8), each  connec‐
37       tion requires a new thread; as a consequence, slapd(8) must be compiled
38       with thread support, and the threads parameter may need some tuning; in
39       those  cases,  unless  the multiple target feature is required, one may
40       consider using slapd-relay(5) instead, which performs the relayed oper‐
41       ation internally and thus reuses the same connection.
42
43

EXAMPLES

45       There  are  examples  in various places in this document, as well as in
46       the slapd/back-meta/data/ directory in the OpenLDAP source tree.
47

CONFIGURATION

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

SPECIAL CONFIGURATION DIRECTIVES

67       Target configuration starts with the "uri" directive.  All the configu‐
68       ration  directives  that  are not specific to targets should be defined
69       first for clarity, including those that are  common  to  all  backends.
70       They are:
71
72
73       conn-ttl <time>
74              This  directive  causes  a  cached  connection  to be dropped an
75              recreated after a given ttl, regardless of being idle or not.
76
77
78       default-target none
79              This directive forces the backend to reject all those operations
80              that  must  resolve  to a single target in case none or multiple
81              targets are selected.  They include: add, delete,  modify,  mod‐
82              rdn;  compare  is  not  included, as well as bind since, as they
83              don't alter entries, in case of multiple matches an  attempt  is
84              made  to perform the operation on any candidate target, with the
85              constraint that at most one must succeed.   This  directive  can
86              also  be  used when processing targets to mark a specific target
87              as default.
88
89
90       dncache-ttl {DISABLED|forever|<ttl>}
91              This directive sets the time-to-live  of  the  DN  cache.   This
92              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 is required, in the  for‐
96              mat illustrated for the idle-timeout directive.
97
98
99       onerr {CONTINUE|report|stop}
100              This directive allows to select the behavior in case an error is
101              returned by one target during a search.  The default,  continue,
102              consists  in  continuing the operation, trying to return as much
103              data as possible.  If the value is set to stop,  the  search  is
104              terminated  as  soon  as an error is returned by one target, and
105              the error is immediately propagated to the client.  If the value
106              is  set  to report, the search is continuated to the end but, in
107              case at least one target returned an error code, the first  non-
108              success error code is returned.
109
110
111       norefs <NO|yes>
112              If  yes,  do not return search reference responses.  By default,
113              they are returned unless request is LDAPv2.  If set  before  any
114              target  specification, it affects all targets, unless overridden
115              by any per-target directive.
116
117
118       noundeffilter <NO|yes>
119              If yes, return success instead of searching if a filter is unde‐
120              fined or contains undefined portions.  By default, the search is
121              propagated after replacing undefined  portions  with  (!(object‐
122              Class=*)),  which  corresponds  to the empty result set.  If set
123              before any target specification, it affects all targets,  unless
124              overridden by any per-target directive.
125
126
127       protocol-version {0,2,3}
128              This  directive  indicates what protocol version must be used to
129              contact the remote server.  If set to 0 (the default), the proxy
130              uses the same protocol version used by the client, otherwise the
131              requested protocol is used.  The proxy  returns  unwillingToPer‐
132              form  if  an  operation  that is incompatible with the requested
133              protocol is attempted.  If set before any target  specification,
134              it  affects  all  targets,  unless  overridden by any per-target
135              directive.
136
137
138       pseudoroot-bind-defer {YES|no}
139              This directive, when set to yes, causes  the  authentication  to
140              the  remote  servers with the pseudo-root identity (the identity
141              defined in each idassert-bind directive) to  be  deferred  until
142              actually  needed by subsequent operations.  Otherwise, all binds
143              as the rootdn are propagated to the targets.
144
145
146       quarantine <interval>,<num>[;<interval>,<num>[...]]
147              Turns on quarantine of URIs that returned  LDAP_UNAVAILABLE,  so
148              that  an  attempt  to  reconnect  only occurs at given intervals
149              instead of any time a client requests an operation.  The pattern
150              is:  retry  only  after  at least interval seconds elapsed since
151              last attempt, for exactly num times; then use the next  pattern.
152              If  num  for the last pattern is "+", it retries forever; other‐
153              wise, no more retries occur.  This directive must appear  before
154              any  target  specification; it affects all targets with the same
155              pattern.
156
157
158       rebind-as-user {NO|yes}
159              If this option is  given,  the  client's  bind  credentials  are
160              remembered  for  rebinds,  when  trying to re-establish a broken
161              connection, or when chasing a referral,  if  chase-referrals  is
162              set to yes.
163
164
165       session-tracking-request {NO|yes}
166              Adds session tracking control for all requests.  The client's IP
167              and hostname, and the identity associated to  each  request,  if
168              known, are sent to the remote server for informational purposes.
169              This directive is incompatible with setting protocol-version  to
170              2.   If set before any target specification, it affects all tar‐
171              gets, unless overridden by any per-target directive.
172
173
174       single-conn {NO|yes}
175              Discards current cached connection when the client rebinds.
176
177
178       use-temporary-conn {NO|yes}
179              when set to yes, create a temporary connection whenever  compet‐
180              ing  with  other threads for a shared one; otherwise, wait until
181              the shared connection is available.
182
183

TARGET SPECIFICATION

185       Target specification starts with a "uri" directive:
186
187
188       uri <protocol>://[<host>]/<naming context> [...]
189              The <protocol> part can be anything  ldap_initialize(3)  accepts
190              ({ldap|ldaps|ldapi}  and  variants);  the <host> may be omitted,
191              defaulting to whatever is set in ldap.conf(5).  The <naming con‐
192              text>  part is mandatory for the first URI, but it must be omit‐
193              ted for subsequent ones, if any.  The naming context  part  must
194              be within the naming context defined for the backend, e.g.:
195
196              suffix "dc=foo,dc=com"
197              uri    "ldap://x.foo.com/dc=x,dc=foo,dc=com"
198
199              The  <naming  context> part doesn't need to be unique across the
200              targets; it may also match one of the  values  of  the  "suffix"
201              directive.   Multiple URIs may be defined in a single URI state‐
202              ment.  The additional URIs must be separate arguments  and  must
203              not  have any <naming context> part.  This causes the underlying
204              library to contact the first server of the list  that  responds.
205              For  example,  if  l1.foo.com  and l2.foo.com are shadows of the
206              same server, the directive
207
208              suffix "dc=foo,dc=com"
209              uri    "ldap://l1.foo.com/dc=foo,dc=com" "ldap://l2.foo.com/"
210
211              causes l2.foo.com to be contacted whenever l1.foo.com  does  not
212              respond.   In  that case, the URI list is internally rearranged,
213              by moving unavailable URIs to the end, so that  further  connec‐
214              tion attempts occur with respect to the last URI that succeeded.
215
216
217       acl-authcDN <administrative DN for access control purposes>
218              DN which is used to query the target server for acl checking, as
219              in the LDAP backend; it is supposed to have read access  on  the
220              target  server to attributes used on the proxy for acl checking.
221              There is no risk of giving away such values; they are only  used
222              to  check  permissions.  The acl-authcDN identity is by no means
223              implicitly used by the proxy when  the  client  connects  anony‐
224              mously.
225
226
227       acl-passwd <password>
228              Password used with the acl-authcDN above.
229
230
231       bind-timeout <microseconds>
232              This  directive  defines the timeout, in microseconds, used when
233              polling for response after an asynchronous bind connection.  The
234              initial  call  to  ldap_result(3)  is performed with a trade-off
235              timeout of 100000 us; if that results  in  a  timeout  exceeded,
236              subsequent  calls use the value provided with bind-timeout.  The
237              default value is used also for subsequent calls if  bind-timeout
238              is  not  specified.   If set before any target specification, it
239              affects all targets, unless overridden by any per-target  direc‐
240              tive.
241
242
243       chase-referrals {YES|no}
244              enable/disable automatic referral chasing, which is delegated to
245              the underlying libldap, with rebinding eventually  performed  if
246              the  rebind-as-user  directive is used.  The default is to chase
247              referrals.  If set before any target specification,  it  affects
248              all targets, unless overridden by any per-target directive.
249
250
251       default-target [<target>]
252              The  "default-target"  directive  can also be used during target
253              specification.  With no arguments it marks the current target as
254              the  default.   The optional number marks target <target> as the
255              default one, starting from 1.  Target <target> must be defined.
256
257
258       idassert-authzFrom <authz-regexp>
259              if defined, selects what  local  identities  are  authorized  to
260              exploit  the identity assertion feature.  The string <authz-reg‐
261              exp> follows the rules defined for the authzFrom attribute.  See
262              slapd.conf(5),  section  related to authz-policy, for details on
263              the syntax of this field.
264
265
266       idassert-bind    bindmethod=none|simple|sasl    [binddn=<simple    DN>]
267              [credentials=<simple     password>]    [saslmech=<SASL    mech>]
268              [secprops=<properties>] [realm=<realm>] [authcId=<authentication
269              ID>]  [authzId=<authorization  ID>]  [authz={native|proxyauthz}]
270              [mode=<mode>]     [flags=<flags>]     [starttls=no|yes|critical]
271              [tls_cert=<file>]      [tls_key=<file>]      [tls_cacert=<file>]
272              [tls_cacertdir=<path>]      [tls_reqcert=never|allow|try|demand]
273              [tls_ciphersuite=<ciphers>]         [tls_protocol_min=<version>]
274              [tls_crlcheck=none|peer|all]
275              Allows to define the parameters  of  the  authentication  method
276              that  is  internally  used by the proxy to authorize connections
277              that are authenticated by other databases.  The identity defined
278              by this directive, according to the properties associated to the
279              authentication method, is supposed to have auth  access  on  the
280              target server to attributes used on the proxy for authentication
281              and authorization, and to be allowed  to  authorize  the  users.
282              This  requires  to  have  proxyAuthz privileges on a wide set of
283              DNs, e.g.  authzTo=dn.subtree:"", and the remote server to  have
284              authz-policy  set  to to or both.  See slapd.conf(5) for details
285              on these statements and for remarks and  drawbacks  about  their
286              usage.  The supported bindmethods are
287
288              none|simple|sasl
289
290              where  none  is  the  default,  i.e.  no  identity  assertion is
291              performed.
292
293              The authz parameter is used to instruct the SASL bind to exploit
294              native  SASL  authorization, if available; since connections are
295              cached, this should only be used when authorizing with  a  fixed
296              identity  (e.g.  by means of the authzDN or authzID parameters).
297              Otherwise, the default proxyauthz is used, i.e.  the  proxyAuthz
298              control  (Proxied  Authorization,  RFC  4370)  is  added  to all
299              operations.
300
301              The supported modes are:
302
303              <mode> := {legacy|anonymous|none|self}
304
305              If <mode> is not present, and authzId is given, the proxy always
306              authorizes that identity.  <authorization ID> can be
307
308              u:<user>
309
310              [dn:]<DN>
311
312              The  former  is  supposed  to  be  expanded by the remote server
313              according to the authz rules; see slapd.conf(5) for details.  In
314              the  latter  case, whether or not the dn: prefix is present, the
315              string must pass DN validation and normalization.
316
317              The default mode is legacy, which implies that  the  proxy  will
318              either  perform  a  simple bind as the authcDN or a SASL bind as
319              the authcID and assert the client's  identity  when  it  is  not
320              anonymous.   Direct  binds  are always proxied.  The other modes
321              imply that the proxy will always either perform a simple bind as
322              the  authcDN or a SASL bind as the authcID, unless restricted by
323              idassert-authzFrom  rules  (see  below),  in  which   case   the
324              operation  will  fail;  eventually,  it  will  assert some other
325              identity according to <mode>.  Other  identity  assertion  modes
326              are  anonymous  and self, which respectively mean that the empty
327              or the client's identity will be  asserted;  none,  which  means
328              that  no  proxyAuthz control will be used, so the authcDN or the
329              authcID identity will be asserted.  For all modes  that  require
330              the  use  of  the  proxyAuthz  control, on the remote server the
331              proxy identity must have appropriate authzTo permissions, or the
332              asserted identities must have appropriate authzFrom permissions.
333              Note, however, that the ID assertion feature  is  mostly  useful
334              when the asserted identities do not exist on the remote server.
335
336              Flags can be
337
338              override,[non-]prescriptive,proxy-authz-[non-]critical
339
340              When  the  override flag is used, identity assertion takes place
341              even when the database is authorizing for the  identity  of  the
342              client,  i.e. after binding with the provided identity, and thus
343              authenticating it, the proxy  performs  the  identity  assertion
344              using the configured identity and authentication method.
345
346              When  the  prescriptive  flag  is used (the default), operations
347              fail with inappropriateAuthentication for those identities whose
348              assertion is not allowed by the idassert-authzFrom patterns.  If
349              the non-prescriptive flag  is  used,  operations  are  performed
350              anonymously  for those identities whose assertion is not allowed
351              by the idassert-authzFrom patterns.
352
353              When the proxy-authz-non-critical flag is  used  (the  default),
354              the  proxyAuthz  control is not marked as critical, in violation
355              of RFC 4370.  Use of proxy-authz-critical is recommended.
356
357              The TLS settings default to the  same  as  the  main  slapd  TLS
358              settings, except for tls_reqcert which defaults to "demand".
359
360              The  identity  associated  to  this  directive  is also used for
361              privileged operations  whenever  idassert-bind  is  defined  and
362              acl-bind is not.  See acl-bind for details.
363
364
365       idle-timeout <time>
366              This  directive  causes  a  cached  connection  to be dropped an
367              recreated after it has been idle for the  specified  time.   The
368              value can be specified as
369
370              [<d>d][<h>h][<m>m][<s>[s]]
371
372              where  <d>,  <h>,  <m> and <s> are respectively treated as days,
373              hours,  minutes  and  seconds.   If  set   before   any   target
374              specification,  it affects all targets, unless overridden by any
375              per-target directive.
376
377
378       map {attribute|objectclass} [<local name>|*] {<foreign name>|*}
379              This maps object classes and attributes as in the LDAP  backend.
380              See slapd-ldap(5).
381
382
383       network-timeout <time>
384              Sets  the  network  timeout  value after which poll(2)/select(2)
385              following a connect(2) returns in  case  of  no  activity.   The
386              value   is   in   seconds,  and  it  can  be  specified  as  for
387              idle-timeout.   If  set  before  any  target  specification,  it
388              affects   all  targets,  unless  overridden  by  any  per-target
389              directive.
390
391
392       nretries {forever|never|<nretries>}
393              This directive defines how many times a bind should  be  retried
394              in case of temporary failure in contacting a target.  If defined
395              before any target specification, it applies to all  targets  (by
396              default,  3  times);  the  global  value  can  be  overridden by
397              redefinitions inside each target specification.
398
399
400       pseudorootdn <substitute DN in case of rootdn bind>
401              Deprecated; use idassert-bind instead.
402
403
404       pseudorootpw <substitute password in case of rootdn bind>
405              Deprecated; use idassert-bind instead.
406
407
408       rewrite* ...
409              The rewrite options are described in the "REWRITING" section.
410
411
412       subtree-exclude <DN>
413              This directive instructs back-meta to ignore the current  target
414              for  operations whose requestDN is subordinate to DN.  There may
415              be multiple occurrences of  the  subtree-exclude  directive  for
416              each of the targets.
417
418
419       suffixmassage <virtual naming context> <real naming context>
420              All  the directives starting with "rewrite" refer to the rewrite
421              engine that  has  been  added  to  slapd.   The  "suffixmassage"
422              directive  was  introduced  in  the LDAP backend to allow suffix
423              massaging  while  proxying.   It  has  been  obsoleted  by   the
424              rewriting  tools.   However, both for backward compatibility and
425              for  ease  of  configuration  when  simple  suffix  massage   is
426              required,  it  has been preserved.  It wraps the basic rewriting
427              instructions that perform suffix massaging.  See the "REWRITING"
428              section for a detailed list of the rewrite rules it implies.
429
430
431       t-f-support {NO|yes|discover}
432              enable  if  the  remote  server  supports  absolute filters (see
433              draft-zeilenga-ldap-t-f  for  details).   If  set  to  discover,
434              support is detected by reading the remote server's root DSE.  If
435              set before any target specification,  it  affects  all  targets,
436              unless overridden by any per-target directive.
437
438
439       timeout [<op>=]<val> [...]
440              This directive allows to set per-operation timeouts.  Operations
441              can be
442
443              <op> ::= bind, add, delete, modrdn, modify, compare, search
444
445              The overall duration  of  the  search  operation  is  controlled
446              either  by  the  timelimit  parameter or by server-side enforced
447              time limits (see  timelimit  and  limits  in  slapd.conf(5)  for
448              details).   This  timeout parameter controls how long the target
449              can be irresponsive before the operation is aborted.  Timeout is
450              meaningless  for  the  remaining operations, unbind and abandon,
451              which do not imply any response, while it is not yet implemented
452              in  currently supported extended operations.  If no operation is
453              specified, the timeout val affects all supported operations.  If
454              specified  before  any target definition, it affects all targets
455              unless overridden by per-target directives.
456
457              Note: if the timeout is exceeded,  the  operation  is  cancelled
458              (according  to  the  cancel  directive);  the  protocol does not
459              provide any means to rollback operations, so the client will not
460              be  notified  about  the  result  of  the  operation,  which may
461              eventually succeeded or not.  In case the  timeout  is  exceeded
462              during  a bind operation, the connection is destroyed, according
463              to RFC4511.
464
465
466       tls {[try-]start|[try-]propagate}
467              execute the StartTLS extended operation when the  connection  is
468              initialized;  only works if the URI directive protocol scheme is
469              not ldaps://.  propagate issues the StartTLS operation  only  if
470              the  original  connection  did.   The  try- prefix instructs the
471              proxy to continue operations if the StartTLS  operation  failed;
472              its  use  is  highly  deprecated.   If  set  before  any  target
473              specification, it affects all targets, unless overridden by  any
474              per-target directive.
475
476

SCENARIOS

478       A  powerful (and in some sense dangerous) rewrite engine has been added
479       to both the LDAP and Meta backends.  While the former can gain  limited
480       beneficial  effects  from  rewriting  stuff,  the  latter can become an
481       amazingly powerful tool.
482
483       Consider a couple of scenarios first.
484
485       1) Two directory servers  share  two  levels  of  naming  context;  say
486       "dc=a,dc=foo,dc=com"  and  "dc=b,dc=foo,dc=com".   Then, an unambiguous
487       Meta database can be configured as:
488
489              database meta
490              suffix   "dc=foo,dc=com"
491              uri      "ldap://a.foo.com/dc=a,dc=foo,dc=com"
492              uri      "ldap://b.foo.com/dc=b,dc=foo,dc=com"
493
494       Operations directed to a specific target can be easily resolved because
495       there  are  no  ambiguities.   The  only  operation that may resolve to
496       multiple targets is a search with base  "dc=foo,dc=com"  and  scope  at
497       least "one", which results in spawning two searches to the targets.
498
499       2a)  Two  directory  servers don't share any portion of naming context,
500       but they'd present as a single DIT [Caveat:  uniqueness  of  (massaged)
501       entries  among  the  two  servers  is assumed; integrity checks risk to
502       incur in excessive overhead and have not  been  implemented].   Say  we
503       have  "dc=bar,dc=org" and "o=Foo,c=US", and we'd like them to appear as
504       branches   of    "dc=foo,dc=com",    say    "dc=a,dc=foo,dc=com"    and
505       "dc=b,dc=foo,dc=com".  Then we need to configure our Meta backend as:
506
507              database      meta
508              suffix        "dc=foo,dc=com"
509
510              uri           "ldap://a.bar.com/dc=a,dc=foo,dc=com"
511              suffixmassage "dc=a,dc=foo,dc=com" "dc=bar,dc=org"
512
513              uri           "ldap://b.foo.com/dc=b,dc=foo,dc=com"
514              suffixmassage "dc=b,dc=foo,dc=com" "o=Foo,c=US"
515
516       Again,  operations  can  be  resolved  without ambiguity, although some
517       rewriting is required.  Notice that the virtual naming context of  each
518       target  is  a  branch of the database's naming context; it is rewritten
519       back and  forth  when  operations  are  performed  towards  the  target
520       servers.  What "back and forth" means will be clarified later.
521
522       When  a  search with base "dc=foo,dc=com" is attempted, if the scope is
523       "base" it fails with "no such object"; in fact, the common root of  the
524       two  targets  (prior  to  massaging)  does  not exist.  If the scope is
525       "one", both targets are  contacted  with  the  base  replaced  by  each
526       target's  base;  the  scope  is derated to "base".  In general, a scope
527       "one" search is honored, and  the  scope  is  derated,  only  when  the
528       incoming  base  is at most one level lower of a target's naming context
529       (prior to massaging).
530
531       Finally, if the scope is "sub" the incoming base is  replaced  by  each
532       target's unmassaged naming context, and the scope is not altered.
533
534       2b)  Consider  the above reported scenario with the two servers sharing
535       the same naming context:
536
537              database      meta
538              suffix        "dc=foo,dc=com"
539
540              uri           "ldap://a.bar.com/dc=foo,dc=com"
541              suffixmassage "dc=foo,dc=com" "dc=bar,dc=org"
542
543              uri           "ldap://b.foo.com/dc=foo,dc=com"
544              suffixmassage "dc=foo,dc=com" "o=Foo,c=US"
545
546       All the previous considerations hold, except that now there is  no  way
547       to  unambiguously  resolve a DN.  In this case, all the operations that
548       require an unambiguous target selection will  fail  unless  the  DN  is
549       already   cached   or   a  default  target  has  been  set.   Practical
550       configurations may result as a combination of all the above scenarios.
551

ACLs

553       Note on ACLs: at present you may add whatever ACL rule you desire to to
554       the  Meta  (and  LDAP)  backends.   However, the meaning of an ACL on a
555       proxy  may  require  some  considerations.   Two  philosophies  may  be
556       considered:
557
558       a)  the remote server dictates the permissions; the proxy simply passes
559       back what it gets from the remote server.
560
561       b) the remote server unveils "everything"; the proxy is responsible for
562       protecting data from unauthorized access.
563
564       Of  course  the  latter  sounds  unreasonable,  but  it  is not.  It is
565       possible to imagine scenarios in which a  remote  host  discloses  data
566       that  can  be  considered "public" inside an intranet, and a proxy that
567       connects it to the internet may impose additional constraints.  To this
568       purpose,  the  proxy should be able to comply with all the ACL matching
569       criteria that the server supports.  This has been achieved with  regard
570       to  all  the  criteria  supported by slapd except a special subtle case
571       (please  drop  me  a  note  if   you   can   find   other   exceptions:
572       <ando@openldap.org>).  The rule
573
574              access to dn="<dn>" attrs=<attr>
575                     by dnattr=<dnattr> read
576                     by * none
577
578       cannot be matched iff the attribute that is being requested, <attr>, is
579       NOT <dnattr>, and the attribute that determines  membership,  <dnattr>,
580       has not been requested (e.g. in a search)
581
582       In  fact  this  ACL  is resolved by slapd using the portion of entry it
583       retrieved  from  the  remote  server  without  requiring  any   further
584       intervention of the backend, so, if the <dnattr> attribute has not been
585       fetched, the match cannot be assessed  because  the  attribute  is  not
586       present, not because no value matches the requirement!
587
588       Note  on  ACLs  and  attribute  mapping: ACLs are applied to the mapped
589       attributes; for instance, if the attribute locally known  as  "foo"  is
590       mapped  to "bar" on a remote server, then local ACLs apply to attribute
591       "foo" and are totally unaware of its remote name.   The  remote  server
592       will  check  permissions  for "bar", and the local server will possibly
593       enforce additional restrictions to "foo".
594

REWRITING

596       A string is rewritten according to a set of rules,  called  a  `rewrite
597       context'.    The  rules  are  based  on  POSIX  (''extended'')  regular
598       expressions   (regex)   with   substring   matching;   basic   variable
599       substitution  and  map  resolution of substrings is allowed by specific
600       mechanisms  detailed  in  the  following.   The  behavior  of   pattern
601       matching/substitution can be altered by a set of flags.
602
603       The underlying concept is to build a lightweight rewrite module for the
604       slapd server (initially dedicated to the LDAP backend).
605

Passes

607       An incoming string is matched against a set of rules.  Rules  are  made
608       of  a regex match pattern, a substitution pattern and a set of actions,
609       described by a set of flags.  In case of match a  string  rewriting  is
610       performed according to the substitution pattern that allows to refer to
611       substrings matched in the incoming string.  The actions,  if  any,  are
612       finally  performed.   The substitution pattern allows map resolution of
613       substrings.  A map is a generic object that maps a substitution pattern
614       to  a  value.   The  flags  are divided in "Pattern matching Flags" and
615       "Action Flags"; the former alter the regex match pattern behavior while
616       the latter alter the action that is taken after substitution.
617

Pattern Matching Flags

619       `C'    honors case in matching (default is case insensitive)
620
621       `R'    use    POSIX   ''basic''   regular   expressions   (default   is
622              ''extended'')
623
624       `M{n}' allow no more than n recursive passes for a specific rule;  does
625              not  alter the max total count of passes, so it can only enforce
626              a stricter limit for a specific rule.
627

Action Flags

629       `:'    apply the rule once only (default is recursive)
630
631       `@'    stop applying rules in case of match; the current rule is  still
632              applied  recursively; combine with `:' to apply the current rule
633              only once and then stop.
634
635       `#'    stop current  operation  if  the  rule  matches,  and  issue  an
636              `unwilling to perform' error.
637
638       `G{n}' jump  n  rules  back  and  forth  (watch for loops!).  Note that
639              `G{1}' is implicit in every rule.
640
641       `I'    ignores errors in rule; this  means,  in  case  of  error,  e.g.
642              issued  by  a  map, the error is treated as a missed match.  The
643              `unwilling to perform' is not overridden.
644
645       `U{n}' uses n as return code if the rule matches;  the  flag  does  not
646              alter  the  recursive  behavior  of  the  rule,  so,  to have it
647              performed only once, it must be used in  combination  with  `:',
648              e.g.    `:U{16}'  returns  the  value  `16'  after  exactly  one
649              execution  of  the  rule,  if  the  pattern   matches.    As   a
650              consequence,  its behavior is equivalent to `@', with the return
651              code set to n; or, in other words, `@' is equivalent to  `U{0}'.
652              By convention, the freely available codes are above 16 included;
653              the others are reserved.
654
655       The ordering of the flags can be significant.   For  instance:  `IG{2}'
656       means  ignore errors and jump two lines ahead both in case of match and
657       in case of error, while `G{2}I' means ignore errors, but jump two lines
658       ahead only in case of match.
659
660       More flags (mainly Action Flags) will be added as needed.
661

Pattern matching:

663       See regex(7) and/or re_format(7).
664

Substitution Pattern Syntax:

666       Everything starting with `%' requires substitution;
667
668       the only obvious exception is `%%', which is left as is;
669
670       the basic substitution is `%d', where `d' is a digit; 0 means the whole
671       string, while 1-9 is a submatch;
672
673       a `%' followed by a `{' invokes an advanced substitution.  The  pattern
674       is:
675
676              `%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
677
678       where <name> must be a legal name for the map, i.e.
679
680              <name> ::= [a-z][a-z0-9]* (case insensitive)
681              <op> ::= `>' `|' `&' `&&' `*' `**' `$'
682
683       and <substitution> must be a legal substitution pattern, with no limits
684       on the nesting level.
685
686       The operators are:
687
688       >      sub context invocation; <name> must be a legal, already  defined
689              rewrite context name
690
691       |      external  command  invocation;  <name>  must  refer  to a legal,
692              already defined command name (NOT IMPL.)
693
694       &      variable assignment; <name> defines a variable  in  the  running
695              operation  structure which can be dereferenced later; operator &
696              assigns a variable in the rewrite  context  scope;  operator  &&
697              assigns  a  variable  that  scopes  the entire session, e.g. its
698              value can be dereferenced later by other rewrite contexts
699
700       *      variable dereferencing; <name> must refer to a variable that  is
701              defined  and  assigned  for  the  running  operation; operator *
702              dereferences a variable scoping the rewrite context; operator **
703              dereferences  a  variable  scoping  the  whole session, e.g. the
704              value is passed across rewrite contexts
705
706       $      parameter  dereferencing;  <name>  must  refer  to  an  existing
707              parameter;  the  idea is to make some run-time parameters set by
708              the system available to the rewrite engine, as the  client  host
709              name,  the  bind  DN  if any, constant parameters initialized at
710              config time, and so on; no parameter is currently set by  either
711              back-ldap  or  back-meta, but constant parameters can be defined
712              in the configuration file by using the rewriteParam directive.
713
714       Substitution escaping has been delegated to the `%'  symbol,  which  is
715       used  instead  of  `\'  in  string substitution patterns because `\' is
716       already  escaped  by  slapd's  low  level  parsing   routines;   as   a
717       consequence,   regex   escaping   requires   two   `\'   symbols,  e.g.
718       `.*\.foo\.bar' must be written as `.*\\.foo\\.bar'.
719

Rewrite context:

721       A rewrite context is a set of rules which are applied in sequence.  The
722       basic idea is to have an application initialize a rewrite engine (think
723       of Apache's mod_rewrite ...) with  a  set  of  rewrite  contexts;  when
724       string  rewriting  is  required,  one  invokes  the appropriate rewrite
725       context with the input string and obtains the newly rewritten one if no
726       errors occur.
727
728       Each  basic  server  operation is associated to a rewrite context; they
729       are divided in two main groups: client -> server and server  ->  client
730       rewriting.
731
732       client -> server:
733
734              (default)            if defined and no specific context
735                                   is available
736              bindDN               bind
737              searchBase           search
738              searchFilter         search
739              searchFilterAttrDN   search
740              compareDN            compare
741              compareAttrDN        compare AVA
742              addDN                add
743              addAttrDN            add AVA
744              modifyDN             modify
745              modifyAttrDN         modify AVA
746              modrDN               modrdn
747              newSuperiorDN        modrdn
748              deleteDN             delete
749              exopPasswdDN         password modify extended operation DN if proxy
750
751       server -> client:
752
753              searchResult         search (only if defined; no default;
754                                   acts on DN and DN-syntax attributes
755                                   of search results)
756              searchAttrDN         search AVA
757              matchedDN            all ops (only if applicable)
758

Basic configuration syntax

760       rewriteEngine { on | off }
761              If  `on',  the  requested  rewriting  is performed; if `off', no
762              rewriting takes place (an easy way  to  stop  rewriting  without
763              altering too much the configuration file).
764
765       rewriteContext <context name> [ alias <aliased context name> ]
766              <Context name> is the name that identifies the context, i.e. the
767              name used by the application to refer to the  set  of  rules  it
768              contains.   It  is used also to reference sub contexts in string
769              rewriting.  A context may alias another one.  In this  case  the
770              alias  context  contains  no  rule, and any reference to it will
771              result in accessing the aliased one.
772
773       rewriteRule <regex match pattern> <substitution pattern> [ <flags> ]
774              Determines how a  string  can  be  rewritten  if  a  pattern  is
775              matched.  Examples are reported below.
776

Additional configuration syntax:

778       rewriteMap <map type> <map name> [ <map attrs> ]
779              Allows  to define a map that transforms substring rewriting into
780              something else.  The map is referenced inside  the  substitution
781              pattern of a rule.
782
783       rewriteParam <param name> <param value>
784              Sets  a value with global scope, that can be dereferenced by the
785              command `%{$paramName}'.
786
787       rewriteMaxPasses <number of passes> [<number of passes per rule>]
788              Sets the maximum number of total rewriting passes  that  can  be
789              performed  in  a  single  rewrite operation (to avoid loops).  A
790              safe default is set to 100; note that  reaching  this  limit  is
791              still  treated  as  a  success; recursive invocation of rules is
792              simply  interrupted.   The  count  applies  to   the   rewriting
793              operation  as  a whole, not to any single rule; an optional per-
794              rule limit can be set.  This  limit  is  overridden  by  setting
795              specific per-rule limits with the `M{n}' flag.
796

Configuration examples:

798       # set to `off' to disable rewriting
799       rewriteEngine on
800
801       # the rules the "suffixmassage" directive implies
802       rewriteEngine on
803       # all dataflow from client to server referring to DNs
804       rewriteContext default
805       rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
806       # empty filter rule
807       rewriteContext searchFilter
808       # all dataflow from server to client
809       rewriteContext searchResult
810       rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
811       rewriteContext searchAttrDN alias searchResult
812       rewriteContext matchedDN alias searchResult
813
814       # Everything defined here goes into the `default' context.
815       # This rule changes the naming context of anything sent
816       # to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
817
818       rewriteRule "(.*)dc=home,[ ]?dc=net"
819                   "%1dc=OpenLDAP, dc=org"  ":"
820
821       # since a pretty/normalized DN does not include spaces
822       # after rdn separators, e.g. `,', this rule suffices:
823
824       rewriteRule "(.*)dc=home,dc=net"
825                   "%1dc=OpenLDAP,dc=org"  ":"
826
827       # Start a new context (ends input of the previous one).
828       # This rule adds blanks between DN parts if not present.
829       rewriteContext  addBlanks
830       rewriteRule     "(.*),([^ ].*)" "%1, %2"
831
832       # This one eats blanks
833       rewriteContext  eatBlanks
834       rewriteRule     "(.*),[ ](.*)" "%1,%2"
835
836       # Here control goes back to the default rewrite
837       # context; rules are appended to the existing ones.
838       # anything that gets here is piped into rule `addBlanks'
839       rewriteContext  default
840       rewriteRule     ".*" "%{>addBlanks(%0)}" ":"
841
842       # Rewrite the search base according to `default' rules.
843       rewriteContext  searchBase alias default
844
845       # Search results with OpenLDAP DN are rewritten back with
846       # `dc=home,dc=net' naming context, with spaces eaten.
847       rewriteContext  searchResult
848       rewriteRule     "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
849                       "%{>eatBlanks(%1)}dc=home,dc=net"    ":"
850
851       # Bind with email instead of full DN: we first need
852       # an ldap map that turns attributes into a DN (the
853       # argument used when invoking the map is appended to
854       # the URI and acts as the filter portion)
855       rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
856
857       # Then we need to detect DN made up of a single email,
858       # e.g. `mail=someone@example.com'; note that the rule
859       # in case of match stops rewriting; in case of error,
860       # it is ignored.  In case we are mapping virtual
861       # to real naming contexts, we also need to rewrite
862       # regular DNs, because the definition of a bindDn
863       # rewrite context overrides the default definition.
864       rewriteContext bindDN
865       rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
866
867       # This is a rather sophisticated example. It massages a
868       # search filter in case who performs the search has
869       # administrative privileges.  First we need to keep
870       # track of the bind DN of the incoming request, which is
871       # stored in a variable called `binddn' with session scope,
872       # and left in place to allow regular binding:
873       rewriteContext  bindDN
874       rewriteRule     ".+" "%{&&binddn(%0)}%0" ":"
875
876       # A search filter containing `uid=' is rewritten only
877       # if an appropriate DN is bound.
878       # To do this, in the first rule the bound DN is
879       # dereferenced, while the filter is decomposed in a
880       # prefix, in the value of the `uid=<arg>' AVA, and
881       # in a suffix. A tag `<>' is appended to the DN.
882       # If the DN refers to an entry in the `ou=admin' subtree,
883       # the filter is rewritten OR-ing the `uid=<arg>' with
884       # `cn=<arg>'; otherwise it is left as is. This could be
885       # useful, for instance, to allow apache's auth_ldap-1.4
886       # module to authenticate users with both `uid' and
887       # `cn', but only if the request comes from a possible
888       # `cn=Web auth,ou=admin,dc=home,dc=net' user.
889       rewriteContext searchFilter
890       rewriteRule "(.*\\()uid=([a-z0-9_]+)(\\).*)"
891         "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
892         ":I"
893       rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
894         "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
895       rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
896
897       # This example shows how to strip unwanted DN-valued
898       # attribute values from a search result; the first rule
899       # matches DN values below "ou=People,dc=example,dc=com";
900       # in case of match the rewriting exits successfully.
901       # The second rule matches everything else and causes
902       # the value to be rejected.
903       rewriteContext searchResult
904       rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
905       rewriteRule ".*" "" "#"
906

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

908       In  case  the  rewritten  DN is an LDAP URI, the operation is initiated
909       towards the host[:port] indicated in the uri, if it does not  refer  to
910       the local server.  E.g.:
911
912         rewriteRule '^cn=root,.*' '%0'                     'G{3}'
913         rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
914         rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
915         rewriteRule '.*'          'ldap://ldap3.my.org/%0' ':@'
916
917       (Rule  1 is simply there to illustrate the `G{n}' action; it could have
918       been written:
919
920         rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
921
922       with the advantage of saving one rewrite pass ...)
923
924

ACCESS CONTROL

926       The meta backend does not honor  all  ACL  semantics  as  described  in
927       slapd.access(5).   In  general,  access  checking  is  delegated to the
928       remote server(s).  Only read (=r) access to the entry  pseudo-attribute
929       and to the other attribute values of the entries returned by the search
930       operation is honored, which is performed by the frontend.
931
932

PROXY CACHE OVERLAY

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

FILES

938       /etc/openldap/slapd.conf
939              default slapd configuration file
940

SEE ALSO

942       slapd.conf(5),   slapd-ldap(5),  slapo-pcache(5),  slapd(8),  regex(7),
943       re_format(7).
944

AUTHOR

946       Pierangelo Masarati, based on back-ldap by Howard Chu
947
948
949
950OpenLDAP 2.4.23                   2010/06/30                     SLAPD-META(5)
Impressum