]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_check.c
remove dbenv->lock_put() call from transaction-protected operations
[openldap] / servers / slapd / schema_check.c
index dc5842c187d05908bc58a6207effa31193479746..405a47e54801f9fdccd0930b18bc941ded277171 100644 (file)
@@ -45,11 +45,17 @@ entry_schema_check(
        AttributeDescription *ad_objectClass
                = slap_schema.si_ad_objectClass;
        int extensible = 0;
+       int subentry = is_entry_subentry( e );
+       int collectiveSubentry = 0;
+
+       if( subentry) collectiveSubentry = is_entry_collectiveAttributeSubentry( e );
 
        *text = textbuf;
 
        /* misc attribute checks */
        for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
+               const char *type = a->a_desc->ad_cname.bv_val;
+
                /* there should be at least one value */
                assert( a->a_vals );
                assert( a->a_vals[0].bv_val != NULL ); 
@@ -62,12 +68,17 @@ entry_schema_check(
                        }
                }
 
+               if( !collectiveSubentry && is_at_collective( a->a_desc->ad_type ) ) {
+                       snprintf( textbuf, textlen,
+                               "'%s' can only appear in collectiveAttributeSubentry",
+                               type );
+                       return LDAP_OBJECT_CLASS_VIOLATION;
+               }
+
                /* if single value type, check for multiple values */
                if( is_at_single_value( a->a_desc->ad_type ) &&
                        a->a_vals[1].bv_val != NULL )
                {
-                       char *type = a->a_desc->ad_cname.bv_val;
-
                        snprintf( textbuf, textlen, 
                                "attribute '%s' cannot have multiple values",
                                type );
@@ -152,7 +163,7 @@ entry_schema_check(
        if ( aoc == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
-                       "entry_schema_check: No objectClass for entry (%s).\n"
+                       "entry_schema_check: No objectClass for entry (%s).\n",
                        e->e_dn ));
 #else
                Debug( LDAP_DEBUG_ANY, "No objectClass for entry (%s)\n",
@@ -208,13 +219,14 @@ entry_schema_check(
                        return LDAP_OBJECT_CLASS_VIOLATION;
                }
 
-               if ( oc->sco_check ) {
-                       int rc = (oc->sco_check)( be, e, oc,
+               if ( oc->soc_check ) {
+                       int rc = (oc->soc_check)( be, e, oc,
                                text, textbuf, textlen );
                        if( rc != LDAP_SUCCESS ) {
                                return rc;
                        }
                }
+
                if ( oc->soc_kind == LDAP_SCHEMA_ABSTRACT ) {
                        /* object class is abstract */
                        if ( oc != slap_schema.si_oc_top &&
@@ -382,7 +394,7 @@ oc_check_required(
 
 int oc_check_allowed(
        AttributeType *at,
-       BVarray ocl,
+       BerVarray ocl,
        ObjectClass *sc )
 {
        int             i, j;
@@ -463,7 +475,7 @@ int oc_check_allowed(
  * Determine the structural object class from a set of OIDs
  */
 int structural_class(
-       BVarray ocs,
+       BerVarray ocs,
        struct berval *scbv,
        ObjectClass **scp,
        const char **text,
@@ -482,7 +494,7 @@ int structural_class(
 
                if( oc == NULL ) {
                        snprintf( textbuf, textlen,
-                               "unrecongized objectClass '%s'",
+                               "unrecognized objectClass '%s'",
                                ocs[i].bv_val );
                        *text = textbuf;
                        return LDAP_OBJECT_CLASS_VIOLATION;
@@ -503,7 +515,7 @@ int structural_class(
 
                                        if( xc == NULL ) {
                                                snprintf( textbuf, textlen,
-                                                       "unrecongized objectClass '%s'",
+                                                       "unrecognized objectClass '%s'",
                                                        ocs[i].bv_val );
                                                *text = textbuf;
                                                return LDAP_OBJECT_CLASS_VIOLATION;