From: Kurt Zeilenga Date: Tue, 24 Jul 2001 03:25:17 +0000 (+0000) Subject: Add an improved single value constraint check. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1207 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3e7e6bc6d5ca93509c807e820802d83af55bdd7b;p=openldap Add an improved single value constraint check. --- diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 7d6626c0cb..811b18a16a 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -477,7 +477,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 28dfcfb337..3042817f17 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -131,6 +131,35 @@ entry_schema_check( break; } + + + /* 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 ); + +#ifdef NEW_LOGGING + LDAP_LOG(( "schema", LDAP_LEVEL_INFO, + "entry_schema_check: dn=\"%s\" %s\n", + e->e_dn, textbuf )); +#else + Debug( LDAP_DEBUG_ANY, + "Entry (%s), %s\n", + e->e_dn, textbuf, 0 ); +#endif + + ret = LDAP_CONSTRAINT_VIOLATION; + break; + } } return( ret );