s4:dsdb Allow renames with (now removed) linked attributes
authorAndrew Bartlett <abartlet@samba.org>
Wed, 16 Jun 2010 02:01:10 +0000 (12:01 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 16 Jun 2010 02:05:31 +0000 (12:05 +1000)
It is important to allow the rename, even if we just have one-way
links, as this happens on deleted objects, which have the backlinks
alredy removed by repl_meta_data.

Andrew Bartlett

source4/dsdb/samdb/ldb_modules/linked_attributes.c

index d2a435ef507d490d7776b6a8832a39b9a615dcf3..c21fda513510c47b2d547c2b6bf63e3f180d4365 100644 (file)
@@ -641,9 +641,17 @@ static int linked_attributes_fix_links(struct ldb_module *module,
                }
                msg = res->msgs[0];
 
-               if (msg->num_elements != 1 ||
-                   ldb_attr_cmp(msg->elements[0].name, target->lDAPDisplayName) != 0) {
-                       ldb_set_errstring(ldb, "Bad msg elements in linked_attributes_fix_links");
+               if (msg->num_elements == 0) {
+                       /* Forward link without backlink remaining - nothing to do here */
+                       continue;
+               } else if (msg->num_elements != 1) {
+                       ldb_asprintf_errstring(ldb, "Bad msg elements - got %u elements, expected one element to be returned in linked_attributes_fix_links for %s", 
+                                              msg->num_elements, ldb_dn_get_linearized(msg->dn));
+                       talloc_free(tmp_ctx);
+                       return LDB_ERR_OPERATIONS_ERROR;
+               }
+               if (ldb_attr_cmp(msg->elements[0].name, target->lDAPDisplayName) != 0) {
+                       ldb_asprintf_errstring(ldb, "Bad returned attribute in linked_attributes_fix_links: got %s, expected %s for %s", msg->elements[0].name, target->lDAPDisplayName, ldb_dn_get_linearized(msg->dn));
                        talloc_free(tmp_ctx);
                        return LDB_ERR_OPERATIONS_ERROR;
                }