r811: make the ldb_modify REPLACE semantics better match LDAP (ie. no error
authorAndrew Tridgell <tridge@samba.org>
Sat, 22 May 2004 00:52:04 +0000 (00:52 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:53:51 +0000 (12:53 -0500)
on the attribute not existing and allow an empty replace)
(This used to be commit 1418b667d9041430786089713eafee63dd7b4a28)

source4/lib/ldb/ldb_tdb/ldb_tdb.c

index 09d1618ffcd977796e8841fb7935c9565cc4a343..d60504ff173fdaa5182e715effd57f28f5ee12b4 100644 (file)
@@ -501,13 +501,12 @@ int ltdb_modify_internal(struct ldb_context *ldb, const struct ldb_message *msg)
 
                case LDB_FLAG_MOD_REPLACE:
                        /* replace all elements of this attribute name with the elements
-                          listed */
-                       if (msg_delete_attribute(ldb, &msg2, msg->elements[i].name) != 0) {
-                               ltdb->last_err_string = "No such attribute";
-                               goto failed;
-                       }
-                       /* add the replacement element */
-                       if (msg_add_element(ldb, &msg2, &msg->elements[i]) != 0) {
+                          listed. The attribute not existing is not an error */
+                       msg_delete_attribute(ldb, &msg2, msg->elements[i].name);
+
+                       /* add the replacement element, if not empty */
+                       if (msg->elements[i].num_values != 0 &&
+                           msg_add_element(ldb, &msg2, &msg->elements[i]) != 0) {
                                goto failed;
                        }
                        break;