From: Garming Sam Date: Fri, 26 May 2017 03:17:21 +0000 (+1200) Subject: replmd: check single values in replmd_add_fix_la X-Git-Tag: tevent-0.9.32~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=990b23d7b6f3099bb471234590b92ed82cd2b5a9;p=thirdparty%2Fsamba.git replmd: check single values in replmd_add_fix_la repl_meta_data knows whether linked attributes are appropriately [un-]duplicated, and this is how it tells ldb_tdb that. Signed-off-by: Garming Sam Pair-programmed-with: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index 1822ea01a08..f470e023d19 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -355,7 +355,9 @@ static int ltdb_add_internal(struct ldb_module *module, continue; } - if (check_single_value) { + if (check_single_value && + !(el->flags & + LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK)) { struct ldb_val *duplicate = NULL; ret = ldb_msg_find_duplicate_val(ldb, discard_const(msg), diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 2715db84083..d295a85f0fd 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -911,9 +911,21 @@ static int replmd_add_fix_la(struct ldb_module *module, TALLOC_CTX *mem_ctx, /* We will take a reference to the schema in replmd_add_backlink */ const struct dsdb_schema *schema = dsdb_get_schema(ldb, NULL); struct ldb_val *new_values = NULL; + int ret; + + if (dsdb_check_single_valued_link(sa, el) == LDB_SUCCESS) { + el->flags |= LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK; + } else { + ldb_asprintf_errstring(ldb, + "Attribute %s is single valued but " + "more than one value has been supplied", + el->name); + talloc_free(tmp_ctx); + return LDB_ERR_CONSTRAINT_VIOLATION; + } - int ret = get_parsed_dns(module, tmp_ctx, el, &pdn, - sa->syntax->ldap_oid, parent); + ret = get_parsed_dns(module, tmp_ctx, el, &pdn, + sa->syntax->ldap_oid, parent); if (ret != LDB_SUCCESS) { talloc_free(tmp_ctx); return ret;