]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_prep.c
Fix previous commit
[openldap] / servers / slapd / schema_prep.c
index c5929221823dd74359634ba10bb38d0c15df4202..6deb5e38f516191b77a46a25480f7db0bbe36015 100644 (file)
@@ -141,12 +141,12 @@ static struct slap_schema_oc_map {
                        "DESC 'RFC2256: an alias' "
                        "SUP top STRUCTURAL "
                        "MUST aliasedObjectName )",
-               aliasObjectClass, 0,
+               aliasObjectClass, SLAP_OC_ALIAS,
                offsetof(struct slap_internal_schema, si_oc_alias) },
        { "referral", "( 2.16.840.1.113730.3.2.6 NAME 'referral' "
                        "DESC 'namedref: named subordinate referral' "
                        "SUP top STRUCTURAL MUST ref )",
-               referralObjectClass, 0,
+               referralObjectClass, SLAP_OC_REFERRAL,
                offsetof(struct slap_internal_schema, si_oc_referral) },
        { "LDAProotDSE", "( 1.3.6.1.4.1.4203.1.4.1 "
                        "NAME ( 'OpenLDAProotDSE' 'LDAProotDSE' ) "
@@ -157,7 +157,7 @@ static struct slap_schema_oc_map {
        { "subentry", "( 2.5.20.0 NAME 'subentry' "
                        "SUP top STRUCTURAL "
                        "MUST ( cn $ subtreeSpecification ) )",
-               subentryObjectClass, 0,
+               subentryObjectClass, SLAP_OC_SUBENTRY,
                offsetof(struct slap_internal_schema, si_oc_subentry) },
        { "subschema", "( 2.5.20.1 NAME 'subschema' "
                "DESC 'RFC2252: controlling subschema (sub)entry' "
@@ -165,23 +165,23 @@ static struct slap_schema_oc_map {
                "MAY ( dITStructureRules $ nameForms $ ditContentRules $ "
                        "objectClasses $ attributeTypes $ matchingRules $ "
                        "matchingRuleUse ) )",
-               subentryObjectClass,
+               subentryObjectClass, 0,
                offsetof(struct slap_internal_schema, si_oc_subschema) },
        { "monitor", "( 1.3.6.1.4.1.4203.666.3.2 NAME 'monitor' "
                "DESC 'OpenLDAP system monitoring' "
                "STRUCTURAL "
                "MUST cn )",
                0, 0, offsetof(struct slap_internal_schema, si_oc_monitor) },
-       { "collectiveAttributes", "( 2.5.20.2 "
-                       "NAME 'collectiveAttributes' "
+       { "collectiveAttributeSubentry", "( 2.5.20.2 "
+                       "NAME 'collectiveAttributeSubentry' "
                        "AUXILIARY )",
-               subentryObjectClass, 0,
-               offsetof(struct slap_internal_schema, si_oc_collectiveAttributes) },
+               subentryObjectClass, SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY,
+               offsetof(struct slap_internal_schema, si_oc_collectiveAttributeSubentry) },
        { "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
                        "NAME 'dynamicObject' "
                        "DESC 'RFC2589: Dynamic Object' "
                        "SUP top AUXILIARY )",
-               dynamicObjectClass, 0,
+               dynamicObjectClass, SLAP_OC_DYNAMICOBJECT,
                offsetof(struct slap_internal_schema, si_oc_dynamicObject) },
        { NULL, NULL, NULL, 0, 0 }
 };
@@ -190,6 +190,7 @@ static AttributeTypeSchemaCheckFN rootDseAttribute;
 static AttributeTypeSchemaCheckFN aliasAttribute;
 static AttributeTypeSchemaCheckFN referralAttribute;
 static AttributeTypeSchemaCheckFN subentryAttribute;
+static AttributeTypeSchemaCheckFN administrativeRoleAttribute;
 static AttributeTypeSchemaCheckFN dynamicAttribute;
 
 static struct slap_schema_ad_map {
@@ -262,13 +263,13 @@ static struct slap_schema_ad_map {
                        "SINGLE-VALUE USAGE directoryOperation )",
                NULL, 0, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
-       { "collectiveAttributeSubentry", "( 2.5.18.12 "
-                       "NAME 'collectiveAttributeSubentry' "
+       { "collectiveAttributeSubentries", "( 2.5.18.12 "
+                       "NAME 'collectiveAttributeSubentries' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "USAGE directoryOperation NO-USER-MODIFICATION )",
                NULL, 0, NULL, NULL, NULL,
-               offsetof(struct slap_internal_schema, si_ad_collectiveSubentry) },
+               offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
        { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
@@ -357,7 +358,7 @@ static struct slap_schema_ad_map {
                        "EQUALITY objectIdentifierMatch "
                        "USAGE directoryOperation "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
-               NULL, 0, NULL, NULL, NULL,
+               administrativeRoleAttribute, 0, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_administrativeRole) },
        { "subtreeSpecification", "( 2.5.18.6 NAME 'subtreeSpecification' "
                        "SINGLE-VALUE "
@@ -537,8 +538,8 @@ static AttributeType slap_at_undefined = {
        NULL, NULL, NULL, NULL, /* matching rules */
        NULL, /* syntax (this may need to be defined) */
        (AttributeTypeSchemaCheckFN *) 0, 0, /* schema check function/mask */
-       NULL  /* next */
-       NULL, /* attribute description */
+       NULL, /* next */
+       NULL /* attribute description */
        /* mutex (don't know how to initialize it :) */
 };
 
@@ -731,10 +732,10 @@ slap_schema_check( void )
 
                if( oc_map[i].ssom_check ) {
                        /* install check routine */
-                       (*ocp)->sco_check = oc_map[i].ssom_check;
+                       (*ocp)->soc_check = oc_map[i].ssom_check;
                }
                /* install flags */
-               (*ocp)->sco_flags |= oc_map[i].ssom_flags;
+               (*ocp)->soc_flags |= oc_map[i].ssom_flags;
        }
 
        ++schema_init_done;
@@ -944,6 +945,28 @@ static int subentryAttribute (
        return LDAP_SUCCESS;
 }
 
+static int administrativeRoleAttribute (
+       Backend *be,
+       Entry *e,
+       Attribute *attr,
+       const char** text,
+       char *textbuf, size_t textlen )
+{
+       *text = textbuf;
+
+       if( !SLAP_SUBENTRIES(be) ) {
+               snprintf( textbuf, textlen,
+                       "attribute \"%s\" not supported in context",
+                       attr->a_desc->ad_cname.bv_val );
+               return LDAP_OBJECT_CLASS_VIOLATION;
+       }
+
+       snprintf( textbuf, textlen,
+               "attribute \"%s\" not supported!",
+               attr->a_desc->ad_cname.bv_val );
+       return LDAP_OBJECT_CLASS_VIOLATION;
+}
+
 static int dynamicAttribute (
        Backend *be,
        Entry *e,