Wrap DRS changes in a transaction
authorAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 01:17:43 +0000 (11:17 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 08:19:55 +0000 (18:19 +1000)
We should always apply a whole set of DRS changes or none of them. See
[MS-DRSR] 3.3.2

source4/dsdb/repl/replicated_objects.c

index d96a06359956e82acc00d43255263361c783fc1c..8018254a00bc5a4aca15067d06231ccc943417cb 100644 (file)
@@ -245,15 +245,33 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb,
 
        /* TODO: handle linked attributes */
 
+       /* wrap the extended operation in a transaction 
+          See [MS-DRSR] 3.3.2 Transactions
+        */
+       ret = ldb_transaction_start(ldb);
+       if (ret != LDB_SUCCESS) {
+               DEBUG(0,(__location__ " Failed to start transaction\n"));
+               talloc_free(out);
+               return WERR_FOOBAR;
+       }
+
        ret = ldb_extended(ldb, DSDB_EXTENDED_REPLICATED_OBJECTS_OID, out, &ext_res);
        if (ret != LDB_SUCCESS) {
                DEBUG(0,("Failed to apply records: %s: %s\n",
                         ldb_errstring(ldb), ldb_strerror(ret)));
                talloc_free(out);
+               ldb_transaction_cancel(ldb);
                return WERR_FOOBAR;
        }
        talloc_free(ext_res);
 
+       ret = ldb_transaction_commit(ldb);
+       if (ret != LDB_SUCCESS) {
+               DEBUG(0,(__location__ " Failed to commit transaction\n"));
+               talloc_free(out);
+               return WERR_FOOBAR;
+       }
+
        if (_out) {
                *_out = out;
        } else {