]> git.sur5r.net Git - openldap/commitdiff
Add an improved single value constraint check.
authorKurt Zeilenga <kurt@openldap.org>
Tue, 24 Jul 2001 03:25:17 +0000 (03:25 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 24 Jul 2001 03:25:17 +0000 (03:25 +0000)
servers/slapd/modify.c
servers/slapd/schema_check.c

index 7d6626c0cb64cba2a18e662868ea2480c470a454..811b18a16a292f0fdd3ecf5ac912bec7fd921032 100644 (file)
@@ -477,7 +477,7 @@ int slap_modlist2mods(
                                        "%s: multiple value provided",
                                        ml->ml_type );
                                *text = textbuf;
-                               return LDAP_INVALID_SYNTAX;
+                               return LDAP_CONSTRAINT_VIOLATION;
                        }
                }
 
index 28dfcfb337fe58c27ba115e688f177438227fb8c..3042817f17fbb4c5d5a733c265f129f7e4cfe332 100644 (file)
@@ -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 );