slapd-meta.5 45.2 KB
Newer Older
1
.TH SLAPD-META 5 "RELEASEDATE" "OpenLDAP LDVERSION"
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
2
.\" Copyright 1998-2021 The OpenLDAP Foundation, All Rights Reserved.
3
4
5
6
7
8
9
10
.\" Copying restrictions apply.  See the COPYRIGHT file.
.\" Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
.\" $OpenLDAP$
.\"
.\" Portions of this document should probably be moved to slapd-ldap(5)
.\" and maybe manual pages for librewrite.
.\"
.SH NAME
Howard Chu's avatar
Howard Chu committed
11
slapd\-meta \- metadirectory backend to slapd
12
13
14
15
16
17
18
19
20
21
22
23
24
.SH SYNOPSIS
ETCDIR/slapd.conf
.SH DESCRIPTION
The
.B meta
backend to
.BR slapd (8)
performs basic LDAP proxying with respect to a set of remote LDAP
servers, called "targets".
The information contained in these servers can be presented as
belonging to a single Directory Information Tree (DIT).
.LP
A basic knowledge of the functionality of the
Pierangelo Masarati's avatar
Pierangelo Masarati committed
25
.BR slapd\-ldap (5)
26
27
28
29
30
31
32
33
34
35
36
37
38
39
backend is recommended.
This backend has been designed as an enhancement of the ldap backend.
The two backends share many features (actually they also share
portions of code).
While the
.B ldap
backend is intended to proxy operations directed to a single server, the
.B meta
backend is mainly intended for proxying of multiple servers and possibly
naming context masquerading.
These features, although useful in many scenarios, may result in
excessive overhead for some applications, so its use should be
carefully considered.
In the examples section, some typical scenarios will be discussed.
40

41
42
43
44
45
46
47
48
49
The proxy instance of
.BR slapd (8)
must contain schema information for the attributes and objectClasses
used in filters, request DN and request-related data in general.
It should also contain schema information for the data returned
by the proxied server.
It is the responsibility of the proxy administrator to keep the schema
of the proxy lined up with that of the proxied server.

50
51
.LP
Note: When looping back to the same instance of \fBslapd\fP(8), 
52
53
54
each connection requires a new thread; as a consequence, the \fBslapd\fP(8)
\fBthreads\fP parameter may need some tuning. In those cases, unless the
multiple target feature is required, one may consider using \fBslapd\-relay\fP(5) instead, 
Kurt Zeilenga's avatar
Kurt Zeilenga committed
55
which performs the relayed operation internally and thus reuses 
56
57
the same connection.

58
.SH EXAMPLES
Pierangelo Masarati's avatar
Pierangelo Masarati committed
59
There are examples in various places in this document, as well as in the
60
slapd/back-meta/data/ directory in the OpenLDAP source tree.
61
.SH CONFIGURATION
Pierangelo Masarati's avatar
Pierangelo Masarati committed
62
63
64
These
.B slapd.conf
options apply to the META backend database.
65
66
That is, they must follow a "database meta" line and come before any
subsequent "backend" or "database" lines.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
67
68
69
Other database options are described in the
.BR slapd.conf (5)
manual page.
70
.LP
71
72
Note: In early versions of back-ldap and back-meta it was recommended to always set
.LP
73
.RS
74
.nf
75
lastmod  off
76
.fi
77
.RE
78
.LP
79
for 
80
81
82
.B ldap
and
.B meta
83
84
85
databases.
This was required because operational attributes related to entry creation 
and modification should not be proxied, as they could be mistakenly written
86
to the target server(s), generating an error.
87
88
The current implementation automatically sets lastmod to \fBoff\fP, 
so its use is redundant and should be omitted.
89

Pierangelo Masarati's avatar
Pierangelo Masarati committed
90
.SH SPECIAL CONFIGURATION DIRECTIVES
91
92
93
94
95
Target configuration starts with the "uri" directive.
All the configuration directives that are not specific to targets
should be defined first for clarity, including those that are common
to all backends.
They are:
Pierangelo Masarati's avatar
Pierangelo Masarati committed
96

97
98
99
100
.TP
.B conn\-pool\-max <int>
This directive defines the maximum size of the privileged connections pool.

101
.TP
Howard Chu's avatar
Howard Chu committed
102
.B conn\-ttl <time>
103
104
105
This directive causes a cached connection to be dropped an recreated
after a given ttl, regardless of being idle or not.

106
.TP
Howard Chu's avatar
Howard Chu committed
107
.B default\-target none
108
109
110
111
112
113
This directive forces the backend to reject all those operations
that must resolve to a single target in case none or multiple
targets are selected.
They include: add, delete, modify, modrdn; compare is not included, as
well as bind since, as they don't alter entries, in case of multiple
matches an attempt is made to perform the operation on any candidate
Pierangelo Masarati's avatar
Pierangelo Masarati committed
114
target, with the constraint that at most one must succeed.
115
116
This directive can also be used when processing targets to mark a
specific target as default.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
117

118
.TP
Howard Chu's avatar
Howard Chu committed
119
.B dncache\-ttl {DISABLED|forever|<ttl>}
Pierangelo Masarati's avatar
Pierangelo Masarati committed
120
121
This directive sets the time-to-live of the DN cache.
This caches the target that holds a given DN to speed up target
122
selection in case multiple targets would result from an uncached
Pierangelo Masarati's avatar
Pierangelo Masarati committed
123
search; forever means cache never expires; disabled means no DN
124
125
caching; otherwise a valid ( > 0 ) ttl is required, in the format
illustrated for the 
Howard Chu's avatar
Howard Chu committed
126
.B idle\-timeout
127
directive.
128
129

.TP
130
.B onerr {CONTINUE|report|stop}
131
This directive allows one to select the behavior in case an error is returned
132
133
134
by one target during a search.
The default, \fBcontinue\fP, consists in continuing the operation, 
trying to return as much data as possible.
135
If the value is set to \fBstop\fP, the search is terminated as soon 
136
137
as an error is returned by one target, and the error is immediately 
propagated to the client.
Josh Soref's avatar
Josh Soref committed
138
If the value is set to \fBreport\fP, the search is continued to the end
139
140
but, in case at least one target returned an error code, the first
non-success error code is returned.
141

142
143
144
145
146
147
148
149
150
.TP
.B norefs <NO|yes>
If
.BR yes ,
do not return search reference responses.
By default, they are returned unless request is LDAPv2.
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.

151
152
153
154
155
156
157
158
159
160
161
162
163
.TP
.B noundeffilter <NO|yes>
If
.BR yes ,
return success instead of searching if a filter is undefined or contains
undefined portions.
By default, the search is propagated after replacing undefined portions
with
.BR (!(objectClass=*)) ,
which corresponds to the empty result set.
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.

