From 63c6209f5c04e4fe1ac41a034d2f0d06d7709305 Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Wed, 29 Mar 2017 15:21:04 +1300 Subject: [PATCH] updaterefs: Do not open transaction even when unnecessary This can be called during GetNCChanges (a generally read-only call), it is not wise to be blocking the database for no reason. Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett Autobuild-User(master): Garming Sam Autobuild-Date(master): Thu Apr 13 11:25:06 CEST 2017 on sn-devel-144 --- source4/rpc_server/drsuapi/updaterefs.c | 53 +++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/source4/rpc_server/drsuapi/updaterefs.c b/source4/rpc_server/drsuapi/updaterefs.c index 457f393fd9d7..9cf3556f4972 100644 --- a/source4/rpc_server/drsuapi/updaterefs.c +++ b/source4/rpc_server/drsuapi/updaterefs.c @@ -35,6 +35,43 @@ struct repsTo { struct repsFromToBlob *r; }; +static WERROR uref_check_dest(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, + struct ldb_dn *dn, struct GUID *dest_guid, + uint32_t options) +{ + struct repsTo reps; + WERROR werr; + unsigned int i; + bool found = false; + + werr = dsdb_loadreps(sam_ctx, mem_ctx, dn, "repsTo", &reps.r, &reps.count); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + for (i=0; idest_dsa_guid, + req->options); + if (W_ERROR_EQUAL(werr, WERR_DS_DRA_REF_ALREADY_EXISTS) || + W_ERROR_EQUAL(werr, WERR_DS_DRA_REF_NOT_FOUND)) { + if (req->options & DRSUAPI_DRS_GETCHG_CHECK) { + return WERR_OK; + } + return werr; + } + if (ldb_transaction_start(sam_ctx) != LDB_SUCCESS) { DEBUG(0,(__location__ ": Failed to start transaction on samdb: %s\n", ldb_errstring(sam_ctx))); -- 2.34.1