1 /* schema_prep.c - load builtin schema */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2009 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>
29 int schema_init_done = 0;
31 struct slap_internal_schema slap_schema;
38 struct berval val = *in;
40 if( val.bv_len == 0 ) {
41 /* disallow empty strings */
42 return LDAP_INVALID_SYNTAX;
45 if( DESC_LEADCHAR( val.bv_val[0] ) ) {
48 if ( val.bv_len == 0 ) return LDAP_SUCCESS;
50 while( DESC_CHAR( val.bv_val[0] ) ) {
54 if ( val.bv_len == 0 ) return LDAP_SUCCESS;
59 while( OID_LEADCHAR( val.bv_val[0] ) ) {
63 if ( val.bv_val[-1] != '0' ) {
64 while ( OID_LEADCHAR( val.bv_val[0] )) {
70 if( val.bv_len == 0 ) {
75 if( !OID_SEPARATOR( val.bv_val[0] )) break;
83 return LDAP_INVALID_SYNTAX;
87 static int objectClassPretty(
95 if( oidValidate( NULL, in )) return LDAP_INVALID_SYNTAX;
98 if( oc == NULL ) return LDAP_INVALID_SYNTAX;
100 ber_dupbv_x( out, &oc->soc_cname, ctx );
110 struct berval *value,
111 void *assertedValue )
113 struct berval *a = (struct berval *) assertedValue;
114 AttributeType *at = at_bvfind( value );
115 AttributeType *asserted = at_bvfind( a );
117 if( asserted == NULL ) {
118 if( OID_LEADCHAR( *a->bv_val ) ) {
119 /* OID form, return FALSE */
124 /* desc form, return undefined */
125 return LDAP_INVALID_SYNTAX;
129 /* unrecognized stored value */
130 return LDAP_INVALID_SYNTAX;
133 *matchp = ( asserted != at );
143 struct berval *value,
144 void *assertedValue )
146 struct berval *a = (struct berval *) assertedValue;
147 MatchingRule *mrv = mr_bvfind( value );
148 MatchingRule *asserted = mr_bvfind( a );
150 if( asserted == NULL ) {
151 if( OID_LEADCHAR( *a->bv_val ) ) {
152 /* OID form, return FALSE */
157 /* desc form, return undefined */
158 return LDAP_INVALID_SYNTAX;
162 /* unrecognized stored value */
163 return LDAP_INVALID_SYNTAX;
166 *matchp = ( asserted != mrv );
176 struct berval *value,
177 void *assertedValue )
179 struct berval *a = (struct berval *) assertedValue;
180 ObjectClass *oc = oc_bvfind( value );
181 ObjectClass *asserted = oc_bvfind( a );
183 if( asserted == NULL ) {
184 if( OID_LEADCHAR( *a->bv_val ) ) {
185 /* OID form, return FALSE */
190 /* desc form, return undefined */
191 return LDAP_INVALID_SYNTAX;
195 /* unrecognized stored value */
196 return LDAP_INVALID_SYNTAX;
199 *matchp = ( asserted != oc );
209 struct berval *value,
210 void *assertedValue )
212 struct berval *a = (struct berval *) assertedValue;
213 ObjectClass *oc = oc_bvfind( value );
214 ObjectClass *asserted = oc_bvfind( a );
216 if( asserted == NULL ) {
217 if( OID_LEADCHAR( *a->bv_val ) ) {
218 /* OID form, return FALSE */
223 /* desc form, return undefined */
224 return LDAP_INVALID_SYNTAX;
228 /* unrecognized stored value */
229 return LDAP_INVALID_SYNTAX;
232 if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) {
233 *matchp = ( asserted != oc );
235 *matchp = !is_object_subclass( asserted, oc );
241 static int objectSubClassIndexer(
246 struct berval *prefix,
255 for( noc=0; values[noc].bv_val != NULL; noc++ ) {
260 socs = slap_sl_malloc( (noc+16) * sizeof( ObjectClass * ), ctx );
263 for( i=0; i<noc; i++ ) {
264 socs[i] = oc_bvfind( &values[i] );
268 for( i=0; i<noc; i++ ) {
270 ObjectClass *oc = socs[i];
271 if( oc == NULL || oc->soc_sups == NULL ) continue;
273 for( j=0; oc->soc_sups[j] != NULL; j++ ) {
275 ObjectClass *sup = oc->soc_sups[j];
278 for( k=0; k<noc; k++ ) {
279 if( sup == socs[k] ) {
286 socs = slap_sl_realloc( socs,
287 sizeof( ObjectClass * ) * (noc+2), ctx );
295 ocvalues = slap_sl_malloc( sizeof( struct berval ) * (noc+1), ctx );
297 for( i=0; i<noc; i++ ) {
299 ocvalues[i] = socs[i]->soc_cname;
301 ocvalues[i] = values[i];
303 BER_BVZERO( &ocvalues[i] );
305 rc = octetStringIndexer( use, mask, syntax, mr,
306 prefix, ocvalues, keysp, ctx );
308 slap_sl_free( ocvalues, ctx );
309 slap_sl_free( socs, ctx );
313 #define objectSubClassFilter octetStringFilter
315 static ObjectClassSchemaCheckFN rootDseObjectClass;
316 static ObjectClassSchemaCheckFN aliasObjectClass;
317 static ObjectClassSchemaCheckFN referralObjectClass;
318 static ObjectClassSchemaCheckFN subentryObjectClass;
319 #ifdef LDAP_DYNAMIC_OBJECTS
320 static ObjectClassSchemaCheckFN dynamicObjectClass;
323 static struct slap_schema_oc_map {
326 ObjectClassSchemaCheckFN *ssom_check;
327 slap_mask_t ssom_flags;
330 { "top", "( 2.5.6.0 NAME 'top' "
331 "DESC 'top of the superclass chain' "
332 "ABSTRACT MUST objectClass )",
333 0, 0, offsetof(struct slap_internal_schema, si_oc_top) },
334 { "extensibleObject", "( 1.3.6.1.4.1.1466.101.120.111 "
335 "NAME 'extensibleObject' "
336 "DESC 'RFC4512: extensible object' "
337 "SUP top AUXILIARY )",
338 0, SLAP_OC_OPERATIONAL,
339 offsetof(struct slap_internal_schema, si_oc_extensibleObject) },
340 { "alias", "( 2.5.6.1 NAME 'alias' "
341 "DESC 'RFC4512: an alias' "
342 "SUP top STRUCTURAL "
343 "MUST aliasedObjectName )",
344 aliasObjectClass, SLAP_OC_ALIAS|SLAP_OC_OPERATIONAL,
345 offsetof(struct slap_internal_schema, si_oc_alias) },
346 { "referral", "( 2.16.840.1.113730.3.2.6 NAME 'referral' "
347 "DESC 'namedref: named subordinate referral' "
348 "SUP top STRUCTURAL MUST ref )",
349 referralObjectClass, SLAP_OC_REFERRAL|SLAP_OC_OPERATIONAL,
350 offsetof(struct slap_internal_schema, si_oc_referral) },
351 { "LDAProotDSE", "( 1.3.6.1.4.1.4203.1.4.1 "
352 "NAME ( 'OpenLDAProotDSE' 'LDAProotDSE' ) "
353 "DESC 'OpenLDAP Root DSE object' "
354 "SUP top STRUCTURAL MAY cn )",
355 rootDseObjectClass, SLAP_OC_OPERATIONAL,
356 offsetof(struct slap_internal_schema, si_oc_rootdse) },
357 { "subentry", "( 2.5.17.0 NAME 'subentry' "
358 "DESC 'RFC3672: subentry' "
359 "SUP top STRUCTURAL "
360 "MUST ( cn $ subtreeSpecification ) )",
361 subentryObjectClass, SLAP_OC_SUBENTRY|SLAP_OC_OPERATIONAL,
362 offsetof(struct slap_internal_schema, si_oc_subentry) },
363 { "subschema", "( 2.5.20.1 NAME 'subschema' "
364 "DESC 'RFC4512: controlling subschema (sub)entry' "
366 "MAY ( dITStructureRules $ nameForms $ dITContentRules $ "
367 "objectClasses $ attributeTypes $ matchingRules $ "
368 "matchingRuleUse ) )",
369 subentryObjectClass, SLAP_OC_OPERATIONAL,
370 offsetof(struct slap_internal_schema, si_oc_subschema) },
371 #ifdef LDAP_COLLECTIVE_ATTRIBUTES
372 { "collectiveAttributeSubentry", "( 2.5.17.2 "
373 "NAME 'collectiveAttributeSubentry' "
374 "DESC 'RFC3671: collective attribute subentry' "
377 SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
378 offsetof( struct slap_internal_schema,
379 si_oc_collectiveAttributeSubentry) },
381 #ifdef LDAP_DYNAMIC_OBJECTS
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 #ifdef LDAP_DYNAMIC_OBJECTS
419 static AttributeTypeSchemaCheckFN dynamicAttribute;
422 static struct slap_schema_ad_map {
425 AttributeTypeSchemaCheckFN *ssam_check;
426 slap_mask_t ssam_flags;
427 slap_syntax_validate_func *ssam_syn_validate;
428 slap_syntax_transform_func *ssam_syn_pretty;
429 slap_mr_convert_func *ssam_mr_convert;
430 slap_mr_normalize_func *ssam_mr_normalize;
431 slap_mr_match_func *ssam_mr_match;
432 slap_mr_indexer_func *ssam_mr_indexer;
433 slap_mr_filter_func *ssam_mr_filter;
436 { "objectClass", "( 2.5.4.0 NAME 'objectClass' "
437 "DESC 'RFC4512: object classes of the entity' "
438 "EQUALITY objectIdentifierMatch "
439 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
441 oidValidate, objectClassPretty,
442 NULL, NULL, objectSubClassMatch,
443 objectSubClassIndexer, objectSubClassFilter,
444 offsetof(struct slap_internal_schema, si_ad_objectClass) },
446 /* user entry operational attributes */
447 { "structuralObjectClass", "( 2.5.21.9 NAME 'structuralObjectClass' "
448 "DESC 'RFC4512: structural object class of entry' "
449 "EQUALITY objectIdentifierMatch "
450 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
451 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
453 oidValidate, objectClassPretty,
454 NULL, NULL, objectSubClassMatch,
455 objectSubClassIndexer, objectSubClassFilter,
456 offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
457 { "createTimestamp", "( 2.5.18.1 NAME 'createTimestamp' "
458 "DESC 'RFC4512: time which object was created' "
459 "EQUALITY generalizedTimeMatch "
460 "ORDERING generalizedTimeOrderingMatch "
461 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
462 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
463 NULL, SLAP_AT_MANAGEABLE,
465 NULL, NULL, NULL, NULL, NULL,
466 offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
467 { "modifyTimestamp", "( 2.5.18.2 NAME 'modifyTimestamp' "
468 "DESC 'RFC4512: time which object was last modified' "
469 "EQUALITY generalizedTimeMatch "
470 "ORDERING generalizedTimeOrderingMatch "
471 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
472 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
473 NULL, SLAP_AT_MANAGEABLE,
475 NULL, NULL, NULL, NULL, NULL,
476 offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
477 { "creatorsName", "( 2.5.18.3 NAME 'creatorsName' "
478 "DESC 'RFC4512: name of creator' "
479 "EQUALITY distinguishedNameMatch "
480 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
481 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
482 NULL, SLAP_AT_MANAGEABLE,
484 NULL, NULL, NULL, NULL, NULL,
485 offsetof(struct slap_internal_schema, si_ad_creatorsName) },
486 { "modifiersName", "( 2.5.18.4 NAME 'modifiersName' "
487 "DESC 'RFC4512: name of last modifier' "
488 "EQUALITY distinguishedNameMatch "
489 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
490 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
491 NULL, SLAP_AT_MANAGEABLE,
493 NULL, NULL, NULL, NULL, NULL,
494 offsetof(struct slap_internal_schema, si_ad_modifiersName) },
495 { "hasSubordinates", "( 2.5.18.9 NAME 'hasSubordinates' "
496 "DESC 'X.501: entry has children' "
497 "EQUALITY booleanMatch "
498 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
499 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
500 NULL, SLAP_AT_DYNAMIC,
502 NULL, NULL, NULL, NULL, NULL,
503 offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
504 { "subschemaSubentry", "( 2.5.18.10 NAME 'subschemaSubentry' "
505 "DESC 'RFC4512: name of controlling subschema entry' "
506 "EQUALITY distinguishedNameMatch "
507 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE "
508 "NO-USER-MODIFICATION USAGE directoryOperation )",
509 NULL, SLAP_AT_DYNAMIC,
511 NULL, NULL, NULL, NULL, NULL,
512 offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
513 #ifdef LDAP_COLLECTIVE_ATTRIBUTES
514 { "collectiveAttributeSubentries", "( 2.5.18.12 "
515 "NAME 'collectiveAttributeSubentries' "
516 "DESC 'RFC3671: collective attribute subentries' "
517 "EQUALITY distinguishedNameMatch "
518 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
519 "NO-USER-MODIFICATION USAGE directoryOperation )",
522 NULL, NULL, NULL, NULL, NULL,
523 offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
524 { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
525 "DESC 'RFC3671: collective attribute exclusions' "
526 "EQUALITY objectIdentifierMatch "
527 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
528 "USAGE directoryOperation )",
531 NULL, NULL, NULL, NULL, NULL,
532 offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) },
535 { "entryDN", "( 1.3.6.1.1.20 NAME 'entryDN' "
536 "DESC 'DN of the entry' "
537 "EQUALITY distinguishedNameMatch "
538 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
539 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
540 NULL, SLAP_AT_DYNAMIC,
542 NULL, NULL, NULL, NULL, NULL,
543 offsetof(struct slap_internal_schema, si_ad_entryDN) },
544 { "entryUUID", "( 1.3.6.1.1.16.4 NAME 'entryUUID' "
545 "DESC 'UUID of the entry' "
546 "EQUALITY UUIDMatch "
547 "ORDERING UUIDOrderingMatch "
548 "SYNTAX 1.3.6.1.1.16.1 "
549 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
550 NULL, SLAP_AT_MANAGEABLE,
552 NULL, NULL, NULL, NULL, NULL,
553 offsetof(struct slap_internal_schema, si_ad_entryUUID) },
554 { "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' "
555 "DESC 'change sequence number of the entry content' "
557 "ORDERING CSNOrderingMatch "
558 "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
559 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
562 NULL, NULL, NULL, NULL, NULL,
563 offsetof(struct slap_internal_schema, si_ad_entryCSN) },
564 { "namingCSN", "( 1.3.6.1.4.1.4203.666.1.13 NAME 'namingCSN' "
565 "DESC 'change sequence number of the entry naming (RDN)' "
567 "ORDERING CSNOrderingMatch "
568 "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
569 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
572 NULL, NULL, NULL, NULL, NULL,
573 offsetof(struct slap_internal_schema, si_ad_namingCSN) },
575 #ifdef LDAP_SUPERIOR_UUID
576 { "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "
577 "DESC 'UUID of the superior entry' "
578 "EQUALITY UUIDMatch "
579 "ORDERING UUIDOrderingMatch "
580 "SYNTAX 1.3.6.1.1.16.1 "
581 "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
584 NULL, NULL, NULL, NULL, NULL,
585 offsetof(struct slap_internal_schema, si_ad_superiorUUID) },
588 { "syncreplCookie", "( 1.3.6.1.4.1.4203.666.1.23 "
589 "NAME 'syncreplCookie' "
590 "DESC 'syncrepl Cookie for shadow copy' "
591 "EQUALITY octetStringMatch "
592 "ORDERING octetStringOrderingMatch "
593 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
594 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
597 NULL, NULL, NULL, NULL, NULL,
598 offsetof(struct slap_internal_schema, si_ad_syncreplCookie) },
600 { "contextCSN", "( 1.3.6.1.4.1.4203.666.1.25 "
602 "DESC 'the largest committed CSN of a context' "
604 "ORDERING CSNOrderingMatch "
605 "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
606 "NO-USER-MODIFICATION USAGE dSAOperation )",
609 NULL, NULL, NULL, NULL, NULL,
610 offsetof(struct slap_internal_schema, si_ad_contextCSN) },
612 #ifdef LDAP_SYNC_TIMESTAMP
613 { "syncTimestamp", "( 1.3.6.1.4.1.4203.666.1.26 NAME 'syncTimestamp' "
614 "DESC 'Time which object was replicated' "
615 "EQUALITY generalizedTimeMatch "
616 "ORDERING generalizedTimeOrderingMatch "
617 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
618 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
621 NULL, NULL, NULL, NULL, NULL,
622 offsetof(struct slap_internal_schema, si_ad_syncTimestamp) },
625 /* root DSE attributes */
626 { "altServer", "( 1.3.6.1.4.1.1466.101.120.6 NAME 'altServer' "
627 "DESC 'RFC4512: alternative servers' "
628 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 USAGE dSAOperation )",
631 NULL, NULL, NULL, NULL, NULL,
632 offsetof(struct slap_internal_schema, si_ad_altServer) },
633 { "namingContexts", "( 1.3.6.1.4.1.1466.101.120.5 "
634 "NAME 'namingContexts' "
635 "DESC 'RFC4512: naming contexts' "
636 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 USAGE dSAOperation )",
639 NULL, NULL, NULL, NULL, NULL,
640 offsetof(struct slap_internal_schema, si_ad_namingContexts) },
641 { "supportedControl", "( 1.3.6.1.4.1.1466.101.120.13 "
642 "NAME 'supportedControl' "
643 "DESC 'RFC4512: supported controls' "
644 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
647 NULL, NULL, NULL, NULL, NULL,
648 offsetof(struct slap_internal_schema, si_ad_supportedControl) },
649 { "supportedExtension", "( 1.3.6.1.4.1.1466.101.120.7 "
650 "NAME 'supportedExtension' "
651 "DESC 'RFC4512: supported extended operations' "
652 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
655 NULL, NULL, NULL, NULL, NULL,
656 offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
657 { "supportedLDAPVersion", "( 1.3.6.1.4.1.1466.101.120.15 "
658 "NAME 'supportedLDAPVersion' "
659 "DESC 'RFC4512: supported LDAP versions' "
660 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 USAGE dSAOperation )",
663 NULL, NULL, NULL, NULL, NULL,
664 offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
665 { "supportedSASLMechanisms", "( 1.3.6.1.4.1.1466.101.120.14 "
666 "NAME 'supportedSASLMechanisms' "
667 "DESC 'RFC4512: supported SASL mechanisms'"
668 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE dSAOperation )",
671 NULL, NULL, NULL, NULL, NULL,
672 offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
673 { "supportedFeatures", "( 1.3.6.1.4.1.4203.1.3.5 "
674 "NAME 'supportedFeatures' "
675 "DESC 'RFC4512: features supported by the server' "
676 "EQUALITY objectIdentifierMatch "
677 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
678 "USAGE dSAOperation )",
681 NULL, NULL, NULL, NULL, NULL,
682 offsetof(struct slap_internal_schema, si_ad_supportedFeatures) },
683 { "monitorContext", "( 1.3.6.1.4.1.4203.666.1.10 "
684 "NAME 'monitorContext' "
685 "DESC 'monitor context' "
686 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
687 "EQUALITY distinguishedNameMatch "
688 "SINGLE-VALUE NO-USER-MODIFICATION "
689 "USAGE dSAOperation )",
690 rootDseAttribute, SLAP_AT_HIDE,
692 NULL, NULL, NULL, NULL, NULL,
693 offsetof(struct slap_internal_schema, si_ad_monitorContext) },
694 { "configContext", "( 1.3.6.1.4.1.4203.1.12.2.1 "
695 "NAME 'configContext' "
696 "DESC 'config context' "
697 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
698 "EQUALITY distinguishedNameMatch "
699 "SINGLE-VALUE NO-USER-MODIFICATION "
700 "USAGE dSAOperation )",
701 rootDseAttribute, SLAP_AT_HIDE,
703 NULL, NULL, NULL, NULL, NULL,
704 offsetof(struct slap_internal_schema, si_ad_configContext) },
705 { "vendorName", "( 1.3.6.1.1.4 NAME 'vendorName' "
706 "DESC 'RFC3045: name of implementation vendor' "
707 "EQUALITY caseExactMatch "
708 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
709 "SINGLE-VALUE NO-USER-MODIFICATION "
710 "USAGE dSAOperation )",
713 NULL, NULL, NULL, NULL, NULL,
714 offsetof(struct slap_internal_schema, si_ad_vendorName) },
715 { "vendorVersion", "( 1.3.6.1.1.5 NAME 'vendorVersion' "
716 "DESC 'RFC3045: version of implementation' "
717 "EQUALITY caseExactMatch "
718 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
719 "SINGLE-VALUE NO-USER-MODIFICATION "
720 "USAGE dSAOperation )",
723 NULL, NULL, NULL, NULL, NULL,
724 offsetof(struct slap_internal_schema, si_ad_vendorVersion) },
726 /* subentry attributes */
727 { "administrativeRole", "( 2.5.18.5 NAME 'administrativeRole' "
728 "DESC 'RFC3672: administrative role' "
729 "EQUALITY objectIdentifierMatch "
730 "USAGE directoryOperation "
731 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
732 administrativeRoleAttribute, SLAP_AT_HIDE,
734 NULL, NULL, NULL, NULL, NULL,
735 offsetof(struct slap_internal_schema, si_ad_administrativeRole) },
736 { "subtreeSpecification", "( 2.5.18.6 NAME 'subtreeSpecification' "
737 "DESC 'RFC3672: subtree specification' "
739 "USAGE directoryOperation "
740 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )",
741 subentryAttribute, SLAP_AT_HIDE,
743 NULL, NULL, NULL, NULL, NULL,
744 offsetof(struct slap_internal_schema, si_ad_subtreeSpecification) },
746 /* subschema subentry attributes */
747 { "dITStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
748 "DESC 'RFC4512: DIT structure rules' "
749 "EQUALITY integerFirstComponentMatch "
750 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
751 "USAGE directoryOperation ) ",
752 subentryAttribute, SLAP_AT_HIDE,
754 NULL, NULL, NULL, NULL, NULL,
755 offsetof(struct slap_internal_schema, si_ad_ditStructureRules) },
756 { "dITContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
757 "DESC 'RFC4512: DIT content rules' "
758 "EQUALITY objectIdentifierFirstComponentMatch "
759 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
760 subentryAttribute, SLAP_AT_HIDE,
762 NULL, NULL, objectClassMatch, NULL, NULL,
763 offsetof(struct slap_internal_schema, si_ad_ditContentRules) },
764 { "matchingRules", "( 2.5.21.4 NAME 'matchingRules' "
765 "DESC 'RFC4512: matching rules' "
766 "EQUALITY objectIdentifierFirstComponentMatch "
767 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )",
768 subentryAttribute, 0,
770 NULL, NULL, matchingRuleMatch, NULL, NULL,
771 offsetof(struct slap_internal_schema, si_ad_matchingRules) },
772 { "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' "
773 "DESC 'RFC4512: attribute types' "
774 "EQUALITY objectIdentifierFirstComponentMatch "
775 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )",
776 subentryAttribute, 0,
778 NULL, NULL, attributeTypeMatch, NULL, NULL,
779 offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
780 { "objectClasses", "( 2.5.21.6 NAME 'objectClasses' "
781 "DESC 'RFC4512: object classes' "
782 "EQUALITY objectIdentifierFirstComponentMatch "
783 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )",
784 subentryAttribute, 0,
786 NULL, NULL, objectClassMatch, NULL, NULL,
787 offsetof(struct slap_internal_schema, si_ad_objectClasses) },
788 { "nameForms", "( 2.5.21.7 NAME 'nameForms' "
789 "DESC 'RFC4512: name forms ' "
790 "EQUALITY objectIdentifierFirstComponentMatch "
791 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.35 USAGE directoryOperation )",
792 subentryAttribute, SLAP_AT_HIDE,
794 NULL, NULL, NULL, NULL, NULL,
795 offsetof(struct slap_internal_schema, si_ad_nameForms) },
796 { "matchingRuleUse", "( 2.5.21.8 NAME 'matchingRuleUse' "
797 "DESC 'RFC4512: matching rule uses' "
798 "EQUALITY objectIdentifierFirstComponentMatch "
799 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )",
800 subentryAttribute, 0,
802 NULL, NULL, matchingRuleMatch, NULL, NULL,
803 offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) },
805 { "ldapSyntaxes", "( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' "
806 "DESC 'RFC4512: LDAP syntaxes' "
807 "EQUALITY objectIdentifierFirstComponentMatch "
808 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation )",
809 subentryAttribute, 0,
811 NULL, NULL, NULL, NULL, NULL,
812 offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
814 /* knowledge information */
815 { "aliasedObjectName", "( 2.5.4.1 "
816 "NAME ( 'aliasedObjectName' 'aliasedEntryName' ) "
817 "DESC 'RFC4512: name of aliased object' "
818 "EQUALITY distinguishedNameMatch "
819 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )",
820 aliasAttribute, SLAP_AT_FINAL,
822 NULL, NULL, NULL, NULL, NULL,
823 offsetof(struct slap_internal_schema, si_ad_aliasedObjectName) },
824 { "ref", "( 2.16.840.1.113730.3.1.34 NAME 'ref' "
825 "DESC 'RFC3296: subordinate referral URL' "
826 "EQUALITY caseExactMatch "
827 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
828 "USAGE distributedOperation )",
829 referralAttribute, 0,
831 NULL, NULL, NULL, NULL, NULL,
832 offsetof(struct slap_internal_schema, si_ad_ref) },
834 /* access control internals */
835 { "entry", "( 1.3.6.1.4.1.4203.1.3.1 "
837 "DESC 'OpenLDAP ACL entry pseudo-attribute' "
838 "SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
839 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
842 NULL, NULL, NULL, NULL, NULL,
843 offsetof(struct slap_internal_schema, si_ad_entry) },
844 { "children", "( 1.3.6.1.4.1.4203.1.3.2 "
846 "DESC 'OpenLDAP ACL children pseudo-attribute' "
847 "SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
848 "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
851 NULL, NULL, NULL, NULL, NULL,
852 offsetof(struct slap_internal_schema, si_ad_children) },
854 /* access control externals */
855 { "authzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
856 "NAME ( 'authzTo' 'saslAuthzTo' ) "
857 "DESC 'proxy authorization targets' "
858 "EQUALITY authzMatch "
859 "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
860 "X-ORDERED 'VALUES' "
861 "USAGE distributedOperation )",
864 NULL, NULL, NULL, NULL, NULL,
865 offsetof(struct slap_internal_schema, si_ad_saslAuthzTo) },
866 { "authzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
867 "NAME ( 'authzFrom' 'saslAuthzFrom' ) "
868 "DESC 'proxy authorization sources' "
869 "EQUALITY authzMatch "
870 "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
871 "X-ORDERED 'VALUES' "
872 "USAGE distributedOperation )",
875 NULL, NULL, NULL, NULL, NULL,
876 offsetof(struct slap_internal_schema, si_ad_saslAuthzFrom) },
878 #ifdef LDAP_DYNAMIC_OBJECTS
879 { "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
880 "DESC 'RFC2589: entry time-to-live' "
881 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
882 "NO-USER-MODIFICATION USAGE dSAOperation )",
883 dynamicAttribute, SLAP_AT_MANAGEABLE,
885 NULL, NULL, NULL, NULL, NULL,
886 offsetof(struct slap_internal_schema, si_ad_entryTtl) },
887 { "dynamicSubtrees", "( 1.3.6.1.4.1.1466.101.119.4 "
888 "NAME 'dynamicSubtrees' "
889 "DESC 'RFC2589: dynamic subtrees' "
890 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MODIFICATION "
891 "USAGE dSAOperation )",
894 NULL, NULL, NULL, NULL, NULL,
895 offsetof(struct slap_internal_schema, si_ad_dynamicSubtrees) },
898 /* userApplication attributes (which system schema depends upon) */
899 { "distinguishedName", "( 2.5.4.49 NAME 'distinguishedName' "
900 "DESC 'RFC4519: common supertype of DN attributes' "
901 "EQUALITY distinguishedNameMatch "
902 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
903 NULL, SLAP_AT_ABSTRACT,
905 NULL, NULL, NULL, NULL, NULL,
906 offsetof(struct slap_internal_schema, si_ad_distinguishedName) },
907 { "name", "( 2.5.4.41 NAME 'name' "
908 "DESC 'RFC4519: common supertype of name attributes' "
909 "EQUALITY caseIgnoreMatch "
910 "SUBSTR caseIgnoreSubstringsMatch "
911 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )",
912 NULL, SLAP_AT_ABSTRACT,
914 NULL, NULL, NULL, NULL, NULL,
915 offsetof(struct slap_internal_schema, si_ad_name) },
916 { "cn", "( 2.5.4.3 NAME ( 'cn' 'commonName' ) "
917 "DESC 'RFC4519: common name(s) for which the entity is known by' "
921 NULL, NULL, NULL, NULL, NULL,
922 offsetof(struct slap_internal_schema, si_ad_cn) },
923 { "uid", "( 0.9.2342.19200300.100.1.1 NAME ( 'uid' 'userid' ) "
924 "DESC 'RFC4519: user identifier' "
925 "EQUALITY caseIgnoreMatch "
926 "SUBSTR caseIgnoreSubstringsMatch "
927 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} )",
930 NULL, NULL, NULL, NULL, NULL,
931 offsetof(struct slap_internal_schema, si_ad_uid) },
932 { "uidNumber", /* for ldapi:// */
933 "( 1.3.6.1.1.1.1.0 NAME 'uidNumber' "
934 "DESC 'RFC2307: An integer uniquely identifying a user "
935 "in an administrative domain' "
936 "EQUALITY integerMatch "
937 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
940 NULL, NULL, NULL, NULL, NULL,
941 offsetof(struct slap_internal_schema, si_ad_uidNumber) },
942 { "gidNumber", /* for ldapi:// */
943 "( 1.3.6.1.1.1.1.1 NAME 'gidNumber' "
944 "DESC 'RFC2307: An integer uniquely identifying a group "
945 "in an administrative domain' "
946 "EQUALITY integerMatch "
947 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
950 NULL, NULL, NULL, NULL, NULL,
951 offsetof(struct slap_internal_schema, si_ad_gidNumber) },
952 { "userPassword", "( 2.5.4.35 NAME 'userPassword' "
953 "DESC 'RFC4519/2307: password of user' "
954 "EQUALITY octetStringMatch "
955 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )",
958 NULL, NULL, NULL, NULL, NULL,
959 offsetof(struct slap_internal_schema, si_ad_userPassword) },
961 { "labeledURI", "( 1.3.6.1.4.1.250.1.57 NAME 'labeledURI' "
962 "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
963 "EQUALITY caseExactMatch "
964 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
967 NULL, NULL, NULL, NULL, NULL,
968 offsetof(struct slap_internal_schema, si_ad_labeledURI) },
970 #ifdef SLAPD_AUTHPASSWD
971 { "authPassword", "( 1.3.6.1.4.1.4203.1.3.4 "
972 "NAME 'authPassword' "
973 "DESC 'RFC3112: authentication password attribute' "
974 "EQUALITY 1.3.6.1.4.1.4203.1.2.2 "
975 "SYNTAX 1.3.6.1.4.1.4203.1.1.2 )",
978 NULL, NULL, NULL, NULL, NULL,
979 offsetof(struct slap_internal_schema, si_ad_authPassword) },
980 { "supportedAuthPasswordSchemes", "( 1.3.6.1.4.1.4203.1.3.3 "
981 "NAME 'supportedAuthPasswordSchemes' "
982 "DESC 'RFC3112: supported authPassword schemes' "
983 "EQUALITY caseExactIA5Match "
984 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} "
985 "USAGE dSAOperation )",
986 subschemaAttribute, 0,
988 NULL, NULL, NULL, NULL, NULL,
989 offsetof(struct slap_internal_schema, si_ad_authPasswordSchemes) },
992 { "description", "( 2.5.4.13 NAME 'description' "
993 "DESC 'RFC4519: descriptive information' "
994 "EQUALITY caseIgnoreMatch "
995 "SUBSTR caseIgnoreSubstringsMatch "
996 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )",
999 NULL, NULL, NULL, NULL, NULL,
1000 offsetof(struct slap_internal_schema, si_ad_description) },
1002 { "seeAlso", "( 2.5.4.34 NAME 'seeAlso' "
1003 "DESC 'RFC4519: DN of related object' "
1004 "SUP distinguishedName )",
1007 NULL, NULL, NULL, NULL, NULL,
1008 offsetof(struct slap_internal_schema, si_ad_seeAlso) },
1010 { NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 }
1013 static AttributeType slap_at_undefined = {
1014 { "1.1.1", NULL, "Catchall for undefined attribute types", 1, NULL,
1015 NULL, NULL, NULL, NULL,
1016 0, 0, 0, 1, LDAP_SCHEMA_DSA_OPERATION, NULL }, /* LDAPAttributeType */
1017 BER_BVC("UNDEFINED"), /* cname */
1019 NULL, /* subtypes */
1020 NULL, NULL, NULL, NULL, /* matching rules routines */
1021 NULL, /* syntax (will be set later to "octetString") */
1022 NULL, /* schema check function */
1023 NULL, /* oidmacro */
1024 NULL, /* soidmacro */
1025 SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
1026 { NULL }, /* next */
1027 NULL /* attribute description */
1028 /* mutex (don't know how to initialize it :) */
1031 static AttributeType slap_at_proxied = {
1032 { "1.1.1", NULL, "Catchall for undefined proxied attribute types", 1, NULL,
1033 NULL, NULL, NULL, NULL,
1034 0, 0, 0, 0, LDAP_SCHEMA_USER_APPLICATIONS, NULL }, /* LDAPAttributeType */
1035 BER_BVC("PROXIED"), /* cname */
1037 NULL, /* subtypes */
1038 NULL, NULL, NULL, NULL, /* matching rules routines (will be set later) */
1039 NULL, /* syntax (will be set later to "octetString") */
1040 NULL, /* schema check function */
1041 NULL, /* oidmacro */
1042 NULL, /* soidmacro */
1043 SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
1044 { NULL }, /* next */
1045 NULL /* attribute description */
1046 /* mutex (don't know how to initialize it :) */
1049 static struct slap_schema_mr_map {
1053 { "caseExactIA5Match",
1054 offsetof(struct slap_internal_schema, si_mr_caseExactIA5Match) },
1056 offsetof(struct slap_internal_schema, si_mr_caseExactMatch) },
1057 { "caseExactSubstringsMatch",
1058 offsetof(struct slap_internal_schema, si_mr_caseExactSubstringsMatch) },
1059 { "distinguishedNameMatch",
1060 offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) },
1062 offsetof(struct slap_internal_schema, si_mr_dnSubtreeMatch) },
1063 { "dnOneLevelMatch",
1064 offsetof(struct slap_internal_schema, si_mr_dnOneLevelMatch) },
1065 { "dnSubordinateMatch",
1066 offsetof(struct slap_internal_schema, si_mr_dnSubordinateMatch) },
1067 { "dnSuperiorMatch",
1068 offsetof(struct slap_internal_schema, si_mr_dnSuperiorMatch) },
1070 offsetof(struct slap_internal_schema, si_mr_integerMatch) },
1071 { "integerFirstComponentMatch",
1072 offsetof(struct slap_internal_schema,
1073 si_mr_integerFirstComponentMatch) },
1074 { "objectIdentifierFirstComponentMatch",
1075 offsetof(struct slap_internal_schema,
1076 si_mr_objectIdentifierFirstComponentMatch) },
1077 { "caseIgnoreMatch",
1078 offsetof(struct slap_internal_schema, si_mr_caseIgnoreMatch) },
1079 { "caseIgnoreListMatch",
1080 offsetof(struct slap_internal_schema, si_mr_caseIgnoreListMatch) },
1084 static struct slap_schema_syn_map {
1088 { "1.3.6.1.4.1.1466.115.121.1.15",
1089 offsetof(struct slap_internal_schema, si_syn_directoryString) },
1090 { "1.3.6.1.4.1.1466.115.121.1.12",
1091 offsetof(struct slap_internal_schema, si_syn_distinguishedName) },
1092 { "1.3.6.1.4.1.1466.115.121.1.27",
1093 offsetof(struct slap_internal_schema, si_syn_integer) },
1094 { "1.3.6.1.4.1.1466.115.121.1.40",
1095 offsetof(struct slap_internal_schema, si_syn_octetString) },
1096 { "1.3.6.1.4.1.1466.115.121.1.3",
1097 offsetof(struct slap_internal_schema, si_syn_attributeTypeDesc) },
1098 { "1.3.6.1.4.1.1466.115.121.1.16",
1099 offsetof(struct slap_internal_schema, si_syn_ditContentRuleDesc) },
1100 { "1.3.6.1.4.1.1466.115.121.1.54",
1101 offsetof(struct slap_internal_schema, si_syn_ldapSyntaxDesc) },
1102 { "1.3.6.1.4.1.1466.115.121.1.30",
1103 offsetof(struct slap_internal_schema, si_syn_matchingRuleDesc) },
1104 { "1.3.6.1.4.1.1466.115.121.1.31",
1105 offsetof(struct slap_internal_schema, si_syn_matchingRuleUseDesc) },
1106 { "1.3.6.1.4.1.1466.115.121.1.35",
1107 offsetof(struct slap_internal_schema, si_syn_nameFormDesc) },
1108 { "1.3.6.1.4.1.1466.115.121.1.37",
1109 offsetof(struct slap_internal_schema, si_syn_objectClassDesc) },
1110 { "1.3.6.1.4.1.1466.115.121.1.17",
1111 offsetof(struct slap_internal_schema, si_syn_ditStructureRuleDesc) },
1116 slap_schema_load( void )
1120 for( i=0; syn_map[i].sssm_name; i++ ) {
1121 Syntax ** synp = (Syntax **)
1122 &(((char *) &slap_schema)[syn_map[i].sssm_offset]);
1124 assert( *synp == NULL );
1126 *synp = syn_find( syn_map[i].sssm_name );
1128 if( *synp == NULL ) {
1129 fprintf( stderr, "slap_schema_load: Syntax: "
1130 "No syntax \"%s\" defined in schema\n",
1131 syn_map[i].sssm_name );
1132 return LDAP_INVALID_SYNTAX;
1136 for( i=0; mr_map[i].ssmm_name; i++ ) {
1137 MatchingRule ** mrp = (MatchingRule **)
1138 &(((char *) &slap_schema)[mr_map[i].ssmm_offset]);
1140 assert( *mrp == NULL );
1142 *mrp = mr_find( mr_map[i].ssmm_name );
1144 if( *mrp == NULL ) {
1145 fprintf( stderr, "slap_schema_load: MatchingRule: "
1146 "No matching rule \"%s\" defined in schema\n",
1147 mr_map[i].ssmm_name );
1148 return LDAP_INAPPROPRIATE_MATCHING;
1152 slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
1153 slap_schema.si_at_undefined = &slap_at_undefined;
1155 slap_at_proxied.sat_equality = mr_find( "octetStringMatch" );
1156 slap_at_proxied.sat_approx = mr_find( "octetStringMatch" );
1157 slap_at_proxied.sat_ordering = mr_find( "octetStringOrderingMatch" );
1158 slap_at_proxied.sat_substr = mr_find( "octetStringSubstringsMatch" );
1159 slap_at_proxied.sat_syntax = slap_schema.si_syn_octetString;
1160 slap_schema.si_at_proxied = &slap_at_proxied;
1162 ldap_pvt_thread_mutex_init( &ad_undef_mutex );
1163 ldap_pvt_thread_mutex_init( &oc_undef_mutex );
1165 for( i=0; ad_map[i].ssam_name; i++ ) {
1166 assert( ad_map[i].ssam_defn != NULL );
1168 LDAPAttributeType *at;
1172 at = ldap_str2attributetype( ad_map[i].ssam_defn,
1173 &code, &err, LDAP_SCHEMA_ALLOW_ALL );
1176 "slap_schema_load: AttributeType \"%s\": %s before %s\n",
1177 ad_map[i].ssam_name, ldap_scherr2str(code), err );
1181 if ( at->at_oid == NULL ) {
1182 fprintf( stderr, "slap_schema_load: "
1183 "AttributeType \"%s\": no OID\n",
1184 ad_map[i].ssam_name );
1185 ldap_attributetype_free( at );
1189 code = at_add( at, 0, NULL, NULL, &err );
1191 ldap_attributetype_free( at );
1192 fprintf( stderr, "slap_schema_load: AttributeType "
1193 "\"%s\": %s: \"%s\"\n",
1194 ad_map[i].ssam_name, scherr2str(code), err );
1202 Syntax *syntax = NULL;
1204 AttributeDescription ** adp = (AttributeDescription **)
1205 &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
1207 assert( *adp == NULL );
1209 rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
1210 if( rc != LDAP_SUCCESS ) {
1211 fprintf( stderr, "slap_schema_load: AttributeType \"%s\": "
1212 "not defined in schema\n",
1213 ad_map[i].ssam_name );
1217 if( ad_map[i].ssam_check ) {
1218 /* install check routine */
1219 (*adp)->ad_type->sat_check = ad_map[i].ssam_check;
1222 (*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags;
1224 /* install custom syntax routines */
1225 if( ad_map[i].ssam_syn_validate ||
1226 ad_map[i].ssam_syn_pretty )
1230 syntax = (*adp)->ad_type->sat_syntax;
1232 syn = ch_malloc( sizeof( Syntax ) );
1235 if( ad_map[i].ssam_syn_validate ) {
1236 syn->ssyn_validate = ad_map[i].ssam_syn_validate;
1238 if( ad_map[i].ssam_syn_pretty ) {
1239 syn->ssyn_pretty = ad_map[i].ssam_syn_pretty;
1242 (*adp)->ad_type->sat_syntax = syn;
1245 /* install custom rule routines */
1246 if( syntax != NULL ||
1247 ad_map[i].ssam_mr_convert ||
1248 ad_map[i].ssam_mr_normalize ||
1249 ad_map[i].ssam_mr_match ||
1250 ad_map[i].ssam_mr_indexer ||
1251 ad_map[i].ssam_mr_filter )
1253 MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
1254 *mr = *(*adp)->ad_type->sat_equality;
1256 if ( syntax != NULL ) {
1257 mr->smr_syntax = (*adp)->ad_type->sat_syntax;
1259 if ( ad_map[i].ssam_mr_convert ) {
1260 mr->smr_convert = ad_map[i].ssam_mr_convert;
1262 if ( ad_map[i].ssam_mr_normalize ) {
1263 mr->smr_normalize = ad_map[i].ssam_mr_normalize;
1265 if ( ad_map[i].ssam_mr_match ) {
1266 mr->smr_match = ad_map[i].ssam_mr_match;
1268 if ( ad_map[i].ssam_mr_indexer ) {
1269 mr->smr_indexer = ad_map[i].ssam_mr_indexer;
1271 if ( ad_map[i].ssam_mr_filter ) {
1272 mr->smr_filter = ad_map[i].ssam_mr_filter;
1275 (*adp)->ad_type->sat_equality = mr;
1280 for( i=0; oc_map[i].ssom_name; i++ ) {
1281 assert( oc_map[i].ssom_defn != NULL );
1283 LDAPObjectClass *oc;
1287 oc = ldap_str2objectclass( oc_map[i].ssom_defn, &code, &err,
1288 LDAP_SCHEMA_ALLOW_ALL );
1290 fprintf( stderr, "slap_schema_load: ObjectClass "
1291 "\"%s\": %s before %s\n",
1292 oc_map[i].ssom_name, ldap_scherr2str(code), err );
1296 if ( oc->oc_oid == NULL ) {
1297 fprintf( stderr, "slap_schema_load: ObjectClass "
1299 oc_map[i].ssom_name );
1300 ldap_objectclass_free( oc );
1304 code = oc_add(oc,0,NULL,NULL,&err);
1306 ldap_objectclass_free( oc );
1307 fprintf( stderr, "slap_schema_load: ObjectClass "
1308 "\"%s\": %s: \"%s\"\n",
1309 oc_map[i].ssom_name, scherr2str(code), err);
1316 ObjectClass ** ocp = (ObjectClass **)
1317 &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
1319 assert( *ocp == NULL );
1321 *ocp = oc_find( oc_map[i].ssom_name );
1322 if( *ocp == NULL ) {
1323 fprintf( stderr, "slap_schema_load: "
1324 "ObjectClass \"%s\": not defined in schema\n",
1325 oc_map[i].ssom_name );
1326 return LDAP_OBJECT_CLASS_VIOLATION;
1329 if( oc_map[i].ssom_check ) {
1330 /* install check routine */
1331 (*ocp)->soc_check = oc_map[i].ssom_check;
1334 (*ocp)->soc_flags |= oc_map[i].ssom_flags;
1338 return LDAP_SUCCESS;
1342 slap_schema_check( void )
1344 /* we should only be called once after schema_init() was called */
1345 assert( schema_init_done == 1 );
1348 * cycle thru attributeTypes to build matchingRuleUse
1350 if ( matching_rule_use_init() ) {
1355 return LDAP_SUCCESS;
1358 static int rootDseObjectClass (
1363 char *textbuf, size_t textlen )
1367 if( e->e_nname.bv_len ) {
1368 snprintf( textbuf, textlen,
1369 "objectClass \"%s\" only allowed in the root DSE",
1371 return LDAP_OBJECT_CLASS_VIOLATION;
1374 /* we should not be called for the root DSE */
1376 return LDAP_SUCCESS;
1379 static int aliasObjectClass (
1384 char *textbuf, size_t textlen )
1388 if( !SLAP_ALIASES(be) ) {
1389 snprintf( textbuf, textlen,
1390 "objectClass \"%s\" not supported in context",
1392 return LDAP_OBJECT_CLASS_VIOLATION;
1395 return LDAP_SUCCESS;
1398 static int referralObjectClass (
1403 char *textbuf, size_t textlen )
1407 if( !SLAP_REFERRALS(be) ) {
1408 snprintf( textbuf, textlen,
1409 "objectClass \"%s\" not supported in context",
1411 return LDAP_OBJECT_CLASS_VIOLATION;
1414 return LDAP_SUCCESS;
1417 static int subentryObjectClass (
1422 char *textbuf, size_t textlen )
1426 if( !SLAP_SUBENTRIES(be) ) {
1427 snprintf( textbuf, textlen,
1428 "objectClass \"%s\" not supported in context",
1430 return LDAP_OBJECT_CLASS_VIOLATION;
1433 if( oc != slap_schema.si_oc_subentry && !is_entry_subentry( e ) ) {
1434 snprintf( textbuf, textlen,
1435 "objectClass \"%s\" only allowed in subentries",
1437 return LDAP_OBJECT_CLASS_VIOLATION;
1440 return LDAP_SUCCESS;
1443 #ifdef LDAP_DYNAMIC_OBJECTS
1444 static int dynamicObjectClass (
1449 char *textbuf, size_t textlen )
1453 if( !SLAP_DYNAMIC(be) ) {
1454 snprintf( textbuf, textlen,
1455 "objectClass \"%s\" not supported in context",
1457 return LDAP_OBJECT_CLASS_VIOLATION;
1460 return LDAP_SUCCESS;
1462 #endif /* LDAP_DYNAMIC_OBJECTS */
1464 static int rootDseAttribute (
1469 char *textbuf, size_t textlen )
1473 if( e->e_nname.bv_len ) {
1474 snprintf( textbuf, textlen,
1475 "attribute \"%s\" only allowed in the root DSE",
1476 attr->a_desc->ad_cname.bv_val );
1477 return LDAP_OBJECT_CLASS_VIOLATION;
1480 /* we should not be called for the root DSE */
1482 return LDAP_SUCCESS;
1485 static int aliasAttribute (
1490 char *textbuf, size_t textlen )
1494 if( !SLAP_ALIASES(be) ) {
1495 snprintf( textbuf, textlen,
1496 "attribute \"%s\" not supported in context",
1497 attr->a_desc->ad_cname.bv_val );
1498 return LDAP_OBJECT_CLASS_VIOLATION;
1501 if( !is_entry_alias( e ) ) {
1502 snprintf( textbuf, textlen,
1503 "attribute \"%s\" only allowed in the alias",
1504 attr->a_desc->ad_cname.bv_val );
1505 return LDAP_OBJECT_CLASS_VIOLATION;
1508 return LDAP_SUCCESS;
1511 static int referralAttribute (
1516 char *textbuf, size_t textlen )
1520 if( !SLAP_REFERRALS(be) ) {
1521 snprintf( textbuf, textlen,
1522 "attribute \"%s\" not supported in context",
1523 attr->a_desc->ad_cname.bv_val );
1524 return LDAP_OBJECT_CLASS_VIOLATION;
1527 if( !is_entry_referral( e ) ) {
1528 snprintf( textbuf, textlen,
1529 "attribute \"%s\" only allowed in the referral",
1530 attr->a_desc->ad_cname.bv_val );
1531 return LDAP_OBJECT_CLASS_VIOLATION;
1534 return LDAP_SUCCESS;
1537 static int subentryAttribute (
1542 char *textbuf, size_t textlen )
1546 if( !SLAP_SUBENTRIES(be) ) {
1547 snprintf( textbuf, textlen,
1548 "attribute \"%s\" not supported in context",
1549 attr->a_desc->ad_cname.bv_val );
1550 return LDAP_OBJECT_CLASS_VIOLATION;
1553 if( !is_entry_subentry( e ) ) {
1554 snprintf( textbuf, textlen,
1555 "attribute \"%s\" only allowed in the subentry",
1556 attr->a_desc->ad_cname.bv_val );
1557 return LDAP_OBJECT_CLASS_VIOLATION;
1560 return LDAP_SUCCESS;
1563 static int administrativeRoleAttribute (
1568 char *textbuf, size_t textlen )
1572 if( !SLAP_SUBENTRIES(be) ) {
1573 snprintf( textbuf, textlen,
1574 "attribute \"%s\" not supported in context",
1575 attr->a_desc->ad_cname.bv_val );
1576 return LDAP_OBJECT_CLASS_VIOLATION;
1579 snprintf( textbuf, textlen,
1580 "attribute \"%s\" not supported!",
1581 attr->a_desc->ad_cname.bv_val );
1582 return LDAP_OBJECT_CLASS_VIOLATION;
1585 #ifdef LDAP_DYNAMIC_OBJECTS
1586 static int dynamicAttribute (
1591 char *textbuf, size_t textlen )
1595 if( !SLAP_DYNAMIC(be) ) {
1596 snprintf( textbuf, textlen,
1597 "attribute \"%s\" not supported in context",
1598 attr->a_desc->ad_cname.bv_val );
1599 return LDAP_OBJECT_CLASS_VIOLATION;
1602 if( !is_entry_dynamicObject( e ) ) {
1603 snprintf( textbuf, textlen,
1604 "attribute \"%s\" only allowed in dynamic object",
1605 attr->a_desc->ad_cname.bv_val );
1606 return LDAP_OBJECT_CLASS_VIOLATION;
1609 return LDAP_SUCCESS;
1611 #endif /* LDAP_DYNAMIC_OBJECTS */