From 3e7e6bc6d5ca93509c807e820802d83af55bdd7b Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 24 Jul 2001 03:25:17 +0000 Subject: [PATCH] Add an improved single value constraint check. --- servers/slapd/modify.c | 2 +- servers/slapd/schema_check.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) 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 ); -- 2.39.5