From 11e2c5777dc1bd8af1f696e04d0712fe43e7a21a Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Fri, 18 Dec 2009 18:11:48 +0200 Subject: s4-dsdb-util: Utility function to process ldb_request in transaction This function is to be used later for manually crafted ldb_requests from within dsdb layer Signed-off-by: Andrew Tridgell --- source4/dsdb/common/util.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4/dsdb') diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index b0f9ef0f35..4f7ddde14c 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -996,6 +996,32 @@ int samdb_replace(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_m return ldb_modify(sam_ldb, msg); } +/* + * Handle ldb_request in transaction + */ +static int dsdb_autotransaction_request(struct ldb_context *sam_ldb, + struct ldb_request *req) +{ + int ret; + + ret = ldb_transaction_start(sam_ldb); + if (ret != LDB_SUCCESS) { + return ret; + } + + ret = ldb_request(sam_ldb, req); + if (ret == LDB_SUCCESS) { + ret = ldb_wait(req->handle, LDB_WAIT_ALL); + } + + if (ret == LDB_SUCCESS) { + return ldb_transaction_commit(sam_ldb); + } + ldb_transaction_cancel(sam_ldb); + + return ret; +} + /* return a default security descriptor */ -- cgit