164
165
166
167
168
169
170
171
172
173
174
.TP
.B protocol\-version {0,2,3}
This directive indicates what protocol version must be used to contact
the remote server.
If set to 0 (the default), the proxy uses the same protocol version 
used by the client, otherwise the requested protocol is used.
The proxy returns \fIunwillingToPerform\fP if an operation that is 
incompatible with the requested protocol is attempted.
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.

175
.TP
Howard Chu's avatar
Howard Chu committed
176
.B pseudoroot\-bind\-defer {YES|no}
177
178
179
This directive, when set to 
.BR yes ,
causes the authentication to the remote servers with the pseudo-root
Pierangelo Masarati's avatar
Pierangelo Masarati committed
180
identity (the identity defined in each
181
.B idassert\-bind
Pierangelo Masarati's avatar
Pierangelo Masarati committed
182
directive) to be deferred until actually needed by subsequent operations.
183
Otherwise, all binds as the rootdn are propagated to the targets.
184

185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
.TP
.B quarantine <interval>,<num>[;<interval>,<num>[...]]
Turns on quarantine of URIs that returned
.IR LDAP_UNAVAILABLE ,
so that an attempt to reconnect only occurs at given intervals instead
of any time a client requests an operation.
The pattern is: retry only after at least
.I interval
seconds elapsed since last attempt, for exactly
.I num
times; then use the next pattern.
If
.I num
for the last pattern is "\fB+\fP", it retries forever; otherwise, 
no more retries occur.
This directive must appear before any target specification;
it affects all targets with the same pattern.

203
.TP
Howard Chu's avatar
Howard Chu committed
204
.B rebind\-as\-user {NO|yes}
205
If this option is given, the client's bind credentials are remembered
206
207
for rebinds, when trying to re-establish a broken connection,
or when chasing a referral, if 
Howard Chu's avatar
Howard Chu committed
208
.B chase\-referrals
209
210
is set to
.IR yes .
211

212
213
214
215
216
217
218
219
220
.TP
.B session\-tracking\-request {NO|yes}
Adds session tracking control for all requests.
The client's IP and hostname, and the identity associated to each request,
if known, are sent to the remote server for informational purposes.
This directive is incompatible with setting \fIprotocol\-version\fP to 2.
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.

221
222
223
224
.TP
.B single\-conn {NO|yes}
Discards current cached connection when the client rebinds.

225
.TP
Howard Chu's avatar
Howard Chu committed
226
.B use\-temporary\-conn {NO|yes}
227
228
229
230
231
when set to 
.BR yes ,
create a temporary connection whenever competing with other threads
for a shared one; otherwise, wait until the shared connection is available.

Pierangelo Masarati's avatar
Pierangelo Masarati committed
232
.SH TARGET SPECIFICATION
233
Target specification starts with a "uri" directive:
Pierangelo Masarati's avatar
Pierangelo Masarati committed
234

235
.TP
236
.B uri <protocol>://[<host>]/<naming context> [...]
Hallvard Furuseth's avatar
Hallvard Furuseth committed
237
238
The <protocol> part can be anything
.BR ldap_initialize (3)
239
accepts ({ldap|ldaps|ldapi} and variants); the <host> may be
240
241
omitted, defaulting to whatever is set in
.BR ldap.conf (5).
242
243
244
The <naming context> part is \fImandatory\fP for the first URI,
but it \fImust be omitted\fP for subsequent ones, if any.
The naming context part must be within the naming context defined for the backend,
245
246
e.g.:
.LP
247
.RS
248
.nf
249
250
suffix "\fBdc=foo,dc=com\fP"
uri    "ldap://x.foo.com/dc=x,\fBdc=foo,dc=com\fP"
251
.fi
252

253
.RE
254
.RS
255
256
The <naming context> part doesn't need to be unique across the targets;
it may also match one of the values of the "suffix" directive.
257
Multiple URIs may be defined in a single URI statement.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
258
The additional URIs must be separate arguments and must not have any
259
<naming context> part.  This causes the underlying library
260
to contact the first server of the list that responds.
261
262
263
264
265
For example, if \fIl1.foo.com\fP and \fIl2.foo.com\fP are shadows
of the same server, the directive
.LP
.nf
suffix "\fBdc=foo,dc=com\fP"
266
uri    "ldap://l1.foo.com/\fBdc=foo,dc=com\fP" "ldap://l2.foo.com/"
267
268
269
270
271
272
.fi

.RE
.RS
causes \fIl2.foo.com\fP to be contacted whenever \fIl1.foo.com\fP
does not respond.
273
274
275
In that case, the URI list is internally rearranged, by moving unavailable
URIs to the end, so that further connection attempts occur with respect to
the last URI that succeeded.
276
.RE
Pierangelo Masarati's avatar
Pierangelo Masarati committed
277

278
.TP
Howard Chu's avatar
Howard Chu committed
279
.B acl\-authcDN "<administrative DN for access control purposes>"
280
281
282
DN which is used to query the target server for acl checking,
as in the LDAP backend; it is supposed to have read access 
on the target server to attributes used on the proxy for acl checking.
283
284
There is no risk of giving away such values; they are only used to
check permissions.
Howard Chu's avatar
Howard Chu committed
285
.B The acl\-authcDN identity is by no means implicitly used by the proxy 
286
.B when the client connects anonymously.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
287

288
.TP
Howard Chu's avatar
Howard Chu committed
289
.B acl\-passwd <password>
290
Password used with the
291
.B acl\-authcDN
292
above.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
293

294
.TP
Howard Chu's avatar
Howard Chu committed
295
.B bind\-timeout <microseconds>
296
297
298
299
300
This directive defines the timeout, in microseconds, used when polling
for response after an asynchronous bind connection.  The initial call
to ldap_result(3) is performed with a trade-off timeout of 100000 us;
if that results in a timeout exceeded, subsequent calls use the value
provided with
Howard Chu's avatar
Howard Chu committed
301
.BR bind\-timeout .
302
The default value is used also for subsequent calls if
Howard Chu's avatar
Howard Chu committed
303
.B bind\-timeout
304
305
306
307
is not specified.
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.

Pierangelo Masarati's avatar
Pierangelo Masarati committed
308
.TP
Howard Chu's avatar
Howard Chu committed
309
.B chase\-referrals {YES|no}
Pierangelo Masarati's avatar
Pierangelo Masarati committed
310
311
enable/disable automatic referral chasing, which is delegated to the
underlying libldap, with rebinding eventually performed if the
Howard Chu's avatar
Howard Chu committed
312
\fBrebind\-as\-user\fP directive is used.  The default is to chase referrals.
313
If set before any target specification, it affects all targets, unless
314
315
316
317
overridden by any per-target directive.

