1 /* schema_prep.c - load builtin schema */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
22 #include <ac/string.h>
23 #include <ac/socket.h>
27 #include "ldap_pvt_uc.h"
31 int schema_init_done = 0;
33 struct slap_internal_schema slap_schema;
40 struct berval val = *in;
42 if( val.bv_len == 0 ) {
43 /* disallow empty strings */
44 return LDAP_INVALID_SYNTAX;
47 if( DESC_LEADCHAR( val.bv_val[0] ) ) {
50 if ( val.bv_len == 0 ) return LDAP_SUCCESS;
52 while( DESC_CHAR( val.bv_val[0] ) ) {
56 if ( val.bv_len == 0 ) return LDAP_SUCCESS;
61 while( OID_LEADCHAR( val.bv_val[0] ) ) {
65 if ( val.bv_val[-1] != '0' ) {
66 while ( OID_LEADCHAR( val.bv_val[0] )) {
72 if( val.bv_len == 0 ) {
77 if( !OID_SEPARATOR( val.bv_val[0] )) break;
85 return LDAP_INVALID_SYNTAX;
89 static int objectClassPretty(
90 struct slap_syntax *syntax,
97 if( oidValidate( NULL, in )) return LDAP_INVALID_SYNTAX;
100 if( oc == NULL ) return LDAP_INVALID_SYNTAX;
102 ber_dupbv_x( out, &oc->soc_cname, ctx );
112 struct berval *value,
113 void *assertedValue )
115 struct berval *a = (struct berval *) assertedValue;
116 AttributeType *at = at_bvfind( value );
117 AttributeType *asserted = at_bvfind( a );
119 if( asserted == NULL ) {
120 if( OID_LEADCHAR( *a->bv_val ) ) {
121 /* OID form, return FALSE */
126 /* desc form, return undefined */
127 return LDAP_INVALID_SYNTAX;
131 /* unrecognized stored value */
132 return LDAP_INVALID_SYNTAX;
135 *matchp = ( asserted != at );
145 struct berval *value,
146 void *assertedValue )
148 struct berval *a = (struct berval *) assertedValue;
149 MatchingRule *mrv = mr_bvfind( value );
150 MatchingRule *asserted = mr_bvfind( a );
152 if( asserted == NULL ) {
153 if( OID_LEADCHAR( *a->bv_val ) ) {
154 /* OID form, return FALSE */
159 /* desc form, return undefined */
160 return LDAP_INVALID_SYNTAX;
164 /* unrecognized stored value */
165 return LDAP_INVALID_SYNTAX;
168 *matchp = ( asserted != mrv );
178 struct berval *value,
179 void *assertedValue )
181 struct berval *a = (struct berval *) assertedValue;
182 ObjectClass *oc = oc_bvfind( value );
183 ObjectClass *asserted = oc_bvfind( a );
185 if( asserted == NULL ) {
186 if( OID_LEADCHAR( *a->bv_val ) ) {
187 /* OID form, return FALSE */
192 /* desc form, return undefined */
193 return LDAP_INVALID_SYNTAX;
197 /* unrecognized stored value */
198 return LDAP_INVALID_SYNTAX;
201 *matchp = ( asserted != oc );
211 struct berval *value,
212 void *assertedValue )
214 struct berval *a = (struct berval *) assertedValue;
215 ObjectClass *oc = oc_bvfind( value );
216 ObjectClass *asserted = oc_bvfind( a );
218 if( asserted == NULL ) {
219 if( OID_LEADCHAR( *a->bv_val ) ) {
220 /* OID form, return FALSE */
225 /* desc form, return undefined */
226 return LDAP_INVALID_SYNTAX;
230 /* unrecognized stored value */
231 return LDAP_INVALID_SYNTAX;
234 if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) {
235 *matchp = ( asserted != oc );
237 *matchp = !is_object_subclass( asserted, oc );
243 static int objectSubClassIndexer(
246 struct slap_syntax *syntax,
247 struct slap_matching_rule *mr,
248 struct berval *prefix,
256 for( noc=0; values[noc].bv_val != NULL; noc++ ) {
261 ocvalues = slap_sl_malloc( sizeof( struct berval ) * (noc+16), ctx );
263 /* copy listed values (and termination) */
264 for( i=0; i<noc; i++ ) {
265 ObjectClass *oc = oc_bvfind( &values[i] );
267 ocvalues[i] = oc->soc_cname;
269 ocvalues[i] = values[i];
273 ocvalues[i].bv_val = NULL;
274 ocvalues[i].bv_len = 0;
277 for( i=0; i<noc; i++ ) {
279 ObjectClass *oc = oc_bvfind( &ocvalues[i] );
280 if( oc == NULL || oc->soc_sups == NULL ) continue;
282 for( j=0; oc->soc_sups[j] != NULL; j++ ) {
284 ObjectClass *sup = oc->soc_sups[j];
287 for( k=0; k<noc; k++ ) {
288 if( bvmatch( &ocvalues[k], &sup->soc_cname ) ) {
295 ocvalues = slap_sl_realloc( ocvalues,
296 sizeof( struct berval ) * (noc+2), ctx );
300 ocvalues[noc] = sup->soc_cname;
302 assert( ocvalues[noc].bv_val );
303 assert( ocvalues[noc].bv_len );
307 ocvalues[noc].bv_len = 0;
308 ocvalues[noc].bv_val = NULL;
313 rc = octetStringIndexer( use, mask, syntax, mr,
314 prefix, ocvalues, keysp, ctx );
316 slap_sl_free( ocvalues, ctx );
320 #define objectSubClassFilter octetStringFilter
322 static ObjectClassSchemaCheckFN rootDseObjectClass;
323 static ObjectClassSchemaCheckFN aliasObjectClass;
324 static ObjectClassSchemaCheckFN referralObjectClass;
325 static ObjectClassSchemaCheckFN subentryObjectClass;
326 static ObjectClassSchemaCheckFN dynamicObjectClass;
328 static struct slap_schema_oc_map {
331 ObjectClassSchemaCheckFN *ssom_check;
332 slap_mask_t ssom_flags;
335 { "top", "( 2.5.6.0 NAME 'top' "
336 "DESC 'top of the superclass chain' "
337 "ABSTRACT MUST objectClass )",
338 0, 0, offsetof(struct slap_internal_schema, si_oc_top) },
339 { "extensibleObject", "( 1.3.6.1.4.1.1466.101.120.111 "
340 "NAME 'extensibleObject' "
341 "DESC 'RFC2252: extensible object' "
342 "SUP top AUXILIARY )",
343 0, SLAP_OC_OPERATIONAL,
344 offsetof(struct slap_internal_schema, si_oc_extensibleObject) },
345 { "alias", "( 2.5.6.1 NAME 'alias' "
346 "DESC 'RFC2256: an alias' "
347 "SUP top STRUCTURAL "
348 "MUST aliasedObjectName )",
349 aliasObjectClass, SLAP_OC_ALIAS|SLAP_OC_OPERATIONAL,
350 offsetof(struct slap_internal_schema, si_oc_alias) },
351 { "referral", "( 2.16.840.1.113730.3.2.6 NAME 'referral' "
352 "DESC 'namedref: named subordinate referral' "
353 "SUP top STRUCTURAL MUST ref )",
354 referralObjectClass, SLAP_OC_REFERRAL|SLAP_OC_OPERATIONAL,
355 offsetof(struct slap_internal_schema, si_oc_referral) },
356 { "LDAProotDSE", "( 1.3.6.1.4.1.4203.1.4.1 "
357 "NAME ( 'OpenLDAProotDSE' 'LDAProotDSE' ) "
358 "DESC 'OpenLDAP Root DSE object' "
359 "SUP top STRUCTURAL MAY cn )",
360 rootDseObjectClass, SLAP_OC_OPERATIONAL,
361 offsetof(struct slap_internal_schema, si_oc_rootdse) },
362 { "subentry", "( 2.5.17.0 NAME 'subentry' "
363 "SUP top STRUCTURAL "
364 "MUST ( cn $ subtreeSpecification ) )",
365 subentryObjectClass, SLAP_OC_SUBENTRY|SLAP_OC_OPERATIONAL,
366 offsetof(struct slap_internal_schema, si_oc_subentry) },
367 { "subschema", "( 2.5.20.1 NAME 'subschema' "
368 "DESC 'RFC2252: controlling subschema (sub)entry' "
370 "MAY ( dITStructureRules $ nameForms $ ditContentRules $ "
371 "objectClasses $ attributeTypes $ matchingRules $ "
372 "matchingRuleUse ) )",
373 subentryObjectClass, SLAP_OC_OPERATIONAL,
374 offsetof(struct slap_internal_schema, si_oc_subschema) },
376 { "collectiveAttributeSubentry", "( 2.5.17.2 "
377 "NAME 'collectiveAttributeSubentry' "
380 SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
381 offsetof(struct slap_internal_schema, si_oc_collectiveAttributeSubentry) },
382 { "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
383 "NAME 'dynamicObject' "
384 "DESC 'RFC2589: Dynamic Object' "
385 "SUP top AUXILIARY )",
386 dynamicObjectClass, SLAP_OC_DYNAMICOBJECT,
387 offsetof(struct slap_internal_schema, si_oc_dynamicObject) },
389 { "glue", "( 1.3.6.1.4.1.4203.666.3.4 "
392 "SUP top STRUCTURAL )",
393 0, SLAP_OC_GLUE|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
394 offsetof(struct slap_internal_schema, si_oc_glue) },
395 { "syncConsumerSubentry", "( 1.3.6.1.4.1.4203.666.3.5 "
396 "NAME 'syncConsumerSubentry' "
397 "DESC 'Persistent Info for SyncRepl Consumer' "
399 "MAY syncreplCookie )",
400 0, SLAP_OC_SYNCCONSUMERSUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
401 offsetof(struct slap_internal_schema, si_oc_syncConsumerSubentry) },
402 { "syncProviderSubentry", "( 1.3.6.1.4.1.4203.666.3.6 "
403 "NAME 'syncProviderSubentry' "
404 "DESC 'Persistent Info for SyncRepl Producer' "
407 0, SLAP_OC_SYNCPROVIDERSUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
408 offsetof(struct slap_internal_schema, si_oc_syncProviderSubentry) },
410 { NULL, NULL, NULL, 0, 0 }
413 static AttributeTypeSchemaCheckFN rootDseAttribute;
414 static AttributeTypeSchemaCheckFN aliasAttribute;
415 static AttributeTypeSchemaCheckFN referralAttribute;
416 static AttributeTypeSchemaCheckFN subentryAttribute;
417 static AttributeTypeSchemaCheckFN administrativeRoleAttribute;
418 static AttributeTypeSchemaCheckFN dynamicAttribute;
420 static struct slap_schema_ad_map {
423 AttributeTypeSchemaCheckFN *ssam_check;
424 slap_mask_t ssam_flags;
425 slap_syntax_validate_func *ssam_syn_validate;
426 slap_syntax_transform_func *ssam_syn_pretty;
427 slap_mr_convert_func *ssam_mr_convert;
428 slap_mr_normalize_func *ssam_mr_normalize;
429 slap_mr_match_func *ssam_mr_match;
430 slap_mr_indexer_func *ssam_mr_indexer;
431 slap_mr_filter_func *ssam_mr_filter;
434 { "objectClass", "( 2.5.4.0 NAME 'objectClass' "
435 "DESC 'RFC2256: object classes of the entity' "
436 "EQUALITY objectIdentifierMatch "
437 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
439 oidValidate, objectClassPretty,
440 NULL, NULL, objectSubClassMatch,
441 objectSubClassIndexer, objectSubClassFilter,
442 offsetof(struct slap_internal_schema, si_ad_objectClass) },
444 /* user entry operational attributes */
445 { "structuralObjectClass", "( 2.5.21.9 NAME 'structuralObjectClass' "
446 "DESC 'X.500(93): structural object class of entry' "
447 "EQUALITY objectIdentifierMatch "
448 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
449 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
451 oidValidate, objectClassPretty,
452 NULL, NULL, objectSubClassMatch,
453 objectSubClassIndexer, objectSubClassFilter,
454 offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
455 { "createTimestamp", "( 2.5.18.1 NAME 'createTimestamp' "
456 "DESC 'RFC2252: time which object was created' "
457 "EQUALITY generalizedTimeMatch "
458 "ORDERING generalizedTimeOrderingMatch "
459 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
460 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
463 NULL, NULL, NULL, NULL, NULL,
464 offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
465 { "modifyTimestamp", "( 2.5.18.2 NAME 'modifyTimestamp' "
466 "DESC 'RFC2252: time which object was last modified' "
467 "EQUALITY generalizedTimeMatch "
468 "ORDERING generalizedTimeOrderingMatch "
469 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
470 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
473 NULL, NULL, NULL, NULL, NULL,
474 offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
475 { "creatorsName", "( 2.5.18.3 NAME 'creatorsName' "
476 "DESC 'RFC2252: name of creator' "
477 "EQUALITY distinguishedNameMatch "
478 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
479 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
482 NULL, NULL, NULL, NULL, NULL,
483 offsetof(struct slap_internal_schema, si_ad_creatorsName) },
484 { "modifiersName", "( 2.5.18.4 NAME 'modifiersName' "
485 "DESC 'RFC2252: name of last modifier' "
486 "EQUALITY distinguishedNameMatch "
487 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
488 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
491 NULL, NULL, NULL, NULL, NULL,
492 offsetof(struct slap_internal_schema, si_ad_modifiersName) },
493 { "hasSubordinates", "( 2.5.18.9 NAME 'hasSubordinates' "
494 "DESC 'X.501: entry has children' "
495 "EQUALITY booleanMatch "
496 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
497 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
498 NULL, SLAP_AT_DYNAMIC,
500 NULL, NULL, NULL, NULL, NULL,
501 offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
502 { "subschemaSubentry", "( 2.5.18.10 NAME 'subschemaSubentry' "
503 "DESC 'RFC2252: name of controlling subschema entry' "
504 "EQUALITY distinguishedNameMatch "
505 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE "
506 "NO-USER-MODIFICATION USAGE directoryOperation )",
507 NULL, SLAP_AT_DYNAMIC,
509 NULL, NULL, NULL, NULL, NULL,
510 offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
512 { "collectiveAttributeSubentries", "( 2.5.18.12 "
513 "NAME 'collectiveAttributeSubentries' "
514 "EQUALITY distinguishedNameMatch "
515 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
516 "NO-USER-MODIFICATION USAGE directoryOperation )",
519 NULL, NULL, NULL, NULL, NULL,
520 offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
521 { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
522 "EQUALITY objectIdentifierMatch "
523 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
524 "USAGE directoryOperation )",
527 NULL, NULL, NULL, NULL, NULL,
528 offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) },
531 { "entryDN", "( 1.3.6.1.4.1.4203.666.1.33 NAME 'entryDN' "
532 "DESC 'DN of the entry' "
533 "EQUALITY distinguishedNameMatch "
534 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
535 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
536 NULL, SLAP_AT_HIDE|SLAP_AT_DYNAMIC,
538 NULL, NULL, NULL, NULL, NULL,
539 offsetof(struct slap_internal_schema, si_ad_entryDN) },
540 { "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' "
541 "DESC 'UUID of the entry' "
542 "EQUALITY UUIDMatch "
543 "ORDERING UUIDOrderingMatch "
544 "SYNTAX 1.3.6.1.4.1.4203.666.2.6 "
545 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
548 NULL, NULL, NULL, NULL, NULL,
549 offsetof(struct slap_internal_schema, si_ad_entryUUID) },
550 { "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' "
551 "DESC 'change sequence number of the entry content' "
552 "EQUALITY octetStringMatch "
553 "ORDERING octetStringOrderingMatch "
554 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
555 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
558 NULL, NULL, NULL, NULL, NULL,
559 offsetof(struct slap_internal_schema, si_ad_entryCSN) },
560 { "namingCSN", "( 1.3.6.1.4.1.4203.666.1.13 NAME 'namingCSN' "
561 "DESC 'change sequence number of the entry naming (RDN)' "
562 "EQUALITY octetStringMatch "
563 "ORDERING octetStringOrderingMatch "
564 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
565 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
568 NULL, NULL, NULL, NULL, NULL,
569 offsetof(struct slap_internal_schema, si_ad_namingCSN) },
572 { "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "
573 "DESC 'UUID of the superior entry' "
574 "EQUALITY octetStringMatch "
575 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
576 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
579 NULL, NULL, NULL, NULL, NULL,
580 offsetof(struct slap_internal_schema, si_ad_superiorUUID) },
583 { "syncreplCookie", "( 1.3.6.1.4.1.4203.666.1.23 "
584 "NAME 'syncreplCookie' "
585 "DESC 'syncrepl Cookie for shadow copy' "
586 "EQUALITY octetStringMatch "
587 "ORDERING octetStringOrderingMatch "
588 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
589 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
592 NULL, NULL, NULL, NULL, NULL,
593 offsetof(struct slap_internal_schema, si_ad_syncreplCookie) },
595 { "contextCSN", "( 1.3.6.1.4.1.4203.666.1.25 "
597 "DESC 'the largest committed CSN of a context' "
598 "EQUALITY octetStringMatch "
599 "ORDERING octetStringOrderingMatch "
600 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
601 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
604 NULL, NULL, NULL, NULL, NULL,
605 offsetof(struct slap_internal_schema, si_ad_contextCSN) },
608 { "syncTimestamp", "( 1.3.6.1.4.1.4203.666.1.26 NAME 'syncTimestamp' "
609 "DESC 'Time which object was replicated' "
610 "EQUALITY generalizedTimeMatch "
611 "ORDERING generalizedTimeOrderingMatch "
612 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
613 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
616 NULL, NULL, NULL, NULL, NULL,
617 offsetof(struct slap_internal_schema, si_ad_syncTimestamp) },
620 /* root DSE attributes */
621 { "altServer", "( 1.3.6.1.4.1.1466.101.120.6 NAME 'altServer' "
622 "DESC 'RFC2252: alternative servers' "
623 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 USAGE dSAOperation )",
626 NULL, NULL, NULL, NULL, NULL,
627 offsetof(struct slap_internal_schema, si_ad_altServer) },
628 { "namingContexts", "( 1.3.6.1.4.1.1466.101.120.5 "
629 "NAME 'namingContexts' "
630 "DESC 'RFC2252: naming contexts' "
631 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 USAGE dSAOperation )",
634 NULL, NULL, NULL, NULL, NULL,
635 offsetof(struct slap_internal_schema, si_ad_namingContexts) },
636 { "supportedControl", "( 1.3.6.1.4.1.1466.101.120.13 "
637 "NAME 'supportedControl' "
638 "DESC 'RFC2252: supported controls' "
639 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
642 NULL, NULL, NULL, NULL, NULL,
643 offsetof(struct slap_internal_schema, si_ad_supportedControl) },
644 { "supportedExtension", "( 1.3.6.1.4.1.1466.101.120.7 "
645 "NAME 'supportedExtension' "
646 "DESC 'RFC2252: supported extended operations' "
647 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
650 NULL, NULL, NULL, NULL, NULL,
651 offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
652 { "supportedLDAPVersion", "( 1.3.6.1.4.1.1466.101.120.15 "
653 "NAME 'supportedLDAPVersion' "
654 "DESC 'RFC2252: supported LDAP versions' "
655 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 USAGE dSAOperation )",
658 NULL, NULL, NULL, NULL, NULL,
659 offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
660 { "supportedSASLMechanisms", "( 1.3.6.1.4.1.1466.101.120.14 "
661 "NAME 'supportedSASLMechanisms' "
662 "DESC 'RFC2252: supported SASL mechanisms'"
663 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE dSAOperation )",
666 NULL, NULL, NULL, NULL, NULL,
667 offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
668 { "supportedFeatures", "( 1.3.6.1.4.1.4203.1.3.5 "
669 "NAME 'supportedFeatures' "
670 "DESC 'features supported by the server' "
671 "EQUALITY objectIdentifierMatch "
672 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
673 "USAGE dSAOperation )",
676 NULL, NULL, NULL, NULL, NULL,
677 offsetof(struct slap_internal_schema, si_ad_supportedFeatures) },
678 { "monitorContext", "( 1.3.6.1.4.1.4203.666.1.10 "
679 "NAME 'monitorContext' "
680 "DESC 'monitor context' "
681 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
682 "SINGLE-VALUE NO-USER-MODIFICATION "
683 "USAGE dSAOperation )",
684 rootDseAttribute, SLAP_AT_HIDE,
686 NULL, NULL, NULL, NULL, NULL,
687 offsetof(struct slap_internal_schema, si_ad_monitorContext) },
688 { "vendorName", "( 1.3.6.1.1.4 NAME 'vendorName' "
689 "DESC 'RFC3045: name of implementation vendor' "
690 "EQUALITY caseExactMatch "
691 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
692 "SINGLE-VALUE NO-USER-MODIFICATION "
693 "USAGE dSAOperation )",
696 NULL, NULL, NULL, NULL, NULL,
697 offsetof(struct slap_internal_schema, si_ad_vendorName) },
698 { "vendorVersion", "( 1.3.6.1.1.5 NAME 'vendorVersion' "
699 "DESC 'RFC3045: version of implementation' "
700 "EQUALITY caseExactMatch "
701 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
702 "SINGLE-VALUE NO-USER-MODIFICATION "
703 "USAGE dSAOperation )",
706 NULL, NULL, NULL, NULL, NULL,
707 offsetof(struct slap_internal_schema, si_ad_vendorVersion) },
709 /* subentry attributes */
710 { "administrativeRole", "( 2.5.18.5 NAME 'administrativeRole' "
711 "EQUALITY objectIdentifierMatch "
712 "USAGE directoryOperation "
713 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
714 administrativeRoleAttribute, SLAP_AT_HIDE,
716 NULL, NULL, NULL, NULL, NULL,
717 offsetof(struct slap_internal_schema, si_ad_administrativeRole) },
718 { "subtreeSpecification", "( 2.5.18.6 NAME 'subtreeSpecification' "
720 "USAGE directoryOperation "
721 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )",
722 subentryAttribute, SLAP_AT_HIDE,
724 NULL, NULL, NULL, NULL, NULL,
725 offsetof(struct slap_internal_schema, si_ad_subtreeSpecification) },
727 /* subschema subentry attributes */
728 { "ditStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
729 "DESC 'RFC2252: DIT structure rules' "
730 "EQUALITY integerFirstComponentMatch "
731 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
732 "USAGE directoryOperation ) ",
733 subentryAttribute, SLAP_AT_HIDE,
735 NULL, NULL, NULL, NULL, NULL,
736 offsetof(struct slap_internal_schema, si_ad_ditStructureRules) },
737 { "ditContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
738 "DESC 'RFC2252: DIT content rules' "
739 "EQUALITY objectIdentifierFirstComponentMatch "
740 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
741 subentryAttribute, SLAP_AT_HIDE,
743 NULL, NULL, objectClassMatch, NULL, NULL,
744 offsetof(struct slap_internal_schema, si_ad_ditContentRules) },
745 { "matchingRules", "( 2.5.21.4 NAME 'matchingRules' "
746 "DESC 'RFC2252: matching rules' "
747 "EQUALITY objectIdentifierFirstComponentMatch "
748 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )",
749 subentryAttribute, 0,
751 NULL, NULL, matchingRuleMatch, NULL, NULL,
752 offsetof(struct slap_internal_schema, si_ad_matchingRules) },
753 { "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' "
754 "DESC 'RFC2252: attribute types' "
755 "EQUALITY objectIdentifierFirstComponentMatch "
756 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )",
757 subentryAttribute, 0,
759 NULL, NULL, attributeTypeMatch, NULL, NULL,
760 offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
761 { "objectClasses", "( 2.5.21.6 NAME 'objectClasses' "
762 "DESC 'RFC2252: object classes' "
763 "EQUALITY objectIdentifierFirstComponentMatch "
764 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )",
765 subentryAttribute, 0,
767 NULL, NULL, objectClassMatch, NULL, NULL,
768 offsetof(struct slap_internal_schema, si_ad_objectClasses) },
769 { "nameForms", "( 2.5.21.7 NAME 'nameForms' "
770 "DESC 'RFC2252: name forms ' "
771 "EQUALITY objectIdentifierFirstComponentMatch "
772 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.35 USAGE directoryOperation )",
773 subentryAttribute, SLAP_AT_HIDE,
775 NULL, NULL, NULL, NULL, NULL,
776 offsetof(struct slap_internal_schema, si_ad_nameForms) },
777 { "matchingRuleUse", "( 2.5.21.8 NAME 'matchingRuleUse' "
778 "DESC 'RFC2252: matching rule uses' "
779 "EQUALITY objectIdentifierFirstComponentMatch "
780 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )",
781 subentryAttribute, 0,
783 NULL, NULL, matchingRuleMatch, NULL, NULL,
784 offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) },
786 { "ldapSyntaxes", "( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' "
787 "DESC 'RFC2252: LDAP syntaxes' "
788 "EQUALITY objectIdentifierFirstComponentMatch "
789 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation )",
790 subentryAttribute, 0,
792 NULL, NULL, NULL, NULL, NULL,
793 offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
795 /* knowledge information */
796 { "aliasedObjectName", "( 2.5.4.1 "
797 "NAME ( 'aliasedObjectName' 'aliasedEntryName' ) "
798 "DESC 'RFC2256: name of aliased object' "
799 "EQUALITY distinguishedNameMatch "
800 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )",
801 aliasAttribute, SLAP_AT_FINAL,
803 NULL, NULL, NULL, NULL, NULL,
804 offsetof(struct slap_internal_schema, si_ad_aliasedObjectName) },
805 { "ref", "( 2.16.840.1.113730.3.1.34 NAME 'ref' "
806 "DESC 'namedref: subordinate referral URL' "
807 "EQUALITY caseExactMatch "
808 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
809 "USAGE distributedOperation )",
810 referralAttribute, 0,
812 NULL, NULL, NULL, NULL, NULL,
813 offsetof(struct slap_internal_schema, si_ad_ref) },
815 /* access control internals */
816 { "entry", "( 1.3.6.1.4.1.4203.1.3.1 "
818 "DESC 'OpenLDAP ACL entry pseudo-attribute' "
819 "SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
820 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
823 NULL, NULL, NULL, NULL, NULL,
824 offsetof(struct slap_internal_schema, si_ad_entry) },
825 { "children", "( 1.3.6.1.4.1.4203.1.3.2 "
827 "DESC 'OpenLDAP ACL children pseudo-attribute' "
828 "SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
829 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
832 NULL, NULL, NULL, NULL, NULL,
833 offsetof(struct slap_internal_schema, si_ad_children) },
834 { "authzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
835 "NAME ( 'authzTo' 'saslAuthzTo' ) "
836 "DESC 'proxy authorization targets' "
837 "EQUALITY caseExactMatch "
838 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
839 "USAGE distributedOperation )",
842 NULL, NULL, NULL, NULL, NULL,
843 offsetof(struct slap_internal_schema, si_ad_saslAuthzTo) },
844 { "authzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
845 "NAME ( 'authzFrom' 'saslAuthzFrom' ) "
846 "DESC 'proxy authorization sources' "
847 "EQUALITY caseExactMatch "
848 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
849 "USAGE distributedOperation )",
852 NULL, NULL, NULL, NULL, NULL,
853 offsetof(struct slap_internal_schema, si_ad_saslAuthzFrom) },
854 #ifdef SLAPD_ACI_ENABLED
855 { "OpenLDAPaci", "( 1.3.6.1.4.1.4203.666.1.5 "
856 "NAME 'OpenLDAPaci' "
857 "DESC 'OpenLDAP access control information (experimental)' "
858 "EQUALITY OpenLDAPaciMatch "
859 "SYNTAX 1.3.6.1.4.1.4203.666.2.1 "
860 "USAGE directoryOperation )",
863 NULL, NULL, NULL, NULL, NULL,
864 offsetof(struct slap_internal_schema, si_ad_aci) },
868 { "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
869 "DESC 'RFC2589: entry time-to-live' "
870 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
871 "NO-USER-MODIFICATION USAGE dSAOperation )",
874 NULL, NULL, NULL, NULL, NULL,
875 offsetof(struct slap_internal_schema, si_ad_entryTtl) },
876 { "dynamicSubtrees", "( 1.3.6.1.4.1.1466.101.119.4 "
877 "NAME 'dynamicSubtrees' "
878 "DESC 'RFC2589: dynamic subtrees' "
879 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MODIFICATION "
880 "USAGE dSAOperation )",
883 NULL, NULL, NULL, NULL, NULL,
884 offsetof(struct slap_internal_schema, si_ad_dynamicSubtrees) },
887 /* userApplication attributes (which system schema depends upon) */
888 { "distinguishedName", "( 2.5.4.49 NAME 'distinguishedName' "
889 "DESC 'RFC2256: common supertype of DN attributes' "
890 "EQUALITY distinguishedNameMatch "
891 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
892 NULL, SLAP_AT_ABSTRACT,
894 NULL, NULL, NULL, NULL, NULL,
895 offsetof(struct slap_internal_schema, si_ad_distinguishedName) },
896 { "name", "( 2.5.4.41 NAME 'name' "
897 "DESC 'RFC2256: common supertype of name attributes' "
898 "EQUALITY caseIgnoreMatch "
899 "SUBSTR caseIgnoreSubstringsMatch "
900 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )",
901 NULL, SLAP_AT_ABSTRACT,
903 NULL, NULL, NULL, NULL, NULL,
904 offsetof(struct slap_internal_schema, si_ad_name) },
905 { "cn", "( 2.5.4.3 NAME ( 'cn' 'commonName' ) "
906 "DESC 'RFC2256: common name(s) for which the entity is known by' "
910 NULL, NULL, NULL, NULL, NULL,
911 offsetof(struct slap_internal_schema, si_ad_cn) },
912 { "userPassword", "( 2.5.4.35 NAME 'userPassword' "
913 "DESC 'RFC2256/2307: password of user' "
914 "EQUALITY octetStringMatch "
915 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )",
918 NULL, NULL, NULL, NULL, NULL,
919 offsetof(struct slap_internal_schema, si_ad_userPassword) },
921 { "labeledURI", "( 1.3.6.1.4.1.250.1.57 NAME 'labeledURI' "
922 "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
923 "EQUALITY caseExactMatch "
924 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
927 NULL, NULL, NULL, NULL, NULL,
928 offsetof(struct slap_internal_schema, si_ad_labeledURI) },
930 #ifdef SLAPD_AUTHPASSWD
931 { "authPassword", "( 1.3.6.1.4.1.4203.1.3.4 "
932 "NAME 'authPassword' "
933 "DESC 'RFC3112: authentication password attribute' "
934 "EQUALITY 1.3.6.1.4.1.4203.1.2.2 "
935 "SYNTAX 1.3.6.1.4.1.4203.1.1.2 )",
938 NULL, NULL, NULL, NULL, NULL,
939 offsetof(struct slap_internal_schema, si_ad_authPassword) },
940 { "supportedAuthPasswordSchemes", "( 1.3.6.1.4.1.4203.1.3.3 "
941 "NAME 'supportedAuthPasswordSchemes' "
942 "DESC 'RFC3112: supported authPassword schemes' "
943 "EQUALITY caseExactIA5Match "
944 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} "
945 "USAGE dSAOperation )",
946 subschemaAttribute, 0,
948 NULL, NULL, NULL, NULL, NULL,
949 offsetof(struct slap_internal_schema, si_ad_authPassword) },
951 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
952 { "krbName", "( 1.3.6.1.4.1.250.1.32 "
953 "NAME ( 'krbName' 'kerberosName' ) "
954 "DESC 'Kerberos principal associated with object' "
955 "EQUALITY caseIgnoreIA5Match "
956 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 "
960 NULL, NULL, NULL, NULL, NULL,
961 offsetof(struct slap_internal_schema, si_ad_krbName) },
963 { NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 }
966 static AttributeType slap_at_undefined = {
967 { "1.1.1", NULL, NULL, 1, NULL,
968 NULL, NULL, NULL, NULL,
969 0, 0, 0, 1, 3, NULL }, /* LDAPAttributeType */
970 { sizeof("UNDEFINED")-1, "UNDEFINED" }, /* cname */
973 NULL, NULL, NULL, NULL, /* matching rules routines */
974 NULL, /* syntax (this may need to be defined) */
975 (AttributeTypeSchemaCheckFN *) 0, /* schema check function */
976 SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
978 NULL /* attribute description */
979 /* mutex (don't know how to initialize it :) */
982 static struct slap_schema_mr_map {
986 { "caseExactIA5Match",
987 offsetof(struct slap_internal_schema, si_mr_caseExactIA5Match) },
989 offsetof(struct slap_internal_schema, si_mr_caseExactMatch) },
990 { "caseExactSubstringsMatch",
991 offsetof(struct slap_internal_schema, si_mr_caseExactSubstringsMatch) },
992 { "distinguishedNameMatch",
993 offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) },
995 offsetof(struct slap_internal_schema, si_mr_dnSubtreeMatch) },
997 offsetof(struct slap_internal_schema, si_mr_dnOneLevelMatch) },
998 { "dnSubordinateMatch",
999 offsetof(struct slap_internal_schema, si_mr_dnSubordinateMatch) },
1000 { "dnSuperiorMatch",
1001 offsetof(struct slap_internal_schema, si_mr_dnSuperiorMatch) },
1003 offsetof(struct slap_internal_schema, si_mr_integerMatch) },
1004 { "integerFirstComponentMatch",
1005 offsetof(struct slap_internal_schema,
1006 si_mr_integerFirstComponentMatch) },
1007 { "objectIdentifierFirstComponentMatch",
1008 offsetof(struct slap_internal_schema,
1009 si_mr_objectIdentifierFirstComponentMatch) },
1013 static struct slap_schema_syn_map {
1017 { "1.3.6.1.4.1.1466.115.121.1.15",
1018 offsetof(struct slap_internal_schema, si_syn_directoryString) },
1019 { "1.3.6.1.4.1.1466.115.121.1.12",
1020 offsetof(struct slap_internal_schema, si_syn_distinguishedName) },
1021 { "1.3.6.1.4.1.1466.115.121.1.27",
1022 offsetof(struct slap_internal_schema, si_syn_integer) },
1023 { "1.3.6.1.4.1.1466.115.121.1.40",
1024 offsetof(struct slap_internal_schema, si_syn_octetString) },
1026 { "1.3.6.1.4.1.1466.115.121.1.3",
1027 offsetof(struct slap_internal_schema, si_syn_attributeTypeDesc) },
1028 { "1.3.6.1.4.1.1466.115.121.1.16",
1029 offsetof(struct slap_internal_schema, si_syn_ditContentRuleDesc) },
1030 { "1.3.6.1.4.1.1466.115.121.1.54",
1031 offsetof(struct slap_internal_schema, si_syn_ldapSyntaxDesc) },
1032 { "1.3.6.1.4.1.1466.115.121.1.30",
1033 offsetof(struct slap_internal_schema, si_syn_matchingRuleDesc) },
1034 { "1.3.6.1.4.1.1466.115.121.1.31",
1035 offsetof(struct slap_internal_schema, si_syn_matchingRuleUseDesc) },
1036 { "1.3.6.1.4.1.1466.115.121.1.35",
1037 offsetof(struct slap_internal_schema, si_syn_nameFormDesc) },
1038 { "1.3.6.1.4.1.1466.115.121.1.37",
1039 offsetof(struct slap_internal_schema, si_syn_objectClassDesc) },
1041 { "1.3.6.1.4.1.1466.115.121.1.17",
1042 offsetof(struct slap_internal_schema, si_syn_ditStructureRuleDesc) },
1048 slap_schema_load( void )
1052 for( i=0; syn_map[i].sssm_name; i++ ) {
1053 Syntax ** synp = (Syntax **)
1054 &(((char *) &slap_schema)[syn_map[i].sssm_offset]);
1056 assert( *synp == NULL );
1058 *synp = syn_find( syn_map[i].sssm_name );
1060 if( *synp == NULL ) {
1061 fprintf( stderr, "slap_schema_load: Syntax: "
1062 "No syntax \"%s\" defined in schema\n",
1063 syn_map[i].sssm_name );
1064 return LDAP_INVALID_SYNTAX;
1068 for( i=0; mr_map[i].ssmm_name; i++ ) {
1069 MatchingRule ** mrp = (MatchingRule **)
1070 &(((char *) &slap_schema)[mr_map[i].ssmm_offset]);
1072 assert( *mrp == NULL );
1074 *mrp = mr_find( mr_map[i].ssmm_name );
1076 if( *mrp == NULL ) {
1077 fprintf( stderr, "slap_schema_load: MatchingRule: "
1078 "No matching rule \"%s\" defined in schema\n",
1079 mr_map[i].ssmm_name );
1080 return LDAP_INAPPROPRIATE_MATCHING;
1084 for( i=0; ad_map[i].ssam_name; i++ ) {
1085 assert( ad_map[i].ssam_defn != NULL );
1087 LDAPAttributeType *at;
1091 at = ldap_str2attributetype( ad_map[i].ssam_defn,
1092 &code, &err, LDAP_SCHEMA_ALLOW_ALL );
1095 "slap_schema_load: AttributeType \"%s\": %s before %s\n",
1096 ad_map[i].ssam_name, ldap_scherr2str(code), err );
1100 if ( at->at_oid == NULL ) {
1101 fprintf( stderr, "slap_schema_load: "
1102 "AttributeType \"%s\": no OID\n",
1103 ad_map[i].ssam_name );
1107 code = at_add( at, &err );
1109 fprintf( stderr, "slap_schema_load: AttributeType "
1110 "\"%s\": %s: \"%s\"\n",
1111 ad_map[i].ssam_name, scherr2str(code), err );
1119 Syntax *syntax = NULL;
1121 AttributeDescription ** adp = (AttributeDescription **)
1122 &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
1124 assert( *adp == NULL );
1126 rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
1127 if( rc != LDAP_SUCCESS ) {
1128 fprintf( stderr, "slap_schema_load: AttributeType \"%s\": "
1129 "not defined in schema\n",
1130 ad_map[i].ssam_name );
1134 if( ad_map[i].ssam_check ) {
1135 /* install check routine */
1136 (*adp)->ad_type->sat_check = ad_map[i].ssam_check;
1139 (*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags;
1141 /* install custom syntax routines */
1142 if( ad_map[i].ssam_syn_validate ||
1143 ad_map[i].ssam_syn_pretty )
1147 syntax = (*adp)->ad_type->sat_syntax;
1149 syn = ch_malloc( sizeof( Syntax ) );
1152 if( ad_map[i].ssam_syn_validate ) {
1153 syn->ssyn_validate = ad_map[i].ssam_syn_validate;
1155 if( ad_map[i].ssam_syn_pretty ) {
1156 syn->ssyn_pretty = ad_map[i].ssam_syn_pretty;
1159 (*adp)->ad_type->sat_syntax = syn;
1162 /* install custom rule routines */
1163 if( syntax != NULL ||
1164 ad_map[i].ssam_mr_convert ||
1165 ad_map[i].ssam_mr_normalize ||
1166 ad_map[i].ssam_mr_match ||
1167 ad_map[i].ssam_mr_indexer ||
1168 ad_map[i].ssam_mr_filter )
1170 MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
1171 *mr = *(*adp)->ad_type->sat_equality;
1173 if ( syntax != NULL ) {
1174 mr->smr_syntax = (*adp)->ad_type->sat_syntax;
1176 if ( ad_map[i].ssam_mr_convert ) {
1177 mr->smr_convert = ad_map[i].ssam_mr_convert;
1179 if ( ad_map[i].ssam_mr_normalize ) {
1180 mr->smr_normalize = ad_map[i].ssam_mr_normalize;
1182 if ( ad_map[i].ssam_mr_match ) {
1183 mr->smr_match = ad_map[i].ssam_mr_match;
1185 if ( ad_map[i].ssam_mr_indexer ) {
1186 mr->smr_indexer = ad_map[i].ssam_mr_indexer;
1188 if ( ad_map[i].ssam_mr_filter ) {
1189 mr->smr_filter = ad_map[i].ssam_mr_filter;
1192 (*adp)->ad_type->sat_equality = mr;
1197 for( i=0; oc_map[i].ssom_name; i++ ) {
1198 assert( oc_map[i].ssom_defn != NULL );
1200 LDAPObjectClass *oc;
1204 oc = ldap_str2objectclass( oc_map[i].ssom_defn, &code, &err,
1205 LDAP_SCHEMA_ALLOW_ALL );
1207 fprintf( stderr, "slap_schema_load: ObjectClass "
1208 "\"%s\": %s before %s\n",
1209 oc_map[i].ssom_name, ldap_scherr2str(code), err );
1213 if ( oc->oc_oid == NULL ) {
1214 fprintf( stderr, "slap_schema_load: ObjectClass "
1216 oc_map[i].ssom_name );
1220 code = oc_add(oc,0,&err);
1222 fprintf( stderr, "slap_schema_load: ObjectClass "
1223 "\"%s\": %s: \"%s\"\n",
1224 oc_map[i].ssom_name, scherr2str(code), err);
1231 ObjectClass ** ocp = (ObjectClass **)
1232 &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
1234 assert( *ocp == NULL );
1236 *ocp = oc_find( oc_map[i].ssom_name );
1237 if( *ocp == NULL ) {
1238 fprintf( stderr, "slap_schema_load: "
1239 "ObjectClass \"%s\": not defined in schema\n",
1240 oc_map[i].ssom_name );
1241 return LDAP_OBJECT_CLASS_VIOLATION;
1244 if( oc_map[i].ssom_check ) {
1245 /* install check routine */
1246 (*ocp)->soc_check = oc_map[i].ssom_check;
1249 (*ocp)->soc_flags |= oc_map[i].ssom_flags;
1253 slap_at_undefined.sat_syntax = slap_schema.si_syn_distinguishedName;
1254 slap_schema.si_at_undefined = &slap_at_undefined;
1256 return LDAP_SUCCESS;
1260 slap_schema_check( void )
1262 /* we should only be called once after schema_init() was called */
1263 assert( schema_init_done == 1 );
1266 * cycle thru attributeTypes to build matchingRuleUse
1268 if ( matching_rule_use_init() ) {
1273 return LDAP_SUCCESS;
1276 static int rootDseObjectClass (
1281 char *textbuf, size_t textlen )
1285 if( e->e_nname.bv_len ) {
1286 snprintf( textbuf, textlen,
1287 "objectClass \"%s\" only allowed in the root DSE",
1289 return LDAP_OBJECT_CLASS_VIOLATION;
1292 /* we should not be called for the root DSE */
1294 return LDAP_SUCCESS;
1297 static int aliasObjectClass (
1302 char *textbuf, size_t textlen )
1306 if( !SLAP_ALIASES(be) ) {
1307 snprintf( textbuf, textlen,
1308 "objectClass \"%s\" not supported in context",
1310 return LDAP_OBJECT_CLASS_VIOLATION;
1313 return LDAP_SUCCESS;
1316 static int referralObjectClass (
1321 char *textbuf, size_t textlen )
1325 if( !SLAP_REFERRALS(be) ) {
1326 snprintf( textbuf, textlen,
1327 "objectClass \"%s\" not supported in context",
1329 return LDAP_OBJECT_CLASS_VIOLATION;
1332 return LDAP_SUCCESS;
1335 static int subentryObjectClass (
1340 char *textbuf, size_t textlen )
1344 if( !SLAP_SUBENTRIES(be) ) {
1345 snprintf( textbuf, textlen,
1346 "objectClass \"%s\" not supported in context",
1348 return LDAP_OBJECT_CLASS_VIOLATION;
1351 if( oc != slap_schema.si_oc_subentry && !is_entry_subentry( e ) ) {
1352 snprintf( textbuf, textlen,
1353 "objectClass \"%s\" only allowed in subentries",
1355 return LDAP_OBJECT_CLASS_VIOLATION;
1358 return LDAP_SUCCESS;
1361 static int dynamicObjectClass (
1366 char *textbuf, size_t textlen )
1370 if( !SLAP_DYNAMIC(be) ) {
1371 snprintf( textbuf, textlen,
1372 "objectClass \"%s\" not supported in context",
1374 return LDAP_OBJECT_CLASS_VIOLATION;
1377 return LDAP_SUCCESS;
1380 static int rootDseAttribute (
1385 char *textbuf, size_t textlen )
1389 if( e->e_nname.bv_len ) {
1390 snprintf( textbuf, textlen,
1391 "attribute \"%s\" only allowed in the root DSE",
1392 attr->a_desc->ad_cname.bv_val );
1393 return LDAP_OBJECT_CLASS_VIOLATION;
1396 /* we should not be called for the root DSE */
1398 return LDAP_SUCCESS;
1401 static int aliasAttribute (
1406 char *textbuf, size_t textlen )
1410 if( !SLAP_ALIASES(be) ) {
1411 snprintf( textbuf, textlen,
1412 "attribute \"%s\" not supported in context",
1413 attr->a_desc->ad_cname.bv_val );
1414 return LDAP_OBJECT_CLASS_VIOLATION;
1417 if( !is_entry_alias( e ) ) {
1418 snprintf( textbuf, textlen,
1419 "attribute \"%s\" only allowed in the alias",
1420 attr->a_desc->ad_cname.bv_val );
1421 return LDAP_OBJECT_CLASS_VIOLATION;
1424 return LDAP_SUCCESS;
1427 static int referralAttribute (
1432 char *textbuf, size_t textlen )
1436 if( !SLAP_REFERRALS(be) ) {
1437 snprintf( textbuf, textlen,
1438 "attribute \"%s\" not supported in context",
1439 attr->a_desc->ad_cname.bv_val );
1440 return LDAP_OBJECT_CLASS_VIOLATION;
1443 if( !is_entry_referral( e ) ) {
1444 snprintf( textbuf, textlen,
1445 "attribute \"%s\" only allowed in the referral",
1446 attr->a_desc->ad_cname.bv_val );
1447 return LDAP_OBJECT_CLASS_VIOLATION;
1450 return LDAP_SUCCESS;
1453 static int subentryAttribute (
1458 char *textbuf, size_t textlen )
1462 if( !SLAP_SUBENTRIES(be) ) {
1463 snprintf( textbuf, textlen,
1464 "attribute \"%s\" not supported in context",
1465 attr->a_desc->ad_cname.bv_val );
1466 return LDAP_OBJECT_CLASS_VIOLATION;
1469 if( !is_entry_subentry( e ) ) {
1470 snprintf( textbuf, textlen,
1471 "attribute \"%s\" only allowed in the subentry",
1472 attr->a_desc->ad_cname.bv_val );
1473 return LDAP_OBJECT_CLASS_VIOLATION;
1476 return LDAP_SUCCESS;
1479 static int administrativeRoleAttribute (
1484 char *textbuf, size_t textlen )
1488 if( !SLAP_SUBENTRIES(be) ) {
1489 snprintf( textbuf, textlen,
1490 "attribute \"%s\" not supported in context",
1491 attr->a_desc->ad_cname.bv_val );
1492 return LDAP_OBJECT_CLASS_VIOLATION;
1495 snprintf( textbuf, textlen,
1496 "attribute \"%s\" not supported!",
1497 attr->a_desc->ad_cname.bv_val );
1498 return LDAP_OBJECT_CLASS_VIOLATION;
1501 static int dynamicAttribute (
1506 char *textbuf, size_t textlen )
1510 if( !SLAP_DYNAMIC(be) ) {
1511 snprintf( textbuf, textlen,
1512 "attribute \"%s\" not supported in context",
1513 attr->a_desc->ad_cname.bv_val );
1514 return LDAP_OBJECT_CLASS_VIOLATION;
1517 if( !is_entry_dynamicObject( e ) ) {
1518 snprintf( textbuf, textlen,
1519 "attribute \"%s\" only allowed in dynamic object",
1520 attr->a_desc->ad_cname.bv_val );
1521 return LDAP_OBJECT_CLASS_VIOLATION;
1524 return LDAP_SUCCESS;