]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_check.c
error message from be_entry_put tool backend function
[openldap] / servers / slapd / schema_check.c
index 81ef6562768f0157973fca2400ec4a7d1abd48b1..5d5aaa82b113824f835dcce47b6a773f78082466 100644 (file)
@@ -30,7 +30,9 @@ static char * oc_check_required(
 
 int
 entry_schema_check( 
-       Entry *e, Attribute *oldattrs,
+       Backend *be,
+       Entry *e,
+       Attribute *oldattrs,
        const char** text,
        char *textbuf, size_t textlen )
 {
@@ -43,29 +45,40 @@ entry_schema_check(
        AttributeDescription *ad_objectClass
                = slap_schema.si_ad_objectClass;
        int extensible = 0;
+       int subentry = is_entry_subentry( e );
+       int collective = 0;
+
+       if( subentry) collective = is_entry_collectiveAttributes( 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 ); 
 
                if( a->a_desc->ad_type->sat_check ) {
                        int rc = (a->a_desc->ad_type->sat_check)(
-                               e, a, text, textbuf, textlen );
+                               be, e, a, text, textbuf, textlen );
                        if( rc != LDAP_SUCCESS ) {
                                return rc;
                        }
                }
 
+               if( !collective && is_at_collective( a->a_desc->ad_type ) ) {
+                       snprintf( textbuf, textlen, "attribute '%s' "
+                               "may only appear in collectiveAttributes subentry",
+                               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 );
@@ -207,7 +220,7 @@ entry_schema_check(
                }
 
                if ( oc->sco_check ) {
-                       int rc = (oc->sco_check)( e, oc,
+                       int rc = (oc->sco_check)( be, e, oc,
                                text, textbuf, textlen );
                        if( rc != LDAP_SUCCESS ) {
                                return rc;