.TP
.B client\-pr {accept-unsolicited|DISABLE|<size>}
318
This feature allows one to use RFC 2696 Paged Results control when performing
319
320
search operations with a specific target,
irrespective of the client's request.
321
322
When set to a numeric value, Paged Results control is always
used with \fIsize\fP as the page size.
323
When set to \fIaccept\-unsolicited\fP, unsolicited Paged Results
324
325
326
327
328
329
330
331
control responses are accepted and honored
for compatibility with broken remote DSAs.
The client is not exposed to paged results handling
between
.BR slapd\-meta (5)
and the remote servers.
By default (disabled), Paged Results control is not used
and responses are not accepted.
332
If set before any target specification, it affects all targets, unless
333
overridden by any per-target directive.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
334
335

.TP
Howard Chu's avatar
Howard Chu committed
336
337
.B default\-target [<target>]
The "default\-target" directive can also be used during target specification.
338
339
340
341
With no arguments it marks the current target as the default.
The optional number marks target <target> as the default one, starting
from 1.
Target <target> must be defined.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
342

343
344
345
346
347
348
349
350
351
352
353
354
355
.TP
.B filter <pattern>
This directive allows specifying a
.BR regex (5)
pattern to indicate what search filter terms are actually served by a target.

In a search request, if the search filter matches the \fIpattern\fP
the target is considered while fulfilling the request; otherwise
the target is ignored. There may be multiple occurrences of
the
.B filter
directive for each target.

356
.TP
Howard Chu's avatar
Howard Chu committed
357
.B idassert\-authzFrom <authz-regexp>
358
359
360
361
if defined, selects what
.I local
identities are authorized to exploit the identity assertion feature.
The string
362
.B <authz\-regexp>
363
364
365
366
367
368
follows the rules defined for the
.I authzFrom
attribute.
See 
.BR slapd.conf (5),
section related to
Howard Chu's avatar
Howard Chu committed
369
.BR authz\-policy ,
370
371
372
373
for details on the syntax of this field.

.HP
.hy 0
Howard Chu's avatar
Howard Chu committed
374
.B idassert\-bind
375
376
377
378
.B bindmethod=none|simple|sasl [binddn=<simple DN>] [credentials=<simple password>]
.B [saslmech=<SASL mech>] [secprops=<properties>] [realm=<realm>]
.B [authcId=<authentication ID>] [authzId=<authorization ID>]
.B [authz={native|proxyauthz}] [mode=<mode>] [flags=<flags>]
379
.B [starttls=no|yes|critical]
380
381
382
383
384
.B [tls_cert=<file>]
.B [tls_key=<file>]
.B [tls_cacert=<file>]
.B [tls_cacertdir=<path>]
.B [tls_reqcert=never|allow|try|demand]
385
.B [tls_reqsan=never|allow|try|demand]
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
386
.B [tls_cipher_suite=<ciphers>]
387
.B [tls_ecname=<ciphers>]
Howard Chu's avatar
Howard Chu committed
388
.B [tls_protocol_min=<major>[.<minor>]]
389
390
.B [tls_crlcheck=none|peer|all]
.RS
391
Allows one to define the parameters of the authentication method that is
392
393
394
395
396
397
398
399
400
401
402
internally used by the proxy to authorize connections that are 
authenticated by other databases.
The identity defined by this directive, according to the properties
associated to the authentication method, is supposed to have auth access 
on the target server to attributes used on the proxy for authentication
and authorization, and to be allowed to authorize the users.
This requires to have
.B proxyAuthz
privileges on a wide set of DNs, e.g.
.BR authzTo=dn.subtree:"" ,
and the remote server to have
Howard Chu's avatar
Howard Chu committed
403
.B authz\-policy
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
set to
.B to
or
.BR both .
See
.BR slapd.conf (5)
for details on these statements and for remarks and drawbacks about
their usage.
The supported bindmethods are

\fBnone|simple|sasl\fP

where
.B none
is the default, i.e. no \fIidentity assertion\fP is performed.

The authz parameter is used to instruct the SASL bind to exploit 
.B native 
SASL authorization, if available; since connections are cached,
this should only be used when authorizing with a fixed identity
(e.g. by means of the 
.B authzDN
or
.B authzID
parameters).
Otherwise, the default
.B proxyauthz
is used, i.e. the proxyAuthz control (Proxied Authorization, RFC 4370)
is added to all operations.

The supported modes are:

\fB<mode> := {legacy|anonymous|none|self}\fP

If 
.B <mode>
is not present, and 
.B authzId
is given, the proxy always authorizes that identity.
.B <authorization ID>
can be 

\fBu:<user>\fP

\fB[dn:]<DN>\fP

The former is supposed to be expanded by the remote server according 
to the authz rules; see
.BR slapd.conf (5)
for details.
In the latter case, whether or not the 
.B dn:
prefix is present, the string must pass DN validation and normalization.

The default mode is 
.BR legacy ,
which implies that the proxy will either perform a simple bind as the
.I authcDN
or a SASL bind as the
.I authcID
and assert the client's identity when it is not anonymous.
Direct binds are always proxied.
The other modes imply that the proxy will always either perform a simple bind 
as the
.IR authcDN
or a SASL bind as the
.IR authcID ,
unless restricted by
Howard Chu's avatar
Howard Chu committed
472
.BR idassert\-authzFrom
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
rules (see below), in which case the operation will fail;
eventually, it will assert some other identity according to
.BR <mode> .
Other identity assertion modes are
.BR anonymous
and
.BR self ,
which respectively mean that the 
.I empty 
or the 
.IR client 's 
identity
will be asserted;
.BR none ,
which means that no proxyAuthz control will be used, so the
.I authcDN
or the
.I authcID
identity will be asserted.
For all modes that require the use of the
.I proxyAuthz 
control, on the remote server the proxy identity must have appropriate 
.I authzTo
permissions, or the asserted identities must have appropriate
.I authzFrom 
permissions.  Note, however, that the ID assertion feature is mostly 
useful when the asserted identities do not exist on the remote server.
500
501
502
503
504
505
506
507
508
When
.I bindmethod
is
.BR SASL ,
the 
.I authcDN
must be specified in addition to the
.IR authcID ,
although it is not used within the authentication process.
509
510
511

Flags can be

512
\fBoverride,[non\-]prescriptive,proxy\-authz\-[non\-]critical\fP
513
514
515
516
517
518
519
520
521
522
523
524
525
526

When the 
.B override
flag is used, identity assertion takes place even when the database
is authorizing for the identity of the client, i.e. after binding
with the provided identity, and thus authenticating it, the proxy
performs the identity assertion using the configured identity and
authentication method.

When the
.B prescriptive
flag is used (the default), operations fail with
\fIinappropriateAuthentication\fP
for those identities whose assertion is not allowed by the
Howard Chu's avatar
Howard Chu committed
527
.B idassert\-authzFrom
528
529
patterns.
If the 
Howard Chu's avatar
Howard Chu committed
530
.B non\-prescriptive
531
532
flag is used, operations are performed anonymously for those identities 
whose assertion is not allowed by the
Howard Chu's avatar
Howard Chu committed
533
.B idassert\-authzFrom
534
535
patterns.

