schema_prep.c 36.1 KB
Newer Older
1
2
3
/* schema_init.c - init builtin schema */
/* $OpenLDAP$ */
/*
Kurt Zeilenga's avatar
Kurt Zeilenga committed
4
 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5
6
7
8
9
10
11
12
13
14
15
16
17
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

#include "portable.h"

#include <stdio.h>

#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/socket.h>

#include "slap.h"
#include "ldap_pvt.h"
Kurt Zeilenga's avatar
Kurt Zeilenga committed
18
#include "ldap_pvt_uc.h"
19

20
21
#define OCDEBUG 0

22
23
24
25
int schema_init_done = 0;

struct slap_internal_schema slap_schema;

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
static int objectClassNormalize(
	slap_mask_t use,
	struct slap_syntax *syntax, /* NULL if in is asserted value */
	struct slap_matching_rule *mr,
	struct berval * in,
	struct berval * out )
{
	ObjectClass *oc = oc_bvfind( in );

	if( oc != NULL ) {
		ber_dupbv( out, &oc->soc_cname );
	} else {
		ber_dupbv( out, in );
	}

41
#if OCDEBUG
42
43
44
45
46
47
48
49
50
51
52
53
#ifdef NEW_LOGGING
	LDAP_LOG( CONFIG, ENTRY, 
		"< objectClassNormalize(%s, %s)\n", in->bv_val, out->bv_val, 0 );
#else
	Debug( LDAP_DEBUG_TRACE, "< objectClassNormalize(%s,%s)\n",
		in->bv_val, out->bv_val, 0 );
#endif
#endif

	return LDAP_SUCCESS;
}

54
static int
55
objectSubClassMatch(
56
	int *matchp,
Kurt Zeilenga's avatar
Kurt Zeilenga committed
57
	slap_mask_t flags,
58
59
60
61
62
	Syntax *syntax,
	MatchingRule *mr,
	struct berval *value,
	void *assertedValue )
{
63
	struct berval *a = (struct berval *) assertedValue;
Howard Chu's avatar
Howard Chu committed
64
65
	ObjectClass *oc = oc_bvfind( value );
	ObjectClass *asserted = oc_bvfind( a );
66

67
#if OCDEBUG
68
#ifdef NEW_LOGGING
Julius Enarusai's avatar
   
Julius Enarusai committed
69
	LDAP_LOG( CONFIG, ENTRY, 
70
		"> objectSubClassMatch(%s, %s)\n", value->bv_val, a->bv_val, 0 );
71
#else
72
	Debug( LDAP_DEBUG_TRACE, "> objectSubClassMatch(%s,%s)\n",
73
74
75
76
		value->bv_val, a->bv_val, 0 );
#endif
#endif

77
	if( asserted == NULL ) {
78
		if( OID_LEADCHAR( *a->bv_val ) ) {
79
80
81
82
83
84
			/* OID form, return FALSE */
			*matchp = 1;
			return LDAP_SUCCESS;
		}

		/* desc form, return undefined */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
85
		return SLAPD_COMPARE_UNDEFINED;
86
87
88
	}

	if ( oc == NULL ) {
Kurt Zeilenga's avatar
Kurt Zeilenga committed
89
90
		/* unrecognized stored value */
		return SLAPD_COMPARE_UNDEFINED;
91
92
	}

93
	if( SLAP_IS_MR_VALUE_SYNTAX_MATCH( flags ) ) {
94
95
96
97
98
		*matchp = ( asserted != oc );
	} else {
		*matchp = !is_object_subclass( asserted, oc );
	}

99
#if OCDEBUG
100
#ifdef NEW_LOGGING
Julius Enarusai's avatar
   
Julius Enarusai committed
101
	LDAP_LOG( CONFIG, ENTRY, 
102
		"< objectSubClassMatch(%s, %s) = %d\n",
Julius Enarusai's avatar
   
Julius Enarusai committed
103
		value->bv_val, a->bv_val, *matchp );
104
#else
105
	Debug( LDAP_DEBUG_TRACE, "< objectSubClassMatch(%s,%s) = %d\n",
106
		value->bv_val, a->bv_val, *matchp );
107
#endif
108
109
#endif

110
111
112
	return LDAP_SUCCESS;
}

113
114
115
116
117
118
119
120
static int objectSubClassIndexer( 
	slap_mask_t use,
	slap_mask_t mask,
	struct slap_syntax *syntax,
	struct slap_matching_rule *mr,
	struct berval *prefix,
	BerVarray values,
	BerVarray *keysp )
