From: Kurt Zeilenga Date: Thu, 26 Jul 2001 00:58:00 +0000 (+0000) Subject: Import single-value check X-Git-Tag: OPENLDAP_REL_ENG_2_0_12~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ced4c77270f83404054894cf6c2d591b1b42a090;p=thirdparty%2Fopenldap.git Import single-value check --- diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 7e3c90890c..cd5d318169 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -423,7 +423,7 @@ int slap_modlist2mods( "%s: multiple value provided", ml->ml_type ); *text = textbuf; - return LDAP_INVALID_SYNTAX; + return LDAP_CONSTRAINT_VIOLATION; } } diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index bc43608b81..b74e7b644a 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -33,10 +33,33 @@ entry_schema_check( Attribute *a, *aoc; ObjectClass *oc; int i; - int ret; AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; int extensible = 0; + /* check single-valued attrs for multiple values */ + for ( a = e->e_attrs; a != NULL; a = a->a_next ) { + /* there should be at least one value */ + assert( a->a_vals ); + assert( a->a_vals[0] != NULL ); + + /* if single value type, check for multiple values */ + if( is_at_single_value( a->a_desc->ad_type ) && + a->a_vals[1] != NULL ) + { + char *type = a->a_desc->ad_cname->bv_val; + + snprintf( textbuf, textlen, + "attribute '%s' cannot have multiple values", + type ); + + Debug( LDAP_DEBUG_ANY, + "Entry (%s), %s\n", + e->e_dn, textbuf, 0 ); + + return LDAP_CONSTRAINT_VIOLATION; + } + } + if( !global_schemacheck ) return LDAP_SUCCESS; *text = textbuf; @@ -88,13 +111,10 @@ entry_schema_check( return LDAP_SUCCESS; } - /* optimistic */ - ret = LDAP_SUCCESS; - /* check that each attr in the entry is allowed by some oc */ for ( a = e->e_attrs; a != NULL; a = a->a_next ) { - ret = oc_check_allowed( a->a_desc->ad_type, aoc->a_vals ); - if ( ret != 0 ) { + int ret = oc_check_allowed( a->a_desc->ad_type, aoc->a_vals ); + if ( ret != LDAP_SUCCESS ) { char *type = a->a_desc->ad_cname->bv_val; snprintf( textbuf, textlen, @@ -105,11 +125,11 @@ entry_schema_check( "Entry (%s), %s\n", e->e_dn, textbuf, 0 ); - break; + return ret; } } - return( ret ); + return LDAP_SUCCESS; } static char *