summaryrefslogtreecommitdiffstats
path: root/contrib/slapd-modules/variant/slapo-variant.5
blob: a48074491fa7414756a69293a28471619075712a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
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
472
.TH SLAPO-VARIANT 5 "RELEASEDATE" "OpenLDAP"
.\" Copyright 2016-2017 Symas Corp. All Rights Reserved.
.\" Copying restrictions apply.  See LICENSE.
.SH NAME
slapo\-variant \- share values between entries
.SH SYNOPSIS
olcOverlay=variant
.SH DESCRIPTION
The
.B variant
overlay to
.BR slapd (8)
allows attributes/values to be shared between several entries. In some ways
this is similar to
.BR slapo-collect (5)
with the exception that the source and target attributes can be different.
.LP
The overlay operates on configured
.B variant
entries which can have several
.B attributes
each configured to borrow values from an attribute in the
.B alternate
entry.
.LP
Two types of
.B variant
entries can be configured,
.B regular
and
.BR regex ,
where the latter are configured with a regular expression and patterns to
locate each alternate entry, with access to the variant DN and first nine
submatches captured by the regular expression.
.LP
For most purposes (see
.BR LIMITATIONS ,
especially for
.B regex
variants), the resulting entry is completely transparent to the operations
performed on it, e.g. a modify operation on the
.B variant
attribute gets transformed
into an operation on the
.B alternate
entry+attribute. As such, the usual ACL rules apply, appropriate
access to both the
.B variant
and
.B alternate
entry is checked.
.LP
As a special case,
.B Add
and
.B Delete
operations will not affect the
.B alternate
entries. Should an attempt be made to add a configured
.B variant
entry with the
.B variant
attributes already populated, the operation will be rejected with a
.B Constraint
.BR Violation .

.SH CONFIGURATION LAYOUT

The overlay has to be instantiated under a database adding an entry of
.B olcOverlay=variant
with objectClass of
.BR olcVariantConfig .

The overlay configuration subtree consists of the following levels:
.RS
.TP
.B objectClass=olcVariantConfig
Main overlay configuration. Created directly under the database
configuration entry.
.TP
.B objectClass=olcVariantVariant
Specifies a
.B regular variant
entry and must be a child of an entry with
.BR objectClass=olcVariantConfig .
There may be as many such entries as necessary provided they all specify a
different DN in the
.BR olcVariantEntry
attribute.
.TP
.B objectClass=olcVariantAttribute
Specifies a
.B regular variant
attribute together with information where the
.B alternate
attribute is stored. Must be a child of an entry with
.BR objectClass=olcVariantVariant .
There may be as many such entries as necessary provided they all specify a
different attribute in
.BR olcVariantVariantAttribute .
.TP
.B objectClass=olcVariantRegex
Specifies a
.B regex variant
entry and must be a child of an entry with
.BR objectClass=olcVariantConfig .
There may be as many such entries as necessary provided they all specify a
different DN in the
.BR olcVariantEntryRegex
attribute.
.TP
.B objectClass=olcVariantAttributePattern
Specifies a
.B regex variant
attribute together with information where the
.B alternate
attribute is stored. Must be a child of an entry with
.BR objectClass=olcVariantRegex .
There may be as many such entries as necessary provided they all specify a
different attribute in
.BR olcVariantVariantAttribute .
.RE

In the case of
.BR slapd.conf (5),
the variant definition is delimited by the keyword
.B variantDN
followed by an arbitrary number of
.B variantSpec
providing the attribute definitions following it. Each new
.B variantDN
line starts configuring a new variant.

.SH OVERLAY CONFIGURATION ENTRY

The top entry
.RB ( olcVariantConfig )
has the following options available:

.RS
.TP
.B olcVariantPassReplication: TRUE | FALSE
If set to
.BR TRUE ,
.B search
operations with the
.B SyncReplication
control will be passed unchanged so that replication can be unaffected.
Defaults to
.B FALSE
while unset. The
.BR slapd.conf (5)
equivalent is
.BR passReplication .
.RE

.SH VARIANT CONFIGURATION ENTRY

The
.B regular variant entry
configuration
.RB ( olcVariantVariant )
has the following options available:

.RS
.TP
.B olcVariantEntry: <dn>
Mandatory attribute, indicates that the named entry is to be treated as a
.B variant
entry. The
.BR slapd.conf (5)
equivalent is
.BR variantDN .
.TP
.B name: <reference>
Name of the entry for reference, usually the attribute present in the
configuration entry's RDN. There is no
.BR slapd.conf (5)
equivalent as this has no effect on the overlay operation.
.RE

Similarly, the
.B regex variant entry
configuration
.RB ( olcVariantRegex )
has these options available:

.RS
.TP
.B olcVariantRegex: <regex>
Mandatory attribute, indicates that the entries whose normalised DN matches is
to be treated as a
.B regex variant
entry. The (POSIX.2) regex can use submatches to capture parts of the DN for
later use in locating the
.B alternative
.BR entry .
The
.BR slapd.conf (5)
equivalent is
.BR variantRegex .
.TP
.B name: <reference>
Name of the entry for reference, usually the attribute present in the
configuration entry's RDN. There is no
.BR slapd.conf (5)
equivalent as this has no effect on the overlay operation.
.RE

.SH CONFIGURATION PRECEDENCE

While several
.B regex variants
can match the same entry, only one can apply at a time. The list of the
.B regular variants
is checked first. Should none match, the list of
.B regex variants
is checked in the order they have been configured using only the first one that
matches.

.SH VARIANT ATTRIBUTE CONFIGURATION ENTRY

The
.B regular variant
attribute configuration
.RB ( olcVariantAttribute )
and
.B regex variant
attribute configuration
.RB ( olcVariantAttributePattern )
have the following options available:

.RS
.TP
.B name: <reference>
Name of the attribute configuration for reference and/or documentation, if
present, usually found in the configuration entry's RDN. There is no
.BR slapd.conf (5)
equivalent as this has no effect on the overlay operation.
.TP
.B olcVariantVariantAttribute: <attr>
Mandatory attribute, indicates that the named attribute is not present in
the
.B variant
entry but is to be retrieved from the
.B alternate
entry.
.TP
.B olcVariantAlternativeAttribute: <attr>
Mandatory attribute, indicates that the values of the named attribute is to
be retrieved from the
.B alternate
entry for use as the values of the
.B variant
attribute. The syntaxes of the corresponding
.B variant
and
.B alternate
attributes have to match or the configuration will be rejected.
.TP
.B olcVariantAlternativeEntry: <dn>
Attribute mandatory for
.B regular
.BR variants ,
indicates the
.B alternate
entry to use when retrieving the attribute from.
.TP
.B olcVariantAlternativeEntryPattern: <pattern>
Attribute mandatory for
.B regex
.BR variants ,
indicates the
.B alternate
entry to use when retrieving the attribute from. Substitution patterns
.RB ( $n )
can be used to insert parts of the variant entry's DN.
.B $0
will place the entire variant DN,
.B $1
to
.B $9
can be used to place respective capture patterns from the
.B variant
entry.
.TP
.B variantSpec <attr> <attr2> <dn>
.BR slapd.conf (5)
only. The equivalent to options above, where
.B <attr>
represents the
.BR olcVariantVariantAttribute ,
.B <attr2>
represents the
.B olcVariantAlternativeAttribute
and
.B <dn>
has the same meaning as the content of
.BR olcVariantAlternativeEntry .
Has to follow a
.B variantDN
line in the overlay's configuration.
.TP
.B variantRegexSpec <attr> <attr2> <pattern>
.BR slapd.conf (5)
only. The equivalent to options above, where
.B <attr>
represents the
.BR olcVariantVariantAttribute ,
.B <attr2>
represents the
.B olcVariantAlternativeAttribute
and
.B <pattern>
has the same meaning as the content of
.BR olcVariantAlternativeEntryPattern .
Has to follow a
.B variantRegex
line in the overlay's configuration.
.RE

.SH EXAMPLE

The following is an example of a configured overlay, substitute
.B $DATABASE
for the DN of the database it is attached to and
.B {x}
with the desired position of the overlay in the overlay stack.

.nf
dn: olcOverlay={x}variant,$DATABASE
objectClass: olcVariantConfig
olcOverlay: variant
# Let replication requests pass through unmodified
olcVariantPassReplication: TRUE