121
{
122
123
124
125
	int rc, noc, i;
	BerVarray ocvalues;
	
	for( noc=0; values[noc].bv_val != NULL; noc++ ) {
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
		/* just count em */;
	}

	/* over allocate */
	ocvalues = ch_malloc( sizeof( struct berval ) * (noc+16) );

	/* copy listed values (and termination) */
	for( i=0; i<noc; i++ ) {
		ObjectClass *oc = oc_bvfind( &values[i] );
		if( oc ) {
			ocvalues[i] = oc->soc_cname;
		} else {
			ocvalues[i] = values[i];
		}
#if OCDEBUG
141
142
143
#ifdef NEW_LOGGING
		LDAP_LOG( CONFIG, ENTRY, 
			"> objectSubClassIndexer(%d, %s)\n",
144
			i, ocvalues[i].bv_val, 0 );
145
146
147
#else
		Debug( LDAP_DEBUG_TRACE,
			"> objectSubClassIndexer(%d, %s)\n",
148
			i, ocvalues[i].bv_val, 0 );
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#endif
#endif
	}

	/* expand values */
	for( i=0; i<noc; i++ ) {
		int j;
		ObjectClass *oc = oc_bvfind( &values[i] );
		if( oc == NULL || oc->soc_sups == NULL ) continue;
		
		for( j=0; oc->soc_sups[j] != NULL; j++ ) {
			int found = 0;
			ObjectClass *sup = oc->soc_sups[j];
			int k;

			for( k=0; k<noc; k++ ) {

#if 0
167
#ifdef NEW_LOGGING
168
169
170
				LDAP_LOG( CONFIG, ENTRY, 
					"= objectSubClassIndexer(%d, %s, %s)\n",
					k, ocvalues[k].bv_val, sup->soc_cname.bv_val );
171
#else
172
173
174
				Debug( LDAP_DEBUG_TRACE,
					"= objectSubClassIndexer(%d, %s, %s)\n",
					k, ocvalues[k].bv_val, sup->soc_cname.bv_val );
175
176
#endif
#endif
177
178
179
180
181
				if( ber_bvcmp( &ocvalues[k], &sup->soc_cname ) == 0 ) {
					found++;
					break;
				}
			}
182

183
184
185
			if( !found ) {
				ocvalues = ch_realloc( ocvalues,
					sizeof( struct berval ) * (noc+2) );
186

187
				assert( k == noc );
188

189
190
191
192
				ocvalues[noc] = sup->soc_cname;

				assert( ocvalues[noc].bv_val );
				assert( ocvalues[noc].bv_len );
193

194
				noc++;
195

196
197
198
				ocvalues[noc].bv_len = 0;
				ocvalues[noc].bv_val = NULL;

199
#if OCDEBUG
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#ifdef NEW_LOGGING
				LDAP_LOG( CONFIG, ENTRY, 
					"< objectSubClassIndexer(%d, %d, %s)\n",
					i, k, sup->soc_cname.bv_val );
#else
				Debug( LDAP_DEBUG_TRACE,
					"< objectSubClassIndexer(%d, %d, %s)\n",
					i, k, sup->soc_cname.bv_val );
#endif
#endif
			}
		}
	}

#if 0
215
#ifdef NEW_LOGGING
Julius Enarusai's avatar
   
Julius Enarusai committed
216
	LDAP_LOG( CONFIG, ENTRY, 
217
		"< objectSubClassIndexer(%d)\n", noc, 0, 0 );
218
#else
219
220
	Debug( LDAP_DEBUG_TRACE, "< objectSubClassIndexer(%d)\n",
		noc, 0, 0 );
221
#endif
222
#endif
223

224
225
226
227
228
	rc = octetStringIndexer( use, mask, syntax, mr,
		prefix, ocvalues, keysp );

	ch_free( ocvalues );
	return rc;
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
/* Index generation function */
static int objectSubClassFilter(
	slap_mask_t use,
	slap_mask_t flags,
	Syntax *syntax,
	MatchingRule *mr,
	struct berval *prefix,
	void * assertedValue,
	BerVarray *keysp )
{
#if OCDEBUG
	struct berval *bv = (struct berval *) assertedValue;
	ObjectClass *oc = oc_bvfind( bv );
	if( oc ) {
		bv = &oc->soc_cname;
	}

#ifdef NEW_LOGGING
	LDAP_LOG( CONFIG, ENTRY, 
		"< objectSubClassFilter(%s)\n", bv->bv_val, 0, 0 );
#else
	Debug( LDAP_DEBUG_TRACE, "< objectSubClassFilter(%s)\n",
		bv->bv_val, 0, 0 );
#endif
#endif

	return octetStringFilter( use, flags, syntax, mr,
		prefix, assertedValue, keysp );
}
260

Kurt Zeilenga's avatar
Kurt Zeilenga committed
261
static ObjectClassSchemaCheckFN rootDseObjectClass;
262
263
static ObjectClassSchemaCheckFN aliasObjectClass;
static ObjectClassSchemaCheckFN referralObjectClass;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
264
static ObjectClassSchemaCheckFN subentryObjectClass;
265
static ObjectClassSchemaCheckFN dynamicObjectClass;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
266

Kurt Zeilenga's avatar
Kurt Zeilenga committed
267
static struct slap_schema_oc_map {
268
	char *ssom_name;
269
270
	char *ssom_defn;
	ObjectClassSchemaCheckFN *ssom_check;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
271
	slap_mask_t ssom_flags;
272
273
	size_t ssom_offset;
} oc_map[] = {
274
275
276
	{ "top", "( 2.5.6.0 NAME 'top' "
			"DESC 'top of the superclass chain' "
			"ABSTRACT MUST objectClass )",
Kurt Zeilenga's avatar
Kurt Zeilenga committed
277
		0, 0, offsetof(struct slap_internal_schema, si_oc_top) },
278
279
280
281
	{ "extensibleObject", "( 1.3.6.1.4.1.1466.101.120.111 "
			"NAME 'extensibleObject' "
			"DESC 'RFC2252: extensible object' "
			"SUP top AUXILIARY )",
282
283
		0, SLAP_OC_OPERATIONAL,
		offsetof(struct slap_internal_schema, si_oc_extensibleObject) },
284
285
286
287
	{ "alias", "( 2.5.6.1 NAME 'alias' "
			"DESC 'RFC2256: an alias' "
			"SUP top STRUCTURAL "
			"MUST aliasedObjectName )",
288
		aliasObjectClass, SLAP_OC_ALIAS|SLAP_OC_OPERATIONAL,
289
		offsetof(struct slap_internal_schema, si_oc_alias) },
290
291
292
	{ "referral", "( 2.16.840.1.113730.3.2.6 NAME 'referral' "
			"DESC 'namedref: named subordinate referral' "
			"SUP top STRUCTURAL MUST ref )",
293
		referralObjectClass, SLAP_OC_REFERRAL|SLAP_OC_OPERATIONAL,
294
		offsetof(struct slap_internal_schema, si_oc_referral) },
295
296
297
	{ "LDAProotDSE", "( 1.3.6.1.4.1.4203.1.4.1 "
			"NAME ( 'OpenLDAProotDSE' 'LDAProotDSE' ) "
			"DESC 'OpenLDAP Root DSE object' "
298
			"SUP top STRUCTURAL MAY cn )",
299
		rootDseObjectClass, SLAP_OC_OPERATIONAL,
Kurt Zeilenga's avatar
Kurt Zeilenga committed
300
		offsetof(struct slap_internal_schema, si_oc_rootdse) },
301
302
303
	{ "subentry", "( 2.5.20.0 NAME 'subentry' "
			"SUP top STRUCTURAL "
			"MUST ( cn $ subtreeSpecification ) )",
304
		subentryObjectClass, SLAP_OC_SUBENTRY|SLAP_OC_OPERATIONAL,
305
		offsetof(struct slap_internal_schema, si_oc_subentry) },
306
307
	{ "subschema", "( 2.5.20.1 NAME 'subschema' "
		"DESC 'RFC2252: controlling subschema (sub)entry' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
308
		"AUXILIARY "
309
310
		"MAY ( dITStructureRules $ nameForms $ ditContentRules $ "
			"objectClasses $ attributeTypes $ matchingRules $ "
311
			"matchingRuleUse ) )",
312
		subentryObjectClass, SLAP_OC_OPERATIONAL,
Kurt Zeilenga's avatar
Kurt Zeilenga committed
313
		offsetof(struct slap_internal_schema, si_oc_subschema) },
314
315
316
317
	{ "monitor", "( 1.3.6.1.4.1.4203.666.3.2 NAME 'monitor' "
		"DESC 'OpenLDAP system monitoring' "
		"STRUCTURAL "
		"MUST cn )",
318
319
		0, SLAP_OC_OPERATIONAL,
		offsetof(struct slap_internal_schema, si_oc_monitor) },
320
321
	{ "collectiveAttributeSubentry", "( 2.5.20.2 "
			"NAME 'collectiveAttributeSubentry' "
322
			"AUXILIARY )",
323
324
		subentryObjectClass,
		SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
325
		offsetof(struct slap_internal_schema, si_oc_collectiveAttributeSubentry) },
326
327
328
329
	{ "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
			"NAME 'dynamicObject' "
			"DESC 'RFC2589: Dynamic Object' "
			"SUP top AUXILIARY )",
330
		dynamicObjectClass, SLAP_OC_DYNAMICOBJECT,
331
		offsetof(struct slap_internal_schema, si_oc_dynamicObject) },
Kurt Zeilenga's avatar
Kurt Zeilenga committed
332
	{ NULL, NULL, NULL, 0, 0 }
333
334
};

335
static AttributeTypeSchemaCheckFN rootDseAttribute;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
336
static AttributeTypeSchemaCheckFN aliasAttribute;
337
static AttributeTypeSchemaCheckFN referralAttribute;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
338
static AttributeTypeSchemaCheckFN subentryAttribute;
339
static AttributeTypeSchemaCheckFN administrativeRoleAttribute;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
340
static AttributeTypeSchemaCheckFN dynamicAttribute;
341

Kurt Zeilenga's avatar
Kurt Zeilenga committed
342
static struct slap_schema_ad_map {
343
	char *ssam_name;
344
345
	char *ssam_defn;
	AttributeTypeSchemaCheckFN *ssam_check;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
346
	slap_mask_t ssam_flags;
347
348
	slap_mr_convert_func *ssam_convert;
	slap_mr_normalize_func *ssam_normalize;
349
	slap_mr_match_func *ssam_match;
350
351
	slap_mr_indexer_func *ssam_indexer;
	slap_mr_filter_func *ssam_filter;
352
353
	size_t ssam_offset;
} ad_map[] = {
354
355
356
357
	{ "objectClass", "( 2.5.4.0 NAME 'objectClass' "
			"DESC 'RFC2256: object classes of the entity' "
			"EQUALITY objectIdentifierMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
358
359
		NULL, SLAP_AT_FINAL,
		NULL, objectClassNormalize, objectSubClassMatch,
360
			objectSubClassIndexer, objectSubClassFilter,
361
		offsetof(struct slap_internal_schema, si_ad_objectClass) },
362
363

	/* user entry operational attributes */
364
365
366
367
	{ "structuralObjectClass", "( 2.5.21.9 NAME 'structuralObjectClass' "
			"DESC 'X.500(93): structural object class of entry' "
			"EQUALITY objectIdentifierMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
368
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
369
370
		NULL, 0,
		NULL, objectClassNormalize, objectSubClassMatch,
371
			objectSubClassIndexer, objectSubClassFilter,
372
		offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
373
374
375
376
377
378
	{ "createTimestamp", "( 2.5.18.1 NAME 'createTimestamp' "
			"DESC 'RFC2252: time which object was created' "
			"EQUALITY generalizedTimeMatch "
			"ORDERING generalizedTimeOrderingMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
379
380
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
381
		offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
382
383
384
385
386
387
	{ "modifyTimestamp", "( 2.5.18.2 NAME 'modifyTimestamp' "
			"DESC 'RFC2252: time which object was last modified' "
			"EQUALITY generalizedTimeMatch "
			"ORDERING generalizedTimeOrderingMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
388
389
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
390
		offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
391
392
393
394
395
	{ "creatorsName", "( 2.5.18.3 NAME 'creatorsName' "
			"DESC 'RFC2252: name of creator' "
			"EQUALITY distinguishedNameMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
396
397
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
398
399
400
401
402
403
		offsetof(struct slap_internal_schema, si_ad_creatorsName) },
	{ "modifiersName", "( 2.5.18.4 NAME 'modifiersName' "
			"DESC 'RFC2252: name of last modifier' "
			"EQUALITY distinguishedNameMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
404
405
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
406
407
408
409
410
411
		offsetof(struct slap_internal_schema, si_ad_modifiersName) },
	{ "hasSubordinates", "( 2.5.18.9 NAME 'hasSubordinates' "
			"DESC 'X.501: entry has children' "
			"EQUALITY booleanMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
412
413
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
414
		offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
415
416
417
	{ "subschemaSubentry", "( 2.5.18.10 NAME 'subschemaSubentry' "
			"DESC 'RFC2252: name of controlling subschema entry' "
			"EQUALITY distinguishedNameMatch "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
418
419
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE "
			"NO-USER-MODIFICATION USAGE directoryOperation )",
420
421
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
422
		offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
423
424
	{ "collectiveAttributeSubentries", "( 2.5.18.12 "
			"NAME 'collectiveAttributeSubentries' "
425
426
			"EQUALITY distinguishedNameMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
427
			"NO-USER-MODIFICATION USAGE directoryOperation )",
428
429
		NULL, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
430
		offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
431
432
433
434
	{ "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
			"EQUALITY objectIdentifierMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
			"USAGE directoryOperation )",
435
436
		NULL, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
437
		offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) },
438

439
440
441
442
443
	{ "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' "   
			"DESC 'LCUP/LDUP: universally unique identifier' "
			"EQUALITY octetStringMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
444
445
		NULL, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
446
447
448
449
450
451
		offsetof(struct slap_internal_schema, si_ad_entryUUID) },
	{ "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' "
			"DESC 'LCUP/LDUP: change sequence number' "
			"EQUALITY octetStringMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
452
453
		NULL, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
454
455
		offsetof(struct slap_internal_schema, si_ad_entryCSN) },

456
	/* root DSE attributes */
457
458
459
	{ "altServer", "( 1.3.6.1.4.1.1466.101.120.6 NAME 'altServer' "
			"DESC 'RFC2252: alternative servers' "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 USAGE dSAOperation )",
460
461
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
462
		offsetof(struct slap_internal_schema, si_ad_altServer) },
463
464
465
466
	{ "namingContexts", "( 1.3.6.1.4.1.1466.101.120.5 "
			"NAME 'namingContexts' "
			"DESC 'RFC2252: naming contexts' "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 USAGE dSAOperation )",
467
468
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
469
		offsetof(struct slap_internal_schema, si_ad_namingContexts) },
470
471
	{ "supportedControl", "( 1.3.6.1.4.1.1466.101.120.13 "
			"NAME 'supportedControl' "
Kurt Zeilenga's avatar
Kurt Zeilenga committed
472
473
			"DESC 'RFC2252: supported controls' "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
474
475
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
476
		offsetof(struct slap_internal_schema, si_ad_supportedControl) },
477
478
479
480
	{ "supportedExtension", "( 1.3.6.1.4.1.1466.101.120.7 "
			"NAME 'supportedExtension' "
			"DESC 'RFC2252: supported extended operations' "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
481
482
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
483
		offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
484
485
486
487
	{ "supportedLDAPVersion", "( 1.3.6.1.4.1.1466.101.120.15 "
			"NAME 'supportedLDAPVersion' "
			"DESC 'RFC2252: supported LDAP versions' "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 USAGE dSAOperation )",
488
489
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
490
		offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
491
492
493
494
	{ "supportedSASLMechanisms", "( 1.3.6.1.4.1.1466.101.120.14 "
			"NAME 'supportedSASLMechanisms' "
			"DESC 'RFC2252: supported SASL mechanisms'"
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE dSAOperation )",
495
496
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
497
		offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
498
499
500
501
502
503
	{ "supportedFeatures", "( 1.3.6.1.4.1.4203.1.3.5 "
			"NAME 'supportedFeatures' "
			"DESC 'features supported by the server' "
			"EQUALITY objectIdentifierMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
			"USAGE dSAOperation )",
504
505
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
506
		offsetof(struct slap_internal_schema, si_ad_supportedFeatures) },
507
508
509
510
511
512
513
	{ "monitorContext", "( 1.3.6.1.4.1.4203.666.1.10 "
			"NAME 'monitorContext' "
			"DESC 'monitor context' "
			"EQUALITY objectIdentifierMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
			"SINGLE-VALUE NO-USER-MODIFICATION "
			"USAGE dSAOperation )",
514
515
		rootDseAttribute, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
516
		offsetof(struct slap_internal_schema, si_ad_monitorContext) },
517
518
519
520
521
522
	{ "vendorName", "( 1.3.6.1.1.4 NAME 'vendorName' "
			"DESC 'RFC3045: name of implementation vendor' "
			"EQUALITY 1.3.6.1.4.1.1466.109.114.1 "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
			"SINGLE-VALUE NO-USER-MODIFICATION "
			"USAGE dSAOperation )",
523
524
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
525
526
527
528
529
530
531
		offsetof(struct slap_internal_schema, si_ad_vendorName) },
	{ "vendorVersion", "( 1.3.6.1.1.5 NAME 'vendorVersion' "
			"DESC 'RFC3045: version of implementation' "
			"EQUALITY 1.3.6.1.4.1.1466.109.114.1 "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
			"SINGLE-VALUE NO-USER-MODIFICATION "
			"USAGE dSAOperation )",
532
533
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
534
535
536
537
538
539
540
		offsetof(struct slap_internal_schema, si_ad_vendorVersion) },

	/* subentry attributes */
	{ "administrativeRole", "( 2.5.18.5 NAME 'administrativeRole' "
			"EQUALITY objectIdentifierMatch "
			"USAGE directoryOperation "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
541
542
		administrativeRoleAttribute, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
543
544
545
546
547
		offsetof(struct slap_internal_schema, si_ad_administrativeRole) },
	{ "subtreeSpecification", "( 2.5.18.6 NAME 'subtreeSpecification' "
			"SINGLE-VALUE "
			"USAGE directoryOperation "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )",
548
549
		subentryAttribute, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
550
		offsetof(struct slap_internal_schema, si_ad_subtreeSpecification) },
551

552
	/* subschema subentry attributes */
553
554
555
556
557
	{ "ditStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
			"DESC 'RFC2252: DIT structure rules' "
			"EQUALITY integerFirstComponentMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
			"USAGE directoryOperation ) ",
558
559
		subentryAttribute, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
560
561
562
563
564
		offsetof(struct slap_internal_schema, si_ad_ditStructureRules) },
	{ "ditContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
			"DESC 'RFC2252: DIT content rules' "
			"EQUALITY objectIdentifierFirstComponentMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
565
566
		subentryAttribute, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
567
		offsetof(struct slap_internal_schema, si_ad_ditContentRules) },
568
569
570
571
	{ "matchingRules", "( 2.5.21.4 NAME 'matchingRules' "
			"DESC 'RFC2252: matching rules' "
			"EQUALITY objectIdentifierFirstComponentMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )",
572
573
		subentryAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
574
		offsetof(struct slap_internal_schema, si_ad_matchingRules) },
575
576
577
578
	{ "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' "
			"DESC 'RFC2252: attribute types' "
			"EQUALITY objectIdentifierFirstComponentMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )",
579
580
		subentryAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
581
582
583
584
585
		offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
	{ "objectClasses", "( 2.5.21.6 NAME 'objectClasses' "
			"DESC 'RFC2252: object classes' "
			"EQUALITY objectIdentifierFirstComponentMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )",
586
587
		subentryAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
588
		offsetof(struct slap_internal_schema, si_ad_objectClasses) },
589
590
591
592
	{ "nameForms", "( 2.5.21.7 NAME 'nameForms' "
			"DESC 'RFC2252: name forms ' "
			"EQUALITY objectIdentifierFirstComponentMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.35 USAGE directoryOperation )",
593
594
		subentryAttribute, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
595
		offsetof(struct slap_internal_schema, si_ad_nameForms) },
596
	{ "matchingRuleUse", "( 2.5.21.8 NAME 'matchingRuleUse' "
597
598
599
			"DESC 'RFC2252: matching rule uses' "
			"EQUALITY objectIdentifierFirstComponentMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )",
600
601
		subentryAttribute, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
602
		offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) },
603

604
605
606
607
	{ "ldapSyntaxes", "( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' "
			"DESC 'RFC2252: LDAP syntaxes' "
			"EQUALITY objectIdentifierFirstComponentMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation )",
608
609
		subentryAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
610
611
		offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },

612
	/* knowledge information */
613
614
615
616
617
	{ "aliasedObjectName", "( 2.5.4.1 "
			"NAME ( 'aliasedObjectName' 'aliasedEntryName' ) "
			"DESC 'RFC2256: name of aliased object' "
			"EQUALITY distinguishedNameMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )",
618
619
		aliasAttribute, SLAP_AT_FINAL,
		NULL, NULL, NULL, NULL, NULL,
620
		offsetof(struct slap_internal_schema, si_ad_aliasedObjectName) },
621
622
623
624
625
	{ "ref", "( 2.16.840.1.113730.3.1.34 NAME 'ref' "
			"DESC 'namedref: subordinate referral URL' "
			"EQUALITY caseExactMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
			"USAGE distributedOperation )",
626
627
		referralAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
628
629
		offsetof(struct slap_internal_schema, si_ad_ref) },

Kurt Zeilenga's avatar
Kurt Zeilenga committed
630
	/* access control internals */
631
632
633
634
635
	{ "entry", "( 1.3.6.1.4.1.4203.1.3.1 "
			"NAME 'entry' "
			"DESC 'OpenLDAP ACL entry pseudo-attribute' "
			"SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
636
637
		NULL, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
638
		offsetof(struct slap_internal_schema, si_ad_entry) },
639
640
641
642
643
	{ "children", "( 1.3.6.1.4.1.4203.1.3.2 "
			"NAME 'children' "
			"DESC 'OpenLDAP ACL children pseudo-attribute' "
			"SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
			"SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
644
645
		NULL, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
646
		offsetof(struct slap_internal_schema, si_ad_children) },
647
	{ "saslAuthzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
648
649
650
651
			"NAME 'saslAuthzTo' "
			"DESC 'SASL proxy authorization targets' "
			"EQUALITY caseExactMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
652
			"USAGE distributedOperation )",
653
654
		NULL, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
655
		offsetof(struct slap_internal_schema, si_ad_saslAuthzTo) },
656
	{ "saslAuthzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
657
658
659
660
			"NAME 'saslAuthzFrom' "
			"DESC 'SASL proxy authorization sources' "
			"EQUALITY caseExactMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
661
			"USAGE distributedOperation )",
662
663
		NULL, SLAP_AT_HIDE,
		NULL, NULL, NULL, NULL, NULL,
664
		offsetof(struct slap_internal_schema, si_ad_saslAuthzFrom) },
665
#ifdef SLAPD_ACI_ENABLED
666
667
668
669
670
671
	{ "OpenLDAPaci", "( 1.3.6.1.4.1.4203.666.1.5 "
			"NAME 'OpenLDAPaci' "
			"DESC 'OpenLDAP access control information (experimental)' "
			"EQUALITY OpenLDAPaciMatch "
			"SYNTAX 1.3.6.1.4.1.4203.666.2.1 "
			"USAGE directoryOperation )",
672
673
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
674
675
		offsetof(struct slap_internal_schema, si_ad_aci) },
#endif
676

677
678
679
680
	{ "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
			"DESC 'RFC2589: entry time-to-live' "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
			"NO-USER-MODIFICATION USAGE dSAOperation )",
681
682
		dynamicAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
683
684
685
686
687
688
		offsetof(struct slap_internal_schema, si_ad_entryTtl) },
	{ "dynamicSubtrees", "( 1.3.6.1.4.1.1466.101.119.4 "
			"NAME 'dynamicSubtrees' "
			"DESC 'RFC2589: dynamic subtrees' "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MODIFICATION "
			"USAGE dSAOperation )",
689
690
		rootDseAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
691
692
		offsetof(struct slap_internal_schema, si_ad_dynamicSubtrees) },

693
	/* userApplication attributes (which system schema depends upon) */
694
695
696
697
	{ "distinguishedName", "( 2.5.4.49 NAME 'distinguishedName' "
			"DESC 'RFC2256: common supertype of DN attributes' "
			"EQUALITY distinguishedNameMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
698
699
		NULL, SLAP_AT_ABSTRACT,
		NULL, NULL, NULL, NULL, NULL,
700
		offsetof(struct slap_internal_schema, si_ad_distinguishedName) },
701
702
703
704
705
	{ "name", "( 2.5.4.41 NAME 'name' "
			"DESC 'RFC2256: common supertype of name attributes' "
			"EQUALITY caseIgnoreMatch "
			"SUBSTR caseIgnoreSubstringsMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )",
706
707
		NULL, SLAP_AT_ABSTRACT,
		NULL, NULL, NULL, NULL, NULL,
708
709
710
711
		offsetof(struct slap_internal_schema, si_ad_name) },
	{ "cn", "( 2.5.4.3 NAME ( 'cn' 'commonName' ) "
			"DESC 'RFC2256: common name(s) for which the entity is known by' "
			"SUP name )",
712
713
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
714
715
716
717
718
		offsetof(struct slap_internal_schema, si_ad_cn) },
	{ "userPassword", "( 2.5.4.35 NAME 'userPassword' "
			"DESC 'RFC2256/2307: password of user' "
			"EQUALITY octetStringMatch "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )",
719
720
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
721
		offsetof(struct slap_internal_schema, si_ad_userPassword) },
722
723

#ifdef SLAPD_AUTHPASSWD
724
725
726
727
728
	{ "authPassword", "( 1.3.6.1.4.1.4203.1.3.4 "
			"NAME 'authPassword' "
			"DESC 'RFC3112: authentication password attribute' "
			"EQUALITY 1.3.6.1.4.1.4203.1.2.2 "
			"SYNTAX 1.3.6.1.4.1.4203.1.1.2 )",
729
		NULL, 0,
730
		NULL, NULL, NULL, NULL, NULL,
731
732
733
734
735
736
737
		offsetof(struct slap_internal_schema, si_ad_authPassword) },
	{ "supportedAuthPasswordSchemes", "( 1.3.6.1.4.1.4203.1.3.3 "
			"NAME 'supportedAuthPasswordSchemes' "
			"DESC 'RFC3112: supported authPassword schemes' "
			"EQUALITY caseExactIA5Match "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} "
			"USAGE dSAOperation )",
738
739
		subschemaAttribute, 0,
		NULL, NULL, NULL, NULL, NULL,
740
		offsetof(struct slap_internal_schema, si_ad_authPassword) },
741
#endif
742
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
743
744
745
746
747
748
	{ "krbName", "( 1.3.6.1.4.1.250.1.32 "
			"NAME ( 'krbName' 'kerberosName' ) "
			"DESC 'Kerberos principal associated with object' "
			"EQUALITY caseIgnoreIA5Match "
			"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 "
			"SINGLE-VALUE )",
749
750
		NULL, 0,
		NULL, NULL, NULL, NULL, NULL,
751
752
753
		offsetof(struct slap_internal_schema, si_ad_krbName) },
#endif

Kurt Zeilenga's avatar
Kurt Zeilenga committed
754
	{ NULL, NULL, NULL, 0, NULL, NULL, NULL, 0 }
755
756
};

757
758
759
static AttributeType slap_at_undefined = {
	{ "1.1.1", NULL, NULL, 1, NULL,
		NULL, NULL, NULL, NULL,
760
		0, 0, 0, 1, 3 }, /* LDAPAttributeType */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
761
	{ sizeof("UNDEFINED")-1, "UNDEFINED" }, /* cname */
762
763
764
765
	NULL, /* sup */
	NULL, /* subtypes */
	NULL, NULL, NULL, NULL,	/* matching rules */
	NULL, /* syntax (this may need to be defined) */
766
767
	(AttributeTypeSchemaCheckFN *) 0, /* schema check function */
	SLAP_AT_ABSTRACT|SLAP_AT_FINAL,	/* mask */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
768
769
	NULL, /* next */
	NULL /* attribute description */
770
	/* mutex (don't know how to initialize it :) */
771
};
772

Kurt Zeilenga's avatar
Kurt Zeilenga committed
773
static struct slap_schema_mr_map {
774
775
776
777
778
779
780
781
782
783
	char *ssmm_name;
	size_t ssmm_offset;
} mr_map[] = {
	{ "distinguishedNameMatch",
		offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) },
	{ "integerMatch",
		offsetof(struct slap_internal_schema, si_mr_integerMatch) },
	{ NULL, 0 }
};

Kurt Zeilenga's avatar
Kurt Zeilenga committed
784
static struct slap_schema_syn_map {
785
786
787
	char *sssm_name;
	size_t sssm_offset;
} syn_map[] = {
788
789
	{ "1.3.6.1.4.1.1466.115.121.1.40",
		offsetof(struct slap_internal_schema, si_syn_octetString) },
790
791
792
793
794
795
796
	{ "1.3.6.1.4.1.1466.115.121.1.12",
		offsetof(struct slap_internal_schema, si_syn_distinguishedName) },
	{ "1.3.6.1.4.1.1466.115.121.1.27",
		offsetof(struct slap_internal_schema, si_syn_integer) },
	{ NULL, 0 }
};

797
int
798
799
slap_schema_load( void )
{
800
	int i;
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833

	for( i=0; syn_map[i].sssm_name; i++ ) {
		Syntax ** synp = (Syntax **)
			&(((char *) &slap_schema)[syn_map[i].sssm_offset]);

		assert( *synp == NULL );

		*synp = syn_find( syn_map[i].sssm_name );

		if( *synp == NULL ) {
			fprintf( stderr, "slap_schema_check: "
				"No syntax \"%s\" defined in schema\n",
				syn_map[i].sssm_name );
			return LDAP_INVALID_SYNTAX;
		}
	}

	for( i=0; mr_map[i].ssmm_name; i++ ) {
		MatchingRule ** mrp = (MatchingRule **)
			&(((char *) &slap_schema)[mr_map[i].ssmm_offset]);

		assert( *mrp == NULL );

		*mrp = mr_find( mr_map[i].ssmm_name );

		if( *mrp == NULL ) {
			fprintf( stderr, "slap_schema_check: "
				"No matching rule \"%s\" defined in schema\n",
				mr_map[i].ssmm_name );
			return LDAP_INAPPROPRIATE_MATCHING;
		}
	}

834
	for( i=0; ad_map[i].ssam_name; i++ ) {
835
836
		assert( ad_map[i].ssam_defn != NULL );
		{
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
			LDAPAttributeType *at;
			int		code;
			const char	*err;

			at = ldap_str2attributetype( ad_map[i].ssam_defn,
				&code, &err, LDAP_SCHEMA_ALLOW_ALL );
			if ( !at ) {
				fprintf( stderr,
					"slap_schema_load: %s: %s before %s\n",
					 ad_map[i].ssam_name, ldap_scherr2str(code), err );
				return code;
			}

			if ( at->at_oid == NULL ) {
				fprintf( stderr, "slap_schema_load: "
					"attributeType \"%s\" has no OID\n",
					ad_map[i].ssam_name );
				return LDAP_OTHER;
			}

			code = at_add( at, &err );
			if ( code ) {
				fprintf( stderr, "slap_schema_load: "
					"%s: %s: \"%s\"\n",
					 ad_map[i].ssam_name, scherr2str(code), err );
				return code;
			}
			ldap_memfree( at );
		}
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
		{
			int rc;
			const char *text;

			AttributeDescription ** adp = (AttributeDescription **)
				&(((char *) &slap_schema)[ad_map[i].ssam_offset]);

			assert( *adp == NULL );

			rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
			if( rc != LDAP_SUCCESS ) {
				fprintf( stderr, "slap_schema_check: "
					"No attribute \"%s\" defined in schema\n",
					ad_map[i].ssam_name );
				return rc;
			}

			if( ad_map[i].ssam_check ) {
				/* install check routine */
				(*adp)->ad_type->sat_check = ad_map[i].ssam_check;
			}
			/* install flags */
			(*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags;

890
			/* install custom rule routine */
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
			if( ad_map[i].ssam_convert ||
				ad_map[i].ssam_normalize ||
				ad_map[i].ssam_match ||
				ad_map[i].ssam_indexer ||
				ad_map[i].ssam_filter )
			{
				MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
				*mr = *(*adp)->ad_type->sat_equality;
				(*adp)->ad_type->sat_equality = mr;
				
				if( ad_map[i].ssam_convert ) {
					mr->smr_convert = ad_map[i].ssam_convert;
				}
				if( ad_map[i].ssam_normalize ) {
					mr->smr_normalize = ad_map[i].ssam_normalize;
				}
				if( ad_map[i].ssam_match ) {
					mr->smr_match = ad_map[i].ssam_match;
				}
				if( ad_map[i].ssam_indexer ) {
					mr->smr_indexer = ad_map[i].ssam_indexer;
				}
				if( ad_map[i].ssam_filter ) {
					mr->smr_filter = ad_map[i].ssam_filter;
				}
916
917
			}
		}
918
	}
919
920

	for( i=0; oc_map[i].ssom_name; i++ ) {
921
922
		assert( oc_map[i].ssom_defn != NULL );
		{
Kurt Zeilenga's avatar
Kurt Zeilenga committed
923
924
925
			LDAPObjectClass *oc;
			int		code;
			const char	*err;
926

Kurt Zeilenga's avatar
Kurt Zeilenga committed
927
928
929
930
931
932
933
934
			oc = ldap_str2objectclass( oc_map[i].ssom_defn, &code, &err,
				LDAP_SCHEMA_ALLOW_ALL );
			if ( !oc ) {
				fprintf( stderr, "slap_schema_load: "
					"%s: %s before %s\n",
				 	oc_map[i].ssom_name, ldap_scherr2str(code), err );
				return code;
			}
935

Kurt Zeilenga's avatar
Kurt Zeilenga committed
936
937
938
939
940
941
			if ( oc->oc_oid == NULL ) {
				fprintf( stderr, "slap_schema_load: "
					"%s: objectclass has no OID\n",
					oc_map[i].ssom_name );
				return LDAP_OTHER;
			}
942

943
			code = oc_add(oc,0,&err);
Kurt Zeilenga's avatar
Kurt Zeilenga committed
944
945
946
947
948
949
950
951
952
			if ( code ) {
				fprintf( stderr, "slap_schema_load: "
					"%s: %s: \"%s\"\n",
				 	oc_map[i].ssom_name, scherr2str(code), err);
				return code;
			}

			ldap_memfree(oc);
		}
953
954
955
		{
			ObjectClass ** ocp = (ObjectClass **)
				&(((char *) &slap_schema)[oc_map[i].ssom_offset]);
956

957
			assert( *ocp == NULL );
958

959
960
961
962
963
964
965
			*ocp = oc_find( oc_map[i].ssom_name );
			if( *ocp == NULL ) {
				fprintf( stderr, "slap_schema_check: "
					"No objectClass \"%s\" defined in schema\n",
					oc_map[i].ssom_name );
				return LDAP_OBJECT_CLASS_VIOLATION;
			}
966

967
968
969
970
971
972
			if( oc_map[i].ssom_check ) {
				/* install check routine */
				(*ocp)->soc_check = oc_map[i].ssom_check;
			}
			/* install flags */
			(*ocp)->soc_flags |= oc_map[i].ssom_flags;
973
974
975
		}
	}

976
	slap_at_undefined.sat_syntax = slap_schema.si_syn_distinguishedName;
977
978
	slap_schema.si_at_undefined = &slap_at_undefined;

979
980
	return LDAP_SUCCESS;
}
Kurt Zeilenga's avatar
Kurt Zeilenga committed
981

982
983
984
985
986
int
slap_schema_check( void )
{
	/* we should only be called once after schema_init() was called */
	assert( schema_init_done == 1 );
987

988
989
990
	++schema_init_done;
	return LDAP_SUCCESS;
}
991

Kurt Zeilenga's avatar
Kurt Zeilenga committed
992
static int rootDseObjectClass (
993
	Backend *be,
Kurt Zeilenga's avatar
Kurt Zeilenga committed
994
995
996
997
998
999
	Entry *e,
	ObjectClass *oc,
	const char** text,
	char *textbuf, size_t textlen )
{
	*text = textbuf;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1000

For faster browsing, not all history is shown. View entire blame