536
537
538
539
540
541
542
When the
.B proxy\-authz\-non\-critical
flag is used (the default), the proxyAuthz control is not marked as critical,
in violation of RFC 4370.  Use of
.B proxy\-authz\-critical
is recommended.

543
544
545
The TLS settings default to the same as the main slapd TLS settings,
except for
.B tls_reqcert
546
547
548
which defaults to "demand", and
.B tls_reqsan
which defaults to "allow"..
549
550

The identity associated to this directive is also used for privileged
Howard Chu's avatar
Howard Chu committed
551
552
operations whenever \fBidassert\-bind\fP is defined and \fBacl\-bind\fP
is not.  See \fBacl\-bind\fP for details.
553
554
.RE

Pierangelo Masarati's avatar
Pierangelo Masarati committed
555
.TP
Howard Chu's avatar
Howard Chu committed
556
.B idle\-timeout <time>
557
558
559
560
561
562
563
564
This directive causes a cached connection to be dropped an recreated
after it has been idle for the specified time.
The value can be specified as

[<d>d][<h>h][<m>m][<s>[s]]

where <d>, <h>, <m> and <s> are respectively treated as days, hours, 
minutes and seconds.
565
566
567
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.

568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
.TP
.B keepalive  <idle>:<probes>:<interval>
The
.B keepalive
parameter sets the values of \fIidle\fP, \fIprobes\fP, and \fIinterval\fP
used to check whether a socket is alive;
.I idle
is the number of seconds a connection needs to remain idle before TCP
starts sending keepalive probes;
.I probes
is the maximum number of keepalive probes TCP should send before dropping
the connection;
.I interval
is interval in seconds between individual keepalive probes.
Only some systems support the customization of these values;
the
.B keepalive
parameter is ignored otherwise, and system-wide settings are used.

587
588
589
590
591
592
593
594
.TP
.B tcp\-user\-timeout  <milliseconds>
If non-zero, corresponds to the
.B TCP_USER_TIMEOUT
set on the target connections, overriding the operating system setting.
Only some systems support the customization of this parameter, it is
ignored otherwise and system-wide settings are used.

595
.TP
596
597
598
.B map "{attribute|objectclass} [<local name>|*] {<foreign name>|*}"
This maps object classes and attributes as in the LDAP backend.
See
Howard Chu's avatar
Howard Chu committed
599
.BR slapd\-ldap (5).
Pierangelo Masarati's avatar
Pierangelo Masarati committed
600

601
.TP
Howard Chu's avatar
Howard Chu committed
602
.B network\-timeout <time>
603
604
605
606
607
608
Sets the network timeout value after which
.BR poll (2)/ select (2) 
following a 
.BR connect (2) 
returns in case of no activity.
The value is in seconds, and it can be specified as for
Howard Chu's avatar
Howard Chu committed
609
.BR idle\-timeout .
610
611
612
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.

613
.TP
614
615
616
617
618
619
620
621
.B nretries {forever|never|<nretries>}
This directive defines how many times a bind should be retried
in case of temporary failure in contacting a target.  If defined
before any target specification, it applies to all targets (by default,
.BR 3
times);
the global value can be overridden by redefinitions inside each target
specification.
622

623
624
625
.TP
.B rewrite* ...
The rewrite options are described in the "REWRITING" section.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
626

627
.TP
628
.B subtree\-{exclude|include} "<rule>"
629
This directive allows one to indicate what subtrees are actually served
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
by a target.
The syntax of the supported rules is

\fB<rule>: [dn[.<style>]:]<pattern>\fP

\fB<style>: subtree|children|regex\fP

When \fB<style>\fP is either \fBsubtree\fP or \fBchildren\fP
the \fB<pattern>\fP is a DN that must be within the naming context
served by the target.
When \fB<style>\fP is \fBregex\fP the \fB<pattern>\fP is a
.BR regex (5)
pattern.
If the \fBdn.<style>:\fP prefix is omitted, \fBdn.subtree:\fP
is implicitly assumed for backward compatibility.

In the
.B subtree\-exclude
form if the \fIrequest DN\fP matches at least one rule,
the target is not considered while fulfilling the request;
otherwise, the target is considered based on the value of the \fIrequest DN\fP.
When the request is a search, also the \fIscope\fP is considered.

In the
.B subtree\-include
form if the \fIrequest DN\fP matches at least one rule,
the target is considered while fulfilling the request;
otherwise the target is ignored.

.LP
.RS
.nf
    |  match  | exclude |
    +---------+---------+-------------------+
    |    T    |    T    | not candidate     |
    |    F    |    T    | continue checking |
    +---------+---------+-------------------+
    |    T    |    F    | candidate         |
    |    F    |    F    | not candidate     |
    +---------+---------+-------------------+
.fi

.RE
.RS
674
There may be multiple occurrences of the
Howard Chu's avatar
Howard Chu committed
675
.B subtree\-exclude
676
677
678
679
or
.B subtree\-include
directive for each of the targets, but they are mutually exclusive.
.RE
680

681
.TP
Pierangelo Masarati's avatar
Pierangelo Masarati committed
682
.B suffixmassage "<virtual naming context>" "<real naming context>"
683
684
685
686
687
688
689
690
All the directives starting with "rewrite" refer to the rewrite engine
that has been added to slapd.
The "suffixmassage" directive was introduced in the LDAP backend to
allow suffix massaging while proxying.
It has been obsoleted by the rewriting tools.
However, both for backward compatibility and for ease of configuration
when simple suffix massage is required, it has been preserved.
It wraps the basic rewriting instructions that perform suffix
691
692
massaging.  See the "REWRITING" section for a detailed list 
of the rewrite rules it implies.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
693

694
.TP
Howard Chu's avatar
Howard Chu committed
695
.B t\-f\-support {NO|yes|discover}
696
enable if the remote server supports absolute filters
697
(see \fIRFC 4526\fP for details).
698
699
700
701
702
703
704
If set to
.BR discover ,
support is detected by reading the remote server's root DSE.
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.

.TP
705
.B timeout [<op>=]<val> [...]
706
This directive allows one to set per-operation timeouts.
707
708
709
710
711
712
713
Operations can be

\fB<op> ::= bind, add, delete, modrdn, modify, compare, search\fP

