]> git.sur5r.net Git - openldap/commitdiff
Patch slapadd(8) to provide a structuralObjectClass if missing
authorKurt Zeilenga <kurt@openldap.org>
Wed, 19 Dec 2001 22:41:00 +0000 (22:41 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 19 Dec 2001 22:41:00 +0000 (22:41 +0000)
from input.  This likely needs to be done by the frontend instead.
Add structuralObjectClass to the root and subschema dses.

servers/slapd/root_dse.c
servers/slapd/schema.c
servers/slapd/schema_check.c
servers/slapd/tools/slapadd.c

index 61de132c3a1728e436b24204e2b306716963f8c4..6ed03ab09fe086141f11aee76f790e787dc9737e 100644 (file)
@@ -39,14 +39,24 @@ root_dse_info(
        int             i, j;
        char ** supportedSASLMechanisms;
 
-       AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
-       AttributeDescription *ad_namingContexts = slap_schema.si_ad_namingContexts;
-       AttributeDescription *ad_supportedControl = slap_schema.si_ad_supportedControl;
-       AttributeDescription *ad_supportedExtension = slap_schema.si_ad_supportedExtension;
-       AttributeDescription *ad_supportedLDAPVersion = slap_schema.si_ad_supportedLDAPVersion;
-       AttributeDescription *ad_supportedSASLMechanisms = slap_schema.si_ad_supportedSASLMechanisms;
-       AttributeDescription *ad_supportedFeatures = slap_schema.si_ad_supportedFeatures;
-       AttributeDescription *ad_ref = slap_schema.si_ad_ref;
+       AttributeDescription *ad_structuralObjectClass
+               = slap_schema.si_ad_structuralObjectClass;
+       AttributeDescription *ad_objectClass
+               = slap_schema.si_ad_objectClass;
+       AttributeDescription *ad_namingContexts
+               = slap_schema.si_ad_namingContexts;
+       AttributeDescription *ad_supportedControl
+               = slap_schema.si_ad_supportedControl;
+       AttributeDescription *ad_supportedExtension
+               = slap_schema.si_ad_supportedExtension;
+       AttributeDescription *ad_supportedLDAPVersion
+               = slap_schema.si_ad_supportedLDAPVersion;
+       AttributeDescription *ad_supportedSASLMechanisms
+               = slap_schema.si_ad_supportedSASLMechanisms;
+       AttributeDescription *ad_supportedFeatures
+               = slap_schema.si_ad_supportedFeatures;
+       AttributeDescription *ad_ref
+               = slap_schema.si_ad_ref;
 
        Attribute *a;
 
@@ -61,6 +71,10 @@ root_dse_info(
        (void) dn_normalize( e->e_ndn );
        e->e_private = NULL;
 
+       val.bv_val = "OpenLDAProotDSE";
+       val.bv_len = sizeof("OpenLDAProotDSE")-1;
+       attr_merge( e, ad_structuralObjectClass, vals );
+
        val.bv_val = "top";
        val.bv_len = sizeof("top")-1;
        attr_merge( e, ad_objectClass, vals );
index f56ca4deffbdc1fe0e6aa4924258810e20f3784f..f28c99161e74fd225600d9a167d680201d0eb3c0 100644 (file)
 int
 schema_info( Entry **entry, const char **text )
 {
-       AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
+       AttributeDescription *ad_structuralObjectClass
+               = slap_schema.si_ad_structuralObjectClass;
+       AttributeDescription *ad_objectClass
+               = slap_schema.si_ad_objectClass;
 
        Entry           *e;
        struct berval   val;
@@ -39,6 +42,10 @@ schema_info( Entry **entry, const char **text )
        (void) dn_normalize( e->e_ndn );
        e->e_private = NULL;
 
+       val.bv_val = "LDAPsubentry";
+       val.bv_len = sizeof("LDAPsubentry")-1;
+       attr_merge( e, ad_structuralObjectClass, vals );
+
        val.bv_val = "top";
        val.bv_len = sizeof("top")-1;
        attr_merge( e, ad_objectClass, vals );
index d8ae713294edae9bfab29359f1b02eabc1cafe28..2306eecfe6606bf433d07acc8775f2b87708ebf1 100644 (file)
@@ -24,7 +24,7 @@ static char * oc_check_required(
 /*
  * Determine the structural object class from a set of OIDs
  */
-static int structural_class(
+int structural_class(
        struct berval **ocs,
        struct berval *scbv,
        const char **text )
@@ -157,7 +157,6 @@ entry_schema_check(
 
        if( !global_schemacheck ) return LDAP_SUCCESS;
 
-#if 1
        /* find the object class attribute - could error out here */
        asc = attr_find( e->e_attrs, ad_structuralObjectClass );
        if ( asc == NULL ) {
@@ -215,7 +214,6 @@ entry_schema_check(
 
                return LDAP_OBJECT_CLASS_VIOLATION;
        }
-#endif
 
        /* find the object class attribute */
        aoc = attr_find( e->e_attrs, ad_objectClass );
index 65923fcae505320f4da661f805a0d22f14e375b9..099033ac3bde01f59f5607dff46c54480825db54 100644 (file)
@@ -81,8 +81,7 @@ main( int argc, char **argv )
                }
 
                /* check backend */
-               if( select_backend( e->e_ndn, is_entry_referral(e), nosubs ) != be )
-               {
+               if( select_backend( e->e_ndn, is_entry_referral(e), nosubs ) != be ) {
                        fprintf( stderr, "%s: database (%s) not configured to "
                                "hold dn=\"%s\" (line=%d)\n",
                                progname,
@@ -94,6 +93,45 @@ main( int argc, char **argv )
                        break;
                }
 
+               {
+                       Attribute *sc = attr_find( e->e_attrs,
+                               slap_schema.si_ad_structuralObjectClass );
+                       Attribute *oc = attr_find( e->e_attrs,
+                               slap_schema.si_ad_objectClass );
+
+                       if( oc == NULL ) {
+                               fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n",
+                                       progname, e->e_dn, lineno,
+                                       "no objectClass attribute");
+                               rc = EXIT_FAILURE;
+                               entry_free( e );
+                               if( continuemode ) continue;
+                               break;
+                       }
+
+                       if( sc == NULL ) {
+                               struct berval *vals[2];
+                               struct berval scbv;
+                               const char *text;
+                               int ret = structural_class(
+                                       oc->a_vals, &scbv, &text );
+
+                               if( scbv.bv_len == 0 ) {
+                                       fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n",
+                                       progname, e->e_dn, lineno, text );
+                                       rc = EXIT_FAILURE;
+                                       entry_free( e );
+                                       if( continuemode ) continue;
+                                       break;
+                               }
+
+                               vals[0] = &scbv;
+                               vals[1] = NULL;
+                               attr_merge( e, slap_schema.si_ad_structuralObjectClass,
+                                       vals );
+                       }
+               }
+
                if( global_schemacheck ) {
                        /* check schema */
                        const char *text;