# when an operation considers dc=example,dc=com
dn: name=example,olcOverlay={x}variant,$DATABASE
objectClass: olcVariantVariant
olcVariantEntry: dc=example,dc=com

# share the Headquarters' address as the company address
dn: olcVariantVariantAttribute=postaladdress,name={0}example,olcOverlay={x}variant,$DATABASE
objectClass: olcVariantVariantAttribute
olcVariantVariantAttribute: postaladdress
olcVariantAlternativeAttribute: postaladdress
olcVariantAlternativeEntry: ou=Headquarters,dc=example,dc=com

# populate telephonenumber from CEO's home phone
dn: name=Take phone from CEO entry,name={0}example,olcOverlay={x}variant,$DATABASE
objectClass: olcVariantVariantAttribute
olcVariantVariantAttribute: telephonenumber
olcVariantAlternativeAttribute: homephone
olcVariantAlternativeEntry: cn=John Doe,ou=People,dc=example,dc=com

# Match all entries with example in the DN
#
# It will not match dc=example,dc=com as that's already configured as a regular
# variant
dn: name=example 2,olcOverlay={x}variant,$DATABASE
objectClass: olcVariantRegex
olcVariantEntryRegex: .*example[^,]*,(.*)

dn: olcVariantVariantAttribute=location,name={1}example 2,olcOverlay={x}variant,$DATABASE
objectClass: olcVariantAttributePattern
olcVariantVariantAttribute: location
olcVariantAlternativeAttribute: location
olcVariantAlternativeEntryPattern: ou=object with location,$1
.fi

The
.BR slapd.conf (5)
equivalent of the above follows (note that the converted
.B cn=config
will differ in the first variant attribute configuration entry):

.nf
overlay variant
passReplication TRUE

variantDN dc=example,dc=com
variantSpec telephonenumber homephone "cn=John Doe,ou=People,dc=example,dc=com"
variantSpec postaladdress postaladdress ou=Headquarters,dc=example,dc=com

variantRegex .*example[^,]*,(.*)
variantRegexSpec location location "ou=object with location,$1"
.fi

.SH REPLICATION

There are two ways that a database with
.BR slapo-variant (5)
might be replicated, either replicating the data as stored in the database,
or as seen by the clients interacting with the server.

The former can be achieved by setting the overlay option
.B olcVariantPassReplication
on the provider and configuring
.BR slapo-syncprov (5)
to appear before (with a lower index than)
.BR slapo-variant (5).
This is the preferred way and the only to work with
.B regex variants
or support multi-provider replication,
but care must be taken to configure
.BR slapo-variant (5)
correctly on each replica.

The latter is mostly possible by keeping the option
.B olcVariantPassReplication
set to
.B FALSE
on the provider and configuring
.BR slapo-syncprov (5)
to appear after (with a higher index than)
.BR slapo-variant (5).
However, it will only really work for replication set-ups that do not
utilise
.B regex
.BR variants ,
delta-replication nor the refresh and persist mode and is therefore
discouraged.

.SH LIMITATIONS
For
.B regex
.BR variants ,
the
.B Search
operation will only apply if the search scope is set to
.BR base .

The
.B ModRDN
operation is not currently handled and will always modify only the entry in
question, not the configured
.B alternate
entry.

The
.B Modify
operation is not atomic with respect to the alternate entries. Currently,
the overlay processes the operations on the entry, sends the result message
and, if successful, starts modifying the
.B alternate
entries accordingly.
There is currently no support to indicate whether modifications to the
.B alternate
entries have been successful or whether they have finished.

The only control explicitly handled is the
.B SyncReplication
control if enabled through the
.B olcVariantPassReplication
setting, adding any controls to an operation that is handled by the overlay
might lead to unexpected behaviour and is therefore discouraged.

.SH FILES
.TP
ETCDIR/slapd.conf
default slapd configuration file
.TP
ETCDIR/slapd.d
default slapd configuration directory
.SH SEE ALSO
.BR slapd-config (5),
.BR slapd.conf (5),
.BR slapd.overlays (5),
.BR regex (7),
.BR slapd (8)
.SH ACKNOWLEDGEMENTS
This module was developed in 2016-2017 by Ondřej Kuzník for Symas Corp.