The overall duration of the \fBsearch\fP operation is controlled either
by the \fBtimelimit\fP parameter or by server-side enforced
time limits (see \fBtimelimit\fP and \fBlimits\fP in
714
.BR slapd.conf (5)
715
716
717
718
719
720
721
722
723
724
725
726
for details).
This \fBtimeout\fP parameter controls how long the target can be 
irresponsive before the operation is aborted.
Timeout is meaningless for the remaining operations,
\fBunbind\fP and \fBabandon\fP, which do not imply any response,
while it is not yet implemented in currently supported \fBextended\fP 
operations.
If no operation is specified, the timeout \fBval\fP affects all
supported operations.
If specified before any target definition, it affects all targets
unless overridden by per-target directives.

Pierangelo Masarati's avatar
Pierangelo Masarati committed
727
Note: if the timeout is exceeded, the operation is cancelled
728
729
730
731
732
733
(according to the \fBcancel\fP directive);
the protocol does not provide any means to rollback operations,
so the client will not be notified about the result of the operation,
which may eventually succeeded or not.
In case the timeout is exceeded during a bind operation, the connection
is destroyed, according to RFC4511.
734
735

.TP
Howard Chu's avatar
Howard Chu committed
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
.B tls {none|[try\-]start|[try\-]propagate|ldaps}
.B [starttls=no]
.B [tls_cert=<file>]
.B [tls_key=<file>]
.B [tls_cacert=<file>]
.B [tls_cacertdir=<path>]
.B [tls_reqcert=never|allow|try|demand]
.B [tls_reqsan=never|allow|try|demand]
.B [tls_cipher_suite=<ciphers>]
.B [tls_ecname=<names>]
.B [tls_crlcheck=none|peer|all]
.RS
Specify TLS settings regular connections.

If the first parameter is not "none" then this configures the TLS
settings to be used for regular connections.
The StartTLS extended operation will be used when establishing the
connection unless the URI directive protocol scheme is \fBldaps://\fP.
In that case this keyword may only be set to "ldaps" and the StartTLS
operation will not be used.

Kurt Zeilenga's avatar
Kurt Zeilenga committed
757
\fBpropagate\fP issues the StartTLS operation only if the original
758
connection did.
Howard Chu's avatar
Howard Chu committed
759
The \fBtry\-\fP prefix instructs the proxy to continue operations
Kurt Zeilenga's avatar
Kurt Zeilenga committed
760
if the StartTLS operation failed; its use is highly deprecated.
Howard Chu's avatar
Howard Chu committed
761
762
763
764
765
766
767
768
769
The TLS settings default to the same as the main slapd TLS settings,
except for
.B tls_reqcert
which defaults to "demand",
.B tls_reqsan
which defaults to "allow", and
.B starttls
which is overshadowed by the first keyword and thus ignored.

770
771
If set before any target specification, it affects all targets, unless
overridden by any per-target directive.
Howard Chu's avatar
Howard Chu committed
772
.RE
773

Pierangelo Masarati's avatar
Pierangelo Masarati committed
774
.SH SCENARIOS
775
776
777
778
779
780
781
782
783
784
785
A powerful (and in some sense dangerous) rewrite engine has been added
to both the LDAP and Meta backends.
While the former can gain limited beneficial effects from rewriting
stuff, the latter can become an amazingly powerful tool.
.LP
Consider a couple of scenarios first.
.LP
1) Two directory servers share two levels of naming context;
say "dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
Then, an unambiguous Meta database can be configured as:
.LP
786
.RS
787
.nf
788
789
790
791
database meta
suffix   "\fBdc=foo,dc=com\fP"
uri      "ldap://a.foo.com/dc=a,\fBdc=foo,dc=com\fP"
uri      "ldap://b.foo.com/dc=b,\fBdc=foo,dc=com\fP"
792
.fi
793
.RE
794
795
796
797
798
799
800
801
.LP
Operations directed to a specific target can be easily resolved
because there are no ambiguities.
The only operation that may resolve to multiple targets is a search
with base "dc=foo,dc=com" and scope at least "one", which results in
spawning two searches to the targets.
.LP
2a) Two directory servers don't share any portion of naming context,
Pierangelo Masarati's avatar
Pierangelo Masarati committed
802
but they'd present as a single DIT
803
804
[Caveat: uniqueness of (massaged) entries among the two servers is
assumed; integrity checks risk to incur in excessive overhead and have
Pierangelo Masarati's avatar
Pierangelo Masarati committed
805
806
not been implemented].
Say we have "dc=bar,dc=org" and "o=Foo,c=US",
807
808
809
810
and we'd like them to appear as branches of "dc=foo,dc=com", say
"dc=a,dc=foo,dc=com" and "dc=b,dc=foo,dc=com".
Then we need to configure our Meta backend as:
.LP
811
.RS
812
.nf
813
814
815
816
817
818
819
820
database      meta
suffix        "dc=foo,dc=com"

uri           "ldap://a.bar.com/\fBdc=a,dc=foo,dc=com\fP"
suffixmassage "\fBdc=a,dc=foo,dc=com\fP" "dc=bar,dc=org"

uri           "ldap://b.foo.com/\fBdc=b,dc=foo,dc=com\fP"
suffixmassage "\fBdc=b,dc=foo,dc=com\fP" "o=Foo,c=US"
821
.fi
822
.RE
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
.LP
Again, operations can be resolved without ambiguity, although
some rewriting is required.
Notice that the virtual naming context of each target is a branch of
the database's naming context; it is rewritten back and forth when
operations are performed towards the target servers.
What "back and forth" means will be clarified later.
.LP
When a search with base "dc=foo,dc=com" is attempted, if the 
scope is "base" it fails with "no such object"; in fact, the
common root of the two targets (prior to massaging) does not
exist.
If the scope is "one", both targets are contacted with the base
replaced by each target's base; the scope is derated to "base".
In general, a scope "one" search is honored, and the scope is derated,
only when the incoming base is at most one level lower of a target's
naming context (prior to massaging).
.LP
Finally, if the scope is "sub" the incoming base is replaced
by each target's unmassaged naming context, and the scope
is not altered.
.LP
2b) Consider the above reported scenario with the two servers
sharing the same naming context:
.LP
848
.RS
849
.nf
850
851
852
853
854
855
856
857
database      meta
suffix        "\fBdc=foo,dc=com\fP"

uri           "ldap://a.bar.com/\fBdc=foo,dc=com\fP"
suffixmassage "\fBdc=foo,dc=com\fP" "dc=bar,dc=org"

