r4071: - ldap does allow adding additional attribute values with a modify
authorAndrew Tridgell <tridge@samba.org>
Mon, 6 Dec 2004 06:45:51 +0000 (06:45 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:06:22 +0000 (13:06 -0500)
  operation, but not if the value already exists

- fixed syntax of test.ldif for ldap backend
(This used to be commit 29225d0bec39038e42e68849bd9378898f062081)

source4/lib/ldb/ldb_tdb/ldb_tdb.c
source4/lib/ldb/tests/test-modify.ldif
source4/lib/ldb/tests/test.ldif

index 4049900a232d64a7d59bcac47e148a4a7b806d5f..6623fd0052cc8b13efc1e7ddf19eaa4e1db60b9e 100644 (file)
@@ -516,8 +516,13 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
                           already exists */
                        ret = find_element(&msg2, msg->elements[i].name);
                        if (ret != -1) {
-                               ltdb->last_err_string = "Attribute exists";
-                               goto failed;
+                               for (j=0;j<msg->elements[i].num_values;j++) {
+                                       if (ldb_msg_find_val(&msg2.elements[ret], 
+                                                            &msg->elements[i].values[j])) {
+                                               ltdb->last_err_string = "Type or value exists";
+                                               goto failed;
+                                       }
+                               }
                        }
                        if (msg_add_element(ldb, &msg2, &msg->elements[i]) != 0) {
                                goto failed;
index 78d8353d3c44522d39c2d2eddf3b69f77632d929..37ef8293e6a62dcee2ef20eecca3fbb28db73f96 100644 (file)
@@ -4,6 +4,9 @@ changetype: modify
 add: drink
 drink: mango lassi
 -
+add: drink
+drink: lemonade
+-
 delete: pager
 -
 replace: telephonenumber
index b9afad8b635accedf09faff099b4d6d699c610bb..8d6c0c750e3e4ad486696812f93dc77d873aa23b 100644 (file)
@@ -409,8 +409,8 @@ postaladdress: Alumni Association $ 111 Maple St $ Ann Arbor, MI 48109
 seealso: cn=All Staff,ou=Groups,o=University of Michigan,c=US
 homepostaladdress: 123 Anystreet $ Ann Arbor, MI 48104
 mail: uham@mail.alumni.example.com
-seeAlso: a long attribute name, longer than 128 bytes so that we 
- trigger sign extension problems in tdb_pack, no thats not long enough 
+description: a long attribute name, longer than 128 bytes so that we
+ trigger sign extension problems in tdb_pack, no thats not long enough
  yet, maybe this is. I'll just keep going till it triggers the error
 homephone: +1 313 555 8421
 pager: +1 313 555 2844