From 9a1e23a1f67c38248e41e0d3aa2af8a682477364 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 25 Oct 2017 16:48:44 +0200 Subject: [PATCH] dsdb:repl_meta_data: implement DSDB_CONTROL_DBCHECK_FIX_DUPLICATE_LINKS control This will be used by dbcheck to fix duplicate link values. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13095 Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 9a243497be7..c7aacd83615 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -3303,6 +3303,7 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) unsigned int functional_level; const struct ldb_message_element *guid_el = NULL; struct ldb_control *sd_propagation_control; + struct ldb_control *fix_links_control = NULL; struct replmd_private *replmd_private = talloc_get_type(ldb_module_get_private(module), struct replmd_private); @@ -3328,6 +3329,39 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) ldb = ldb_module_get_ctx(module); + fix_links_control = ldb_request_get_control(req, + DSDB_CONTROL_DBCHECK_FIX_DUPLICATE_LINKS); + if (fix_links_control != NULL) { + struct dsdb_schema *schema = NULL; + const struct dsdb_attribute *sa = NULL; + + if (req->op.mod.message->num_elements != 1) { + return ldb_module_operr(module); + } + + if (req->op.mod.message->elements[0].flags != LDB_FLAG_MOD_REPLACE) { + return ldb_module_operr(module); + } + + schema = dsdb_get_schema(ldb, req); + if (schema == NULL) { + return ldb_module_operr(module); + } + + sa = dsdb_attribute_by_lDAPDisplayName(schema, + req->op.mod.message->elements[0].name); + if (sa == NULL) { + return ldb_module_operr(module); + } + + if (sa->linkID == 0) { + return ldb_module_operr(module); + } + + fix_links_control->critical = false; + return ldb_next_request(module, req); + } + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_modify\n"); guid_el = ldb_msg_find_element(req->op.mod.message, "objectGUID"); -- 2.11.4.GIT