]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_prep.c
need this outside for back monitor ...
[openldap] / servers / slapd / schema_prep.c
index 143d167498fb2d33c5a6412344451460cf20608a..e6572be51039883ff61483c2c15c9c4307ad6a08 100644 (file)
@@ -115,6 +115,9 @@ structuralObjectClassMatch(
        return LDAP_SUCCESS;
 }
 
+static ObjectClassSchemaCheckFN rootDseObjectClass;
+static ObjectClassSchemaCheckFN subentryObjectClass;
+
 static struct slap_schema_oc_map {
        char *ssom_name;
        char *ssom_defn;
@@ -142,24 +145,29 @@ static struct slap_schema_oc_map {
        { "LDAProotDSE", "( 1.3.6.1.4.1.4203.1.4.1 "
                        "NAME ( 'OpenLDAProotDSE' 'LDAProotDSE' ) "
                        "DESC 'OpenLDAP Root DSE object' "
-                       "SUP top STRUCTURAL MAY cn )",
-               0, offsetof(struct slap_internal_schema, si_oc_rootdse) },
+                       "SUP top STRUCTURAL MAY cn )", rootDseObjectClass,
+               offsetof(struct slap_internal_schema, si_oc_rootdse) },
        { "subentry", "( 2.5.20.0 NAME 'subentry' "
                        "SUP top STRUCTURAL "
                        "MUST ( cn $ subtreeSpecification ) )",
                0, offsetof(struct slap_internal_schema, si_oc_subentry) },
        { "subschema", "( 2.5.20.1 NAME 'subschema' "
                "DESC 'RFC2252: controlling subschema (sub)entry' "
-               "AUXILIARY"
+               "AUXILIARY "
                "MAY ( dITStructureRules $ nameForms $ ditContentRules $ "
                        "objectClasses $ attributeTypes $ matchingRules $ "
-                       "matchingRuleUse ) )",
-               0, offsetof(struct slap_internal_schema, si_oc_subschema) },
+                       "matchingRuleUse ) )", subentryObjectClass,
+               offsetof(struct slap_internal_schema, si_oc_subschema) },
        { "collectiveAttributes", "( 2.5.20.2 "
                        "NAME 'collectiveAttributes' "
-                       "AUXILIARY )",
-               0,
+                       "AUXILIARY )", subentryObjectClass,
                offsetof(struct slap_internal_schema, si_oc_collectiveAttributes) },
+       { "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
+                       "NAME 'dynamicObject' "
+                       "DESC 'RFC2589: Dynamic Object' "
+                       "SUP top AUXILIARY )",
+               0,
+               offsetof(struct slap_internal_schema, si_oc_dynamicObject) },
        { NULL, 0 }
 };
 
@@ -577,36 +585,37 @@ slap_schema_load( void )
        }
 
        for( i=0; oc_map[i].ssom_name; i++ ) {
-               LDAPObjectClass *oc;
-               int             code;
-               const char      *err;
-
-               oc = ldap_str2objectclass( oc_map[i].ssom_defn, &code, &err,
-                       LDAP_SCHEMA_ALLOW_ALL );
-               if ( !oc ) {
-                       fprintf( stderr, "slap_schema_load: "
-                               "%s: %s before %s\n",
-                                oc_map[i].ssom_name, ldap_scherr2str(code), err );
-                       return code;
-               }
+               if( oc_map[i].ssom_defn != NULL ) {
+                       LDAPObjectClass *oc;
+                       int             code;
+                       const char      *err;
 
-               if ( oc->oc_oid == NULL ) {
-                       fprintf( stderr, "slap_schema_load: "
-                               "%s: objectclass has no OID\n",
-                               oc_map[i].ssom_name );
-                       return LDAP_OTHER;
-               }
+                       oc = ldap_str2objectclass( oc_map[i].ssom_defn, &code, &err,
+                               LDAP_SCHEMA_ALLOW_ALL );
+                       if ( !oc ) {
+                               fprintf( stderr, "slap_schema_load: "
+                                       "%s: %s before %s\n",
+                                       oc_map[i].ssom_name, ldap_scherr2str(code), err );
+                               return code;
+                       }
 
-               code = oc_add(oc,&err);
-               if ( code ) {
-                       fprintf( stderr, "slap_schema_load: "
-                               "%s: %s: \"%s\"\n",
-                                oc_map[i].ssom_name, scherr2str(code), err);
-                       return code;
-               }
+                       if ( oc->oc_oid == NULL ) {
+                               fprintf( stderr, "slap_schema_load: "
+                                       "%s: objectclass has no OID\n",
+                                       oc_map[i].ssom_name );
+                               return LDAP_OTHER;
+                       }
+
+                       code = oc_add(oc,&err);
+                       if ( code ) {
+                               fprintf( stderr, "slap_schema_load: "
+                                       "%s: %s: \"%s\"\n",
+                                       oc_map[i].ssom_name, scherr2str(code), err);
+                               return code;
+                       }
 
-               ldap_memfree(oc);
-               return 0;
+                       ldap_memfree(oc);
+               }
        }
 
        return LDAP_SUCCESS;
@@ -703,6 +712,40 @@ slap_schema_check( void )
        return LDAP_SUCCESS;
 }
 
+static int rootDseObjectClass (
+       Entry *e,
+       ObjectClass *oc,
+       const char** text,
+       char *textbuf, size_t textlen )
+{
+       *text = textbuf;
+       if( e->e_nname.bv_len ) {
+               snprintf( textbuf, textlen,
+                       "objectClass \"%s\" only allowed in the root DSE",
+                       oc->soc_oid );
+               return LDAP_OBJECT_CLASS_VIOLATION;
+       }
+
+       /* we should not be called for the root DSE */
+       assert( 0 );
+       return LDAP_SUCCESS;
+}
+
+static int subentryObjectClass (
+       Entry *e,
+       ObjectClass *oc,
+       const char** text,
+       char *textbuf, size_t textlen )
+{
+       if( !is_entry_subentry( e ) ) {
+               snprintf( textbuf, textlen,
+                       "objectClass \"%s\" only allowed in subentries",
+                       oc->soc_oid );
+               return LDAP_OBJECT_CLASS_VIOLATION;
+       }
+       return LDAP_SUCCESS;
+}
+
 static int rootDseAttribute (
        Entry *e,
        Attribute *attr,
@@ -712,7 +755,7 @@ static int rootDseAttribute (
        *text = textbuf;
        if( e->e_nname.bv_len ) {
                snprintf( textbuf, textlen,
-                       "attribute \"%s\"only allowed in the root DSE",
+                       "attribute \"%s\" only allowed in the root DSE",
                        attr->a_desc->ad_cname.bv_val );
                return LDAP_OBJECT_CLASS_VIOLATION;
        }
@@ -731,7 +774,7 @@ static int subentryAttribute (
        *text = textbuf;
        if( !is_entry_subentry( e ) ) {
                snprintf( textbuf, textlen,
-                       "attribute \"%s\"only allowed in the subentry",
+                       "attribute \"%s\" only allowed in the subentry",
                        attr->a_desc->ad_cname.bv_val );
                return LDAP_OBJECT_CLASS_VIOLATION;
        }
@@ -748,7 +791,7 @@ static int referralAttribute (
        *text = textbuf;
        if( !is_entry_referral( e ) ) {
                snprintf( textbuf, textlen,
-                       "attribute \"%s\"only allowed in the referral",
+                       "attribute \"%s\" only allowed in the referral",
                        attr->a_desc->ad_cname.bv_val );
                return LDAP_OBJECT_CLASS_VIOLATION;
        }