uri           "ldap://b.foo.com/\fBdc=foo,dc=com\fP"
suffixmassage "\fBdc=foo,dc=com\fP" "o=Foo,c=US"
858
.fi
859
.RE
860
861
862
863
.LP
All the previous considerations hold, except that now there is
no way to unambiguously resolve a DN.
In this case, all the operations that require an unambiguous target
Pierangelo Masarati's avatar
Pierangelo Masarati committed
864
selection will fail unless the DN is already cached or a default
865
target has been set.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
866
867
Practical configurations may result as a combination of all the
above scenarios.
868
869
.SH ACLs
Note on ACLs: at present you may add whatever ACL rule you desire
870
to the Meta (and LDAP) backends.
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
However, the meaning of an ACL on a proxy may require some
considerations.
Two philosophies may be considered:
.LP
a) the remote server dictates the permissions; the proxy simply passes
back what it gets from the remote server.
.LP
b) the remote server unveils "everything"; the proxy is responsible
for protecting data from unauthorized access.
.LP
Of course the latter sounds unreasonable, but it is not.
It is possible to imagine scenarios in which a remote host discloses
data that can be considered "public" inside an intranet, and a proxy
that connects it to the internet may impose additional constraints.
To this purpose, the proxy should be able to comply with all the ACL
matching criteria that the server supports.
This has been achieved with regard to all the criteria supported by
888
889
slapd except a special subtle case (please file an ITS if you can
find other exceptions: <http://www.openldap.org/its/>).
890
891
The rule
.LP
892
.RS
893
.nf
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
894
access to dn="<dn>" attrs=<attr>
895
896
       by dnattr=<dnattr> read
       by * none
897
.fi
898
.RE
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
.LP
cannot be matched iff the attribute that is being requested, <attr>,
is NOT <dnattr>, and the attribute that determines membership,
<dnattr>, has not been requested (e.g. in a search)
.LP
In fact this ACL is resolved by slapd using the portion of entry it
retrieved from the remote server without requiring any further
intervention of the backend, so, if the <dnattr> attribute has not
been fetched, the match cannot be assessed because the attribute is
not present, not because no value matches the requirement!
.LP
Note on ACLs and attribute mapping: ACLs are applied to the mapped
attributes; for instance, if the attribute locally known as "foo" is
mapped to "bar" on a remote server, then local ACLs apply to attribute
"foo" and are totally unaware of its remote name.
The remote server will check permissions for "bar", and the local
server will possibly enforce additional restrictions to "foo".
.\"
.\" If this section is moved, also update the reference in
.\" libraries/librewrite/RATIONALE.
.\"
.SH REWRITING
A string is rewritten according to a set of rules, called a `rewrite
context'.
923
924
The rules are based on POSIX (''extended'') regular expressions (regex)
with substring matching; basic variable substitution and map resolution 
925
of substrings is allowed by specific mechanisms detailed in the following.
926
927
928
929
930
931
The behavior of pattern matching/substitution can be altered by a set
of flags.
.LP
The underlying concept is to build a lightweight rewrite module
for the slapd server (initially dedicated to the LDAP backend).
.SH Passes
Hallvard Furuseth's avatar
Hallvard Furuseth committed
932
An incoming string is matched against a set of rules.
933
934
Rules are made of a regex match pattern, a substitution pattern
and a set of actions, described by a set of flags.
935
In case of match a string rewriting is performed according to the
936
substitution pattern that allows one to refer to substrings matched in the
937
938
939
940
incoming string.
The actions, if any, are finally performed.
The substitution pattern allows map resolution of substrings.
A map is a generic object that maps a substitution pattern to a value.
941
The flags are divided in "Pattern matching Flags" and "Action Flags";
Hallvard Furuseth's avatar
Hallvard Furuseth committed
942
the former alter the regex match pattern behavior while the latter
943
alter the action that is taken after substitution.
944
945
946
947
948
949
.SH "Pattern Matching Flags"
.TP
.B `C'
honors case in matching (default is case insensitive)
.TP
.B `R'
950
use POSIX ''basic'' regular expressions (default is ''extended'')
951
952
953
954
955
956
.TP
.B `M{n}'
allow no more than
.B n
recursive passes for a specific rule; does not alter the max total count
of passes, so it can only enforce a stricter limit for a specific rule.
957
958
959
960
961
962
.SH "Action Flags"
.TP
.B `:'
apply the rule once only (default is recursive)
.TP
.B `@'
963
964
965
stop applying rules in case of match; the current rule is still applied 
recursively; combine with `:' to apply the current rule only once 
and then stop.
966
967
968
969
970
971
.TP
.B `#'
stop current operation if the rule matches, and issue an `unwilling to
perform' error.
.TP
.B `G{n}'
972
973
974
jump
.B n
rules back and forth (watch for loops!).
975
976
977
978
979
980
Note that `G{1}' is implicit in every rule.
.TP
.B `I'
ignores errors in rule; this means, in case of error, e.g. issued by a
map, the error is treated as a missed match.
The `unwilling to perform' is not overridden.
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
.TP
.B `U{n}'
uses
.B
n
as return code if the rule matches; the flag does not alter the recursive
behavior of the rule, so, to have it performed only once, it must be used 
in combination with `:', e.g.
.B `:U{16}'
returns the value `16' after exactly one execution of the rule, if the
pattern matches.
As a consequence, its behavior is equivalent to `@', with the return
code set to
.BR n ;
or, in other words, `@' is equivalent to `U{0}'.
By convention, the freely available codes are above 16 included;
the others are reserved.
998
.LP
999
The ordering of the flags can be significant.
1000
1001
For instance: `IG{2}' means ignore errors and jump two lines ahead
both in case of match and in case of error, while `G{2}I' means ignore
Pierangelo Masarati's avatar
typo    
Pierangelo Masarati committed
1002
errors, but jump two lines ahead only in case of match.
1003
1004
1005
1006
.LP
More flags (mainly Action Flags) will be added as needed.
.SH "Pattern matching:"
See
1007
1008
1009
.BR regex (7)
and/or
.BR re_format (7).
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1010
.SH "Substitution Pattern Syntax:"
1011
Everything starting with `%' requires substitution;
1012
.LP
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1013
the only obvious exception is `%%', which is left as is;
1014
.LP
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1015
the basic substitution is `%d', where `d' is a digit;
1016
0 means the whole string, while 1-9 is a submatch;
1017
.LP
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1018
a `%' followed by a `{' invokes an advanced substitution.
1019
1020
The pattern is:
.LP
1021
1022
1023
.RS
`%' `{' [ <op> ] <name> `(' <substitution> `)' `}'
.RE
1024
1025
1026
.LP
where <name> must be a legal name for the map, i.e.
.LP
1027
.RS
1028
.nf
1029
1030
<name> ::= [a-z][a-z0-9]* (case insensitive)
<op> ::= `>' `|' `&' `&&' `*' `**' `$'
1031
.fi
1032
.RE
1033
.LP
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1034
1035
and <substitution> must be a legal substitution
pattern, with no limits on the nesting level.
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
.LP
The operators are:
.TP
.B >
sub context invocation; <name> must be a legal, already defined
rewrite context name
.TP
.B |
external command invocation; <name> must refer to a legal, already
defined command name (NOT IMPL.)
.TP
.B &
variable assignment; <name> defines a variable in the running
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1049
1050
1051
1052
1053
operation structure which can be dereferenced later; operator
.B &
assigns a variable in the rewrite context scope; operator
.B &&
assigns a variable that scopes the entire session, e.g. its value
Hallvard Furuseth's avatar
Hallvard Furuseth committed
1054
can be dereferenced later by other rewrite contexts
1055
1056
1057
.TP
.B *
variable dereferencing; <name> must refer to a variable that is
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1058
1059
1060
1061
1062
1063
defined and assigned for the running operation; operator
.B *
dereferences a variable scoping the rewrite context; operator
.B **
dereferences a variable scoping the whole session, e.g. the value
is passed across rewrite contexts
1064
1065
1066
1067
.TP
.B $
parameter dereferencing; <name> must refer to an existing parameter;
the idea is to make some run-time parameters set by the system
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
available to the rewrite engine, as the client host name, the bind DN
if any, constant parameters initialized at config time, and so on;
no parameter is currently set by either 
.B back\-ldap
or
.BR back\-meta ,
but constant parameters can be defined in the configuration file
by using the
.B rewriteParam
directive.
.LP
Substitution escaping has been delegated to the `%' symbol, 
which is used instead of `\e' in string substitution patterns
because `\e' is already escaped by slapd's low level parsing routines;
1082
1083
as a consequence, regex escaping requires two `\e' symbols,
e.g. `\fB.*\e.foo\e.bar\fP' must be written as `\fB.*\e\e.foo\e\e.bar\fP'.
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1084
1085
1086
1087
.\"
.\" The symbol can be altered at will by redefining the related macro in
.\" "rewrite-int.h".
.\"
1088
1089
1090
1091
1092
1093
1094
1095
.SH "Rewrite context:"
A rewrite context is a set of rules which are applied in sequence.
The basic idea is to have an application initialize a rewrite
engine (think of Apache's mod_rewrite ...) with a set of rewrite
contexts; when string rewriting is required, one invokes the
appropriate rewrite context with the input string and obtains the
newly rewritten one if no errors occur.
.LP
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1096
1097
1098
Each basic server operation is associated to a rewrite context;
they are divided in two main groups: client \-> server and
server \-> client rewriting.
1099
.LP
Howard Chu's avatar
Howard Chu committed
1100
client \-> server:
1101
.LP
1102
.RS
1103
.nf
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
(default)            if defined and no specific context 
                     is available
bindDN               bind
searchBase           search
searchFilter         search
searchFilterAttrDN   search
compareDN            compare
compareAttrDN        compare AVA
addDN                add
addAttrDN            add AVA
modifyDN             modify
modifyAttrDN         modify AVA
modrDN               modrdn
newSuperiorDN        modrdn
deleteDN             delete
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1119
exopPasswdDN         password modify extended operation DN if proxy
1120
.fi
1121
.RE
1122
.LP
Howard Chu's avatar
Howard Chu committed
1123
server \-> client:
1124
.LP
1125
.RS
1126
.nf
1127
1128
1129
1130
1131
searchResult         search (only if defined; no default;
                     acts on DN and DN-syntax attributes 
                     of search results)
searchAttrDN         search AVA
matchedDN            all ops (only if applicable)
1132
.fi
1133
.RE
1134
1135
1136
1137
1138
1139
1140
1141
.LP
.SH "Basic configuration syntax"
.TP
.B rewriteEngine { on | off }
If `on', the requested rewriting is performed; if `off', no
rewriting takes place (an easy way to stop rewriting without
altering too much the configuration file).
.TP
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1142
.B rewriteContext <context name> "[ alias <aliased context name> ]"
1143
1144
1145
<Context name> is the name that identifies the context, i.e. the name
used by the application to refer to the set of rules it contains.
It is used also to reference sub contexts in string rewriting.
Hallvard Furuseth's avatar
Hallvard Furuseth committed
1146
A context may alias another one.
1147
1148
1149
In this case the alias context contains no rule, and any reference to
it will result in accessing the aliased one.
.TP
1150
.B rewriteRule "<regex match pattern>" "<substitution pattern>" "[ <flags> ]"
1151
Determines how a string can be rewritten if a pattern is matched.
1152
1153
1154
Examples are reported below.
.SH "Additional configuration syntax:"
.TP
1155
.B rewriteMap "<map type>" "<map name>" "[ <map attrs> ]"
1156
Allows one to define a map that transforms substring rewriting into
1157
1158
1159
1160
1161
something else.
The map is referenced inside the substitution pattern of a rule.
.TP
.B rewriteParam <param name> <param value>
Sets a value with global scope, that can be dereferenced by the
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1162
command `%{$paramName}'.
1163
.TP
1164
.B rewriteMaxPasses <number of passes> [<number of passes per rule>]
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1165
1166
Sets the maximum number of total rewriting passes that can be
performed in a single rewrite operation (to avoid loops).
1167
1168
1169
1170
1171
1172
1173
A safe default is set to 100; note that reaching this limit is still
treated as a success; recursive invocation of rules is simply 
interrupted.
The count applies to the rewriting operation as a whole, not 
to any single rule; an optional per-rule limit can be set.
This limit is overridden by setting specific per-rule limits
with the `M{n}' flag.
1174
1175
.SH "Configuration examples:"
.nf
1176
1177
# set to `off' to disable rewriting
rewriteEngine on
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1178

1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
# the rules the "suffixmassage" directive implies
rewriteEngine on
# all dataflow from client to server referring to DNs
rewriteContext default
rewriteRule "(.*)<virtualnamingcontext>$" "%1<realnamingcontext>" ":"
# empty filter rule
rewriteContext searchFilter
# all dataflow from server to client
rewriteContext searchResult
rewriteRule "(.*)<realnamingcontext>$" "%1<virtualnamingcontext>" ":"
rewriteContext searchAttrDN alias searchResult
rewriteContext matchedDN alias searchResult

1192
1193
1194
# Everything defined here goes into the `default' context.
# This rule changes the naming context of anything sent
# to `dc=home,dc=net' to `dc=OpenLDAP, dc=org'
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1195

1196
1197
rewriteRule "(.*)dc=home,[ ]?dc=net"
            "%1dc=OpenLDAP, dc=org"  ":"
1198

1199
1200
# since a pretty/normalized DN does not include spaces
# after rdn separators, e.g. `,', this rule suffices:
1201

1202
1203
rewriteRule "(.*)dc=home,dc=net"
            "%1dc=OpenLDAP,dc=org"  ":"
1204

1205
1206
1207
1208
# Start a new context (ends input of the previous one).
# This rule adds blanks between DN parts if not present.
rewriteContext  addBlanks
rewriteRule     "(.*),([^ ].*)" "%1, %2"
1209

1210
1211
1212
# This one eats blanks
rewriteContext  eatBlanks
rewriteRule     "(.*),[ ](.*)" "%1,%2"
1213

1214
1215
1216
1217
1218
# Here control goes back to the default rewrite
# context; rules are appended to the existing ones.
# anything that gets here is piped into rule `addBlanks'
rewriteContext  default
rewriteRule     ".*" "%{>addBlanks(%0)}" ":"
1219

1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
.\" # Anything with `uid=username' is looked up in
.\" # /etc/passwd for gecos (I know it's nearly useless,
.\" # but it is there just as a guideline to implementing
.\" # custom maps).
.\" # Note the `I' flag that leaves `uid=username' in place 
.\" # if `username' does not have a valid account, and the
.\" # `:' that forces the rule to be processed exactly once.
.\" rewriteContext  uid2Gecos
.\" rewriteRule     "(.*)uid=([a-z0-9]+),(.+)"
.\"                 "%1cn=%2{xpasswd},%3"      "I:"
.\" 
.\" # Finally, in a bind, if one uses a `uid=username' DN,
.\" # it is rewritten in `cn=name surname' if possible.
1233
.\" rewriteContext  bindDN
1234
1235
.\" rewriteRule     ".*" "%{>addBlanks(%{>uid2Gecos(%0)})}" ":"
.\" 
1236
# Rewrite the search base according to `default' rules.
1237
rewriteContext  searchBase alias default
1238

1239
1240
1241
1242
1243
# Search results with OpenLDAP DN are rewritten back with
# `dc=home,dc=net' naming context, with spaces eaten.
rewriteContext  searchResult
rewriteRule     "(.*[^ ]?)[ ]?dc=OpenLDAP,[ ]?dc=org"
                "%{>eatBlanks(%1)}dc=home,dc=net"    ":"
1244

1245
1246
1247
1248
1249
# Bind with email instead of full DN: we first need
# an ldap map that turns attributes into a DN (the
# argument used when invoking the map is appended to 
# the URI and acts as the filter portion)
rewriteMap ldap attr2dn "ldap://host/dc=my,dc=org?dn?sub"
1250

1251
1252
1253
1254
1255
1256
1257
# Then we need to detect DN made up of a single email,
# e.g. `mail=someone@example.com'; note that the rule
# in case of match stops rewriting; in case of error,
# it is ignored.  In case we are mapping virtual
# to real naming contexts, we also need to rewrite
# regular DNs, because the definition of a bindDn
# rewrite context overrides the default definition.
1258
rewriteContext bindDN
1259
rewriteRule "^mail=[^,]+@[^,]+$" "%{attr2dn(%0)}" ":@I"
1260

1261
1262
1263
1264
1265
1266
# This is a rather sophisticated example. It massages a
# search filter in case who performs the search has
# administrative privileges.  First we need to keep
# track of the bind DN of the incoming request, which is
# stored in a variable called `binddn' with session scope,
# and left in place to allow regular binding:
1267
rewriteContext  bindDN
1268
rewriteRule     ".+" "%{&&binddn(%0)}%0" ":"
1269

1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
# A search filter containing `uid=' is rewritten only
# if an appropriate DN is bound.
# To do this, in the first rule the bound DN is
# dereferenced, while the filter is decomposed in a
# prefix, in the value of the `uid=<arg>' AVA, and 
# in a suffix. A tag `<>' is appended to the DN. 
# If the DN refers to an entry in the `ou=admin' subtree, 
# the filter is rewritten OR-ing the `uid=<arg>' with
# `cn=<arg>'; otherwise it is left as is. This could be
# useful, for instance, to allow apache's auth_ldap-1.4
# module to authenticate users with both `uid' and
# `cn', but only if the request comes from a possible
# `cn=Web auth,ou=admin,dc=home,dc=net' user.
rewriteContext searchFilter
rewriteRule "(.*\e\e()uid=([a-z0-9_]+)(\e\e).*)"
  "%{**binddn}<>%{&prefix(%1)}%{&arg(%2)}%{&suffix(%3)}"
  ":I"
rewriteRule "[^,]+,ou=admin,dc=home,dc=net"
1288
  "%{*prefix}|(uid=%{*arg})(cn=%{*arg})%{*suffix}" ":@I"
1289
rewriteRule ".*<>" "%{*prefix}uid=%{*arg}%{*suffix}" ":"
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1290
1291
1292
1293
1294
1295
1296
1297

# This example shows how to strip unwanted DN-valued
# attribute values from a search result; the first rule
# matches DN values below "ou=People,dc=example,dc=com";
# in case of match the rewriting exits successfully.
# The second rule matches everything else and causes
# the value to be rejected.
rewriteContext searchResult
1298
rewriteRule ".*,ou=People,dc=example,dc=com" "%0" ":@"
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1299
rewriteRule ".*" "" "#"
1300
.fi
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1301
1302
1303
.SH "LDAP Proxy resolution (a possible evolution of slapd\-ldap(5)):"
In case the rewritten DN is an LDAP URI, the operation is initiated
towards the host[:port] indicated in the uri, if it does not refer
1304
1305
1306
1307
to the local server.
E.g.:
.LP
.nf
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1308
  rewriteRule '^cn=root,.*' '%0'                     'G{3}'
1309
1310
1311
  rewriteRule '^cn=[a-l].*' 'ldap://ldap1.my.org/%0' ':@'
  rewriteRule '^cn=[m-z].*' 'ldap://ldap2.my.org/%0' ':@'
  rewriteRule '.*'          'ldap://ldap3.my.org/%0' ':@'
1312
1313
1314
1315
1316
1317
.fi
.LP
(Rule 1 is simply there to illustrate the `G{n}' action; it could have
been written:
.LP
.nf
1318
  rewriteRule '^cn=root,.*' 'ldap://ldap3.my.org/%0' ':@'
1319
1320
1321
.fi
.LP
with the advantage of saving one rewrite pass ...)
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337

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

1338
1339
1340
.SH PROXY CACHE OVERLAY
The proxy cache overlay 
allows caching of LDAP search requests (queries) in a local database.
1341
See 
Howard Chu's avatar
Howard Chu committed
1342
.BR slapo\-pcache (5)
1343
for details.
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361

.SH DEPRECATED STATEMENTS
The following statements have been deprecated and should no longer be used.

.TP
.B pseudorootdn "<substitute DN in case of rootdn bind>"
Use
.B idassert\-bind
instead.

.TP
.B pseudorootpw "<substitute password in case of rootdn bind>"
Use
.B idassert\-bind
instead.



Pierangelo Masarati's avatar
Pierangelo Masarati committed
1362
.SH FILES
1363
.TP
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1364
ETCDIR/slapd.conf
1365
default slapd configuration file
Pierangelo Masarati's avatar
Pierangelo Masarati committed
1366
.SH SEE ALSO
1367
.BR slapd.conf (5),
1368
.BR slapd\-asyncmeta (5),