1 /* schema_init.c - init builtin schema */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
18 #include "ldap_pvt_uc.h"
20 int schema_init_done = 0;
22 struct slap_internal_schema slap_schema;
33 struct berval *a = (struct berval *) assertedValue;
34 ObjectClass *oc = oc_bvfind( value );
35 ObjectClass *asserted = oc_bvfind( a );
37 if( asserted == NULL ) {
38 if( OID_LEADCHAR( *a->bv_val ) ) {
39 /* OID form, return FALSE */
44 /* desc form, return undefined */
45 return SLAPD_COMPARE_UNDEFINED;
49 /* unrecognized stored value */
50 return SLAPD_COMPARE_UNDEFINED;
53 if( SLAP_IS_MR_VALUE_SYNTAX_MATCH( flags ) ) {
54 *matchp = ( asserted != oc );
56 *matchp = !is_object_subclass( asserted, oc );
61 LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
62 "objectClassMatch(%s, %s) = %d\n",
63 value->bv_val, a->bv_val, *matchp ));
65 Debug( LDAP_DEBUG_TRACE, "objectClassMatch(%s,%s) = %d\n",
66 value->bv_val, a->bv_val, *matchp );
74 structuralObjectClassMatch(
82 struct berval *a = (struct berval *) assertedValue;
83 ObjectClass *oc = oc_bvfind( value );
84 ObjectClass *asserted = oc_bvfind( a );
86 if( asserted == NULL ) {
87 if( OID_LEADCHAR( *a->bv_val ) ) {
88 /* OID form, return FALSE */
93 /* desc form, return undefined */
94 return SLAPD_COMPARE_UNDEFINED;
98 /* unrecognized stored value */
99 return SLAPD_COMPARE_UNDEFINED;
102 *matchp = ( asserted != oc );
106 LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
107 "structuralObjectClassMatch( %s, %s ) = %d\n",
108 value->bv_val, a->bv_val, *matchp ));
110 Debug( LDAP_DEBUG_TRACE, "structuralObjectClassMatch(%s,%s) = %d\n",
111 value->bv_val, a->bv_val, *matchp );
118 static ObjectClassSchemaCheckFN rootDseObjectClass;
119 static ObjectClassSchemaCheckFN subentryObjectClass;
121 static struct slap_schema_oc_map {
124 ObjectClassSchemaCheckFN *ssom_check;
127 { "top", "( 2.5.6.0 NAME 'top' "
128 "DESC 'top of the superclass chain' "
129 "ABSTRACT MUST objectClass )",
130 0, offsetof(struct slap_internal_schema, si_oc_top) },
131 { "extensibleObject", "( 1.3.6.1.4.1.1466.101.120.111 "
132 "NAME 'extensibleObject' "
133 "DESC 'RFC2252: extensible object' "
134 "SUP top AUXILIARY )",
135 0, offsetof(struct slap_internal_schema, si_oc_extensibleObject) },
136 { "alias", "( 2.5.6.1 NAME 'alias' "
137 "DESC 'RFC2256: an alias' "
138 "SUP top STRUCTURAL "
139 "MUST aliasedObjectName )",
140 0, offsetof(struct slap_internal_schema, si_oc_alias) },
141 { "referral", "( 2.16.840.1.113730.3.2.6 NAME 'referral' "
142 "DESC 'namedref: named subordinate referral' "
143 "SUP top STRUCTURAL MUST ref )",
144 0, offsetof(struct slap_internal_schema, si_oc_referral) },
145 { "LDAProotDSE", "( 1.3.6.1.4.1.4203.1.4.1 "
146 "NAME ( 'OpenLDAProotDSE' 'LDAProotDSE' ) "
147 "DESC 'OpenLDAP Root DSE object' "
148 "SUP top STRUCTURAL MAY cn )", rootDseObjectClass,
149 offsetof(struct slap_internal_schema, si_oc_rootdse) },
150 { "subentry", "( 2.5.20.0 NAME 'subentry' "
151 "SUP top STRUCTURAL "
152 "MUST ( cn $ subtreeSpecification ) )",
153 0, offsetof(struct slap_internal_schema, si_oc_subentry) },
154 { "subschema", "( 2.5.20.1 NAME 'subschema' "
155 "DESC 'RFC2252: controlling subschema (sub)entry' "
157 "MAY ( dITStructureRules $ nameForms $ ditContentRules $ "
158 "objectClasses $ attributeTypes $ matchingRules $ "
159 "matchingRuleUse ) )", subentryObjectClass,
160 offsetof(struct slap_internal_schema, si_oc_subschema) },
161 { "collectiveAttributes", "( 2.5.20.2 "
162 "NAME 'collectiveAttributes' "
163 "AUXILIARY )", subentryObjectClass,
164 offsetof(struct slap_internal_schema, si_oc_collectiveAttributes) },
168 static AttributeTypeSchemaCheckFN rootDseAttribute;
169 static AttributeTypeSchemaCheckFN subentryAttribute;
170 static AttributeTypeSchemaCheckFN referralAttribute;
172 static struct slap_schema_ad_map {
175 AttributeTypeSchemaCheckFN *ssam_check;
176 slap_mr_match_func *ssam_match;
177 slap_mr_indexer_func *ssam_indexer;
178 slap_mr_filter_func *ssam_filter;
181 { "objectClass", "( 2.5.4.0 NAME 'objectClass' "
182 "DESC 'RFC2256: object classes of the entity' "
183 "EQUALITY objectIdentifierMatch "
184 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
186 objectClassMatch, NULL, NULL,
187 offsetof(struct slap_internal_schema, si_ad_objectClass) },
189 /* user entry operational attributes */
190 { "structuralObjectClass", "( 2.5.21.9 NAME 'structuralObjectClass' "
191 "DESC 'X.500(93): structural object class of entry' "
192 "EQUALITY objectIdentifierMatch "
193 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
194 "NO-USER-MODIFICATION SINGLE-VALUE USAGE directoryOperation )",
196 structuralObjectClassMatch, NULL, NULL,
197 offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
198 { "createTimestamp", "( 2.5.18.1 NAME 'createTimestamp' "
199 "DESC 'RFC2252: time which object was created' "
200 "EQUALITY generalizedTimeMatch "
201 "ORDERING generalizedTimeOrderingMatch "
202 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
203 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
204 NULL, NULL, NULL, NULL,
205 offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
206 { "modifyTimestamp", "( 2.5.18.2 NAME 'modifyTimestamp' "
207 "DESC 'RFC2252: time which object was last modified' "
208 "EQUALITY generalizedTimeMatch "
209 "ORDERING generalizedTimeOrderingMatch "
210 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
211 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
212 NULL, NULL, NULL, NULL,
213 offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
214 { "creatorsName", "( 2.5.18.3 NAME 'creatorsName' "
215 "DESC 'RFC2252: name of creator' "
216 "EQUALITY distinguishedNameMatch "
217 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
218 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
219 NULL, NULL, NULL, NULL,
220 offsetof(struct slap_internal_schema, si_ad_creatorsName) },
221 { "modifiersName", "( 2.5.18.4 NAME 'modifiersName' "
222 "DESC 'RFC2252: name of last modifier' "
223 "EQUALITY distinguishedNameMatch "
224 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
225 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
226 NULL, NULL, NULL, NULL,
227 offsetof(struct slap_internal_schema, si_ad_modifiersName) },
228 { "hasSubordinates", "( 2.5.18.9 NAME 'hasSubordinates' "
229 "DESC 'X.501: entry has children' "
230 "EQUALITY booleanMatch "
231 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
232 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
233 NULL, NULL, NULL, NULL,
234 offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
235 { "subschemaSubentry", "( 2.5.18.10 NAME 'subschemaSubentry' "
236 "DESC 'RFC2252: name of controlling subschema entry' "
237 "EQUALITY distinguishedNameMatch "
238 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MODIFICATION "
239 "SINGLE-VALUE USAGE directoryOperation )",
240 NULL, NULL, NULL, NULL,
241 offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
242 { "collectiveAttributeSubentry", "( 2.5.18.12 "
243 "NAME 'collectiveAttributeSubentry' "
244 "EQUALITY distinguishedNameMatch "
245 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
246 "USAGE directoryOperation NO-USER-MODIFICATION )",
247 NULL, NULL, NULL, NULL,
248 offsetof(struct slap_internal_schema, si_ad_collectiveSubentry) },
249 { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
250 "EQUALITY objectIdentifierMatch "
251 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
252 "USAGE directoryOperation )",
253 NULL, NULL, NULL, NULL,
254 offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) },
256 { "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' "
257 "DESC 'LCUP/LDUP: universally unique identifier' "
258 "EQUALITY octetStringMatch "
259 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
260 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
261 NULL, NULL, NULL, NULL,
262 offsetof(struct slap_internal_schema, si_ad_entryUUID) },
263 { "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' "
264 "DESC 'LCUP/LDUP: change sequence number' "
265 "EQUALITY octetStringMatch "
266 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
267 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
268 NULL, NULL, NULL, NULL,
269 offsetof(struct slap_internal_schema, si_ad_entryCSN) },
271 /* root DSE attributes */
272 { "altServer", "( 1.3.6.1.4.1.1466.101.120.6 NAME 'altServer' "
273 "DESC 'RFC2252: alternative servers' "
274 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 USAGE dSAOperation )",
275 rootDseAttribute, NULL, NULL, NULL,
276 offsetof(struct slap_internal_schema, si_ad_altServer) },
277 { "namingContexts", "( 1.3.6.1.4.1.1466.101.120.5 "
278 "NAME 'namingContexts' "
279 "DESC 'RFC2252: naming contexts' "
280 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 USAGE dSAOperation )",
281 rootDseAttribute, NULL, NULL, NULL,
282 offsetof(struct slap_internal_schema, si_ad_namingContexts) },
283 { "supportedControl", "( 1.3.6.1.4.1.1466.101.120.13 "
284 "NAME 'supportedControl' "
285 "DESC 'RFC2252: supported controls' "
286 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
287 rootDseAttribute, NULL, NULL, NULL,
288 offsetof(struct slap_internal_schema, si_ad_supportedControl) },
289 { "supportedExtension", "( 1.3.6.1.4.1.1466.101.120.7 "
290 "NAME 'supportedExtension' "
291 "DESC 'RFC2252: supported extended operations' "
292 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
293 rootDseAttribute, NULL, NULL, NULL,
294 offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
295 { "supportedLDAPVersion", "( 1.3.6.1.4.1.1466.101.120.15 "
296 "NAME 'supportedLDAPVersion' "
297 "DESC 'RFC2252: supported LDAP versions' "
298 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 USAGE dSAOperation )",
299 rootDseAttribute, NULL, NULL, NULL,
300 offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
301 { "supportedSASLMechanisms", "( 1.3.6.1.4.1.1466.101.120.14 "
302 "NAME 'supportedSASLMechanisms' "
303 "DESC 'RFC2252: supported SASL mechanisms'"
304 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE dSAOperation )",
305 rootDseAttribute, NULL, NULL, NULL,
306 offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
307 { "supportedFeatures", "( 1.3.6.1.4.1.4203.1.3.5 "
308 "NAME 'supportedFeatures' "
309 "DESC 'features supported by the server' "
310 "EQUALITY objectIdentifierMatch "
311 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
312 "USAGE dSAOperation )",
313 rootDseAttribute, NULL, NULL, NULL,
314 offsetof(struct slap_internal_schema, si_ad_supportedFeatures) },
315 { "vendorName", "( 1.3.6.1.1.4 NAME 'vendorName' "
316 "DESC 'RFC3045: name of implementation vendor' "
317 "EQUALITY 1.3.6.1.4.1.1466.109.114.1 "
318 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
319 "SINGLE-VALUE NO-USER-MODIFICATION "
320 "USAGE dSAOperation )",
321 rootDseAttribute, NULL, NULL, NULL,
322 offsetof(struct slap_internal_schema, si_ad_vendorName) },
323 { "vendorVersion", "( 1.3.6.1.1.5 NAME 'vendorVersion' "
324 "DESC 'RFC3045: version of implementation' "
325 "EQUALITY 1.3.6.1.4.1.1466.109.114.1 "
326 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
327 "SINGLE-VALUE NO-USER-MODIFICATION "
328 "USAGE dSAOperation )",
329 rootDseAttribute, NULL, NULL, NULL,
330 offsetof(struct slap_internal_schema, si_ad_vendorVersion) },
332 /* subentry attributes */
333 { "administrativeRole", "( 2.5.18.5 NAME 'administrativeRole' "
334 "EQUALITY objectIdentifierMatch "
335 "USAGE directoryOperation "
336 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
337 NULL, NULL, NULL, NULL,
338 offsetof(struct slap_internal_schema, si_ad_administrativeRole) },
339 { "subtreeSpecification", "( 2.5.18.6 NAME 'subtreeSpecification' "
341 "USAGE directoryOperation "
342 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )",
343 subentryAttribute, NULL, NULL, NULL,
344 offsetof(struct slap_internal_schema, si_ad_subtreeSpecification) },
346 /* subschema subentry attributes */
347 { "ditStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
348 "DESC 'RFC2252: DIT structure rules' "
349 "EQUALITY integerFirstComponentMatch "
350 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
351 "USAGE directoryOperation ) ",
352 subentryAttribute, NULL, NULL, NULL,
353 offsetof(struct slap_internal_schema, si_ad_ditStructureRules) },
354 { "ditContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
355 "DESC 'RFC2252: DIT content rules' "
356 "EQUALITY objectIdentifierFirstComponentMatch "
357 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
358 subentryAttribute, NULL, NULL, NULL,
359 offsetof(struct slap_internal_schema, si_ad_ditContentRules) },
360 { "matchingRules", "( 2.5.21.4 NAME 'matchingRules' "
361 "DESC 'RFC2252: matching rules' "
362 "EQUALITY objectIdentifierFirstComponentMatch "
363 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )",
364 subentryAttribute, NULL, NULL, NULL,
365 offsetof(struct slap_internal_schema, si_ad_matchingRules) },
366 { "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' "
367 "DESC 'RFC2252: attribute types' "
368 "EQUALITY objectIdentifierFirstComponentMatch "
369 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )",
370 subentryAttribute, NULL, NULL, NULL,
371 offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
372 { "objectClasses", "( 2.5.21.6 NAME 'objectClasses' "
373 "DESC 'RFC2252: object classes' "
374 "EQUALITY objectIdentifierFirstComponentMatch "
375 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )",
376 subentryAttribute, NULL, NULL, NULL,
377 offsetof(struct slap_internal_schema, si_ad_objectClasses) },
378 { "nameForms", "( 2.5.21.7 NAME 'nameForms' "
379 "DESC 'RFC2252: name forms ' "
380 "EQUALITY objectIdentifierFirstComponentMatch "
381 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.35 USAGE directoryOperation )",
382 subentryAttribute, NULL, NULL, NULL,
383 offsetof(struct slap_internal_schema, si_ad_nameForms) },
384 { "matchingRuleUse", "( 2.5.21.8 NAME 'matchingRuleUse' "
385 "DESC 'RFC2252: matching rule uses' "
386 "EQUALITY objectIdentifierFirstComponentMatch "
387 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )",
388 subentryAttribute, NULL, NULL, NULL,
389 offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) },
391 { "ldapSyntaxes", "( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' "
392 "DESC 'RFC2252: LDAP syntaxes' "
393 "EQUALITY objectIdentifierFirstComponentMatch "
394 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation )",
395 subentryAttribute, NULL, NULL, NULL,
396 offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
398 /* knowledge information */
399 { "aliasedObjectName", "( 2.5.4.1 "
400 "NAME ( 'aliasedObjectName' 'aliasedEntryName' ) "
401 "DESC 'RFC2256: name of aliased object' "
402 "EQUALITY distinguishedNameMatch "
403 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )",
404 NULL, NULL, NULL, NULL,
405 offsetof(struct slap_internal_schema, si_ad_aliasedObjectName) },
406 { "ref", "( 2.16.840.1.113730.3.1.34 NAME 'ref' "
407 "DESC 'namedref: subordinate referral URL' "
408 "EQUALITY caseExactMatch "
409 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
410 "USAGE distributedOperation )",
411 referralAttribute, NULL, NULL, NULL,
412 offsetof(struct slap_internal_schema, si_ad_ref) },
414 /* access control internals */
415 { "entry", "( 1.3.6.1.4.1.4203.1.3.1 "
417 "DESC 'OpenLDAP ACL entry pseudo-attribute' "
418 "SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
419 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
420 NULL, NULL, NULL, NULL,
421 offsetof(struct slap_internal_schema, si_ad_entry) },
422 { "children", "( 1.3.6.1.4.1.4203.1.3.2 "
424 "DESC 'OpenLDAP ACL children pseudo-attribute' "
425 "SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
426 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
427 NULL, NULL, NULL, NULL,
428 offsetof(struct slap_internal_schema, si_ad_children) },
429 #ifdef SLAPD_ACI_ENABLED
430 { "OpenLDAPaci", "( 1.3.6.1.4.1.4203.666.1.5 "
431 "NAME 'OpenLDAPaci' "
432 "DESC 'OpenLDAP access control information (experimental)' "
433 "EQUALITY OpenLDAPaciMatch "
434 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 "
435 "USAGE directoryOperation )",
436 NULL, NULL, NULL, NULL,
437 offsetof(struct slap_internal_schema, si_ad_aci) },
440 { "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
441 "DESC 'RFC2589: entry time-to-live' "
442 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
443 "NO-USER-MODIFICATION USAGE dSAOperation )",
444 NULL, NULL, NULL, NULL,
445 offsetof(struct slap_internal_schema, si_ad_entryTtl) },
446 { "dynamicSubtrees", "( 1.3.6.1.4.1.1466.101.119.4 "
447 "NAME 'dynamicSubtrees' "
448 "DESC 'RFC2589: dynamic subtrees' "
449 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MODIFICATION "
450 "USAGE dSAOperation )",
451 rootDseAttribute, NULL, NULL, NULL,
452 offsetof(struct slap_internal_schema, si_ad_dynamicSubtrees) },
454 /* userApplication attributes */
455 { "distinguishedName", "( 2.5.4.49 NAME 'distinguishedName' "
456 "DESC 'RFC2256: common supertype of DN attributes' "
457 "EQUALITY distinguishedNameMatch "
458 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
459 NULL, NULL, NULL, NULL,
460 offsetof(struct slap_internal_schema, si_ad_distinguishedName) },
461 { "name", "( 2.5.4.41 NAME 'name' "
462 "DESC 'RFC2256: common supertype of name attributes' "
463 "EQUALITY caseIgnoreMatch "
464 "SUBSTR caseIgnoreSubstringsMatch "
465 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )",
466 NULL, NULL, NULL, NULL,
467 offsetof(struct slap_internal_schema, si_ad_name) },
468 { "cn", "( 2.5.4.3 NAME ( 'cn' 'commonName' ) "
469 "DESC 'RFC2256: common name(s) for which the entity is known by' "
471 NULL, NULL, NULL, NULL,
472 offsetof(struct slap_internal_schema, si_ad_cn) },
474 { "userPassword", "( 2.5.4.35 NAME 'userPassword' "
475 "DESC 'RFC2256/2307: password of user' "
476 "EQUALITY octetStringMatch "
477 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )",
478 NULL, NULL, NULL, NULL,
479 offsetof(struct slap_internal_schema, si_ad_userPassword) },
481 #ifdef SLAPD_AUTHPASSWD
482 { "authPassword", "( 1.3.6.1.4.1.4203.1.3.4 "
483 "NAME 'authPassword' "
484 "DESC 'RFC3112: authentication password attribute' "
485 "EQUALITY 1.3.6.1.4.1.4203.1.2.2 "
486 "SYNTAX 1.3.6.1.4.1.4203.1.1.2 )",
487 NULL, NULL, NULL, NULL,
488 offsetof(struct slap_internal_schema, si_ad_authPassword) },
489 { "supportedAuthPasswordSchemes", "( 1.3.6.1.4.1.4203.1.3.3 "
490 "NAME 'supportedAuthPasswordSchemes' "
491 "DESC 'RFC3112: supported authPassword schemes' "
492 "EQUALITY caseExactIA5Match "
493 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} "
494 "USAGE dSAOperation )",
495 subschemaAttribute, NULL, NULL, NULL,
496 offsetof(struct slap_internal_schema, si_ad_authPassword) },
498 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
500 NULL, NULL, NULL, NULL,
501 offsetof(struct slap_internal_schema, si_ad_krbName) },
504 { NULL, NULL, NULL, NULL, NULL, NULL, 0 }
507 static AttributeType slap_at_undefined = {
508 { "1.1.1", NULL, NULL, 1, NULL,
509 NULL, NULL, NULL, NULL,
510 0, 0, 0, 1, 3 }, /* LDAPAttributeType */
511 { sizeof("UNDEFINED")-1, "UNDEFINED" }, /* cname */
514 NULL, NULL, NULL, NULL, /* matching rules */
515 NULL, /* syntax (this may need to be defined) */
516 (AttributeTypeSchemaCheckFN *) 0, /* schema check function */
517 NULL, /* attribute description */
519 /* mutex (don't know how to initialize it :) */
522 static struct slap_schema_mr_map {
526 { "distinguishedNameMatch",
527 offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) },
529 offsetof(struct slap_internal_schema, si_mr_integerMatch) },
533 static struct slap_schema_syn_map {
537 { "1.3.6.1.4.1.1466.115.121.1.12",
538 offsetof(struct slap_internal_schema, si_syn_distinguishedName) },
539 { "1.3.6.1.4.1.1466.115.121.1.27",
540 offsetof(struct slap_internal_schema, si_syn_integer) },
545 slap_schema_load( void )
548 for( i=0; ad_map[i].ssam_name; i++ ) {
549 if( ad_map[i].ssam_defn != NULL ) {
550 LDAPAttributeType *at;
554 at = ldap_str2attributetype( ad_map[i].ssam_defn,
555 &code, &err, LDAP_SCHEMA_ALLOW_ALL );
558 "slap_schema_load: %s: %s before %s\n",
559 ad_map[i].ssam_name, ldap_scherr2str(code), err );
563 if ( at->at_oid == NULL ) {
564 fprintf( stderr, "slap_schema_load: "
565 "attributeType \"%s\" has no OID\n",
566 ad_map[i].ssam_name );
570 code = at_add( at, &err );
572 fprintf( stderr, "slap_schema_load: "
574 ad_map[i].ssam_name, scherr2str(code), err );
581 for( i=0; oc_map[i].ssom_name; i++ ) {
582 if( oc_map[i].ssom_defn != NULL ) {
587 oc = ldap_str2objectclass( oc_map[i].ssom_defn, &code, &err,
588 LDAP_SCHEMA_ALLOW_ALL );
590 fprintf( stderr, "slap_schema_load: "
591 "%s: %s before %s\n",
592 oc_map[i].ssom_name, ldap_scherr2str(code), err );
596 if ( oc->oc_oid == NULL ) {
597 fprintf( stderr, "slap_schema_load: "
598 "%s: objectclass has no OID\n",
599 oc_map[i].ssom_name );
603 code = oc_add(oc,&err);
605 fprintf( stderr, "slap_schema_load: "
607 oc_map[i].ssom_name, scherr2str(code), err);
619 slap_schema_check( void )
622 /* we should only be called once after schema_init() was called */
623 assert( schema_init_done == 1 );
625 for( i=0; syn_map[i].sssm_name; i++ ) {
626 Syntax ** synp = (Syntax **)
627 &(((char *) &slap_schema)[syn_map[i].sssm_offset]);
629 assert( *synp == NULL );
631 *synp = syn_find( syn_map[i].sssm_name );
633 if( *synp == NULL ) {
634 fprintf( stderr, "slap_schema_check: "
635 "No syntax \"%s\" defined in schema\n",
636 syn_map[i].sssm_name );
637 return LDAP_INVALID_SYNTAX;
641 for( i=0; mr_map[i].ssmm_name; i++ ) {
642 MatchingRule ** mrp = (MatchingRule **)
643 &(((char *) &slap_schema)[mr_map[i].ssmm_offset]);
645 assert( *mrp == NULL );
647 *mrp = mr_find( mr_map[i].ssmm_name );
650 fprintf( stderr, "slap_schema_check: "
651 "No matching rule \"%s\" defined in schema\n",
652 mr_map[i].ssmm_name );
653 return LDAP_INAPPROPRIATE_MATCHING;
657 slap_at_undefined.sat_syntax = syn_find( SLAPD_OCTETSTRING_SYNTAX );
658 if( slap_at_undefined.sat_syntax == NULL ) {
659 fprintf( stderr, "slap_schema_check: "
660 "No octetString syntax \"" SLAPD_OCTETSTRING_SYNTAX "\"\n" );
661 return LDAP_INVALID_SYNTAX;
663 slap_schema.si_at_undefined = &slap_at_undefined;
665 for( i=0; ad_map[i].ssam_name; i++ ) {
669 AttributeDescription ** adp = (AttributeDescription **)
670 &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
672 assert( *adp == NULL );
674 rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
676 if( rc != LDAP_SUCCESS ) {
677 fprintf( stderr, "slap_schema_check: "
678 "No attribute \"%s\" defined in schema\n",
679 ad_map[i].ssam_name );
683 if( ad_map[i].ssam_match ) {
684 /* install custom matching routine */
685 (*adp)->ad_type->sat_equality->smr_match = ad_map[i].ssam_match;
689 for( i=0; oc_map[i].ssom_name; i++ ) {
690 ObjectClass ** ocp = (ObjectClass **)
691 &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
693 assert( *ocp == NULL );
695 *ocp = oc_find( oc_map[i].ssom_name );
698 fprintf( stderr, "slap_schema_check: "
699 "No objectClass \"%s\" defined in schema\n",
700 oc_map[i].ssom_name );
701 return LDAP_OBJECT_CLASS_VIOLATION;
709 static int rootDseObjectClass (
713 char *textbuf, size_t textlen )
716 if( e->e_nname.bv_len ) {
717 snprintf( textbuf, textlen,
718 "objectClass \"%s\" only allowed in the root DSE",
720 return LDAP_OBJECT_CLASS_VIOLATION;
723 /* we should not be called for the root DSE */
728 static int subentryObjectClass (
732 char *textbuf, size_t textlen )
734 if( !is_entry_subentry( e ) ) {
735 snprintf( textbuf, textlen,
736 "objectClass \"%s\" only allowed in subentries",
738 return LDAP_OBJECT_CLASS_VIOLATION;
743 static int rootDseAttribute (
747 char *textbuf, size_t textlen )
750 if( e->e_nname.bv_len ) {
751 snprintf( textbuf, textlen,
752 "attribute \"%s\" only allowed in the root DSE",
753 attr->a_desc->ad_cname.bv_val );
754 return LDAP_OBJECT_CLASS_VIOLATION;
757 /* we should not be called for the root DSE */
762 static int subentryAttribute (
766 char *textbuf, size_t textlen )
769 if( !is_entry_subentry( e ) ) {
770 snprintf( textbuf, textlen,
771 "attribute \"%s\" only allowed in the subentry",
772 attr->a_desc->ad_cname.bv_val );
773 return LDAP_OBJECT_CLASS_VIOLATION;
779 static int referralAttribute (
783 char *textbuf, size_t textlen )
786 if( !is_entry_referral( e ) ) {
787 snprintf( textbuf, textlen,
788 "attribute \"%s\" only allowed in the referral",
789 attr->a_desc->ad_cname.bv_val );
790 return LDAP_OBJECT_CLASS_VIOLATION;