s4-dsdb: move checking for single valued links to samba modules
authorAndrew Tridgell <tridge@samba.org>
Sat, 19 Dec 2009 10:42:40 +0000 (21:42 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 1 Jan 2010 21:16:51 +0000 (08:16 +1100)
This uses the RELAX control and checking of single valued attributes
in ldb modules to avoid problems with multi-valued links where all
values but one are deleted

source4/dsdb/samdb/ldb_modules/linked_attributes.c
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 4113a581549b87895ce6aa4ce0cfb5c30a45662e..4c326bc240bdbbf9de6caf8d3b0cadf3e0148a39 100644 (file)
@@ -116,7 +116,13 @@ static int linked_attributes_fix_links(struct ldb_module *module,
                                dsdb_dn_get_extended_linearized(el2->values, dsdb_dn2, 1));
                }
 
-               ret = dsdb_module_modify(module, msg, 0);
+               ret = dsdb_check_single_valued_link(target, el2);
+               if (ret != LDB_SUCCESS) {
+                       talloc_free(tmp_ctx);
+                       return ret;
+               }
+
+               ret = dsdb_module_modify(module, msg, DSDB_MODIFY_RELAX);
                if (ret != LDB_SUCCESS) {
                        ldb_asprintf_errstring(ldb, "Linked attribute %s->%s between %s and %s - update failed - %s",
                                               el->name, target->lDAPDisplayName,
index 7f797752d0d8aadde6b1589bfce689fb3d0e50fb..d3a7e3791c679bbf5983e27a7d787b3d25078bc3 100644 (file)
@@ -3566,9 +3566,15 @@ linked_attributes[0]:
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       ret = dsdb_module_modify(module, msg, 0);
+       ret = dsdb_check_single_valued_link(attr, old_el);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(tmp_ctx);
+               return ret;
+       }
+
+       ret = dsdb_module_modify(module, msg, DSDB_MODIFY_RELAX);
        if (ret != LDB_SUCCESS) {
-               ldb_debug(ldb, LDB_DEBUG_WARNING, "Failed to apply linked attribute change '%s' %s\n",
+               ldb_debug(ldb, LDB_DEBUG_WARNING, "Failed to apply linked attribute change '%s'\n%s\n",
                          ldb_errstring(ldb),
                          ldb_ldif_message_string(ldb, tmp_ctx, LDB_CHANGETYPE_MODIFY, msg));
                talloc_free(tmp_ctx);