replmd: check single values in replmd_add_fix_la
authorGarming Sam <garming@catalyst.net.nz>
Fri, 26 May 2017 03:17:21 +0000 (15:17 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 15 Jun 2017 15:33:10 +0000 (17:33 +0200)
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 <garming@catalyst.net.nz>
Pair-programmed-with: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/ldb_tdb/ldb_tdb.c
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 1822ea01a08380e8f43899c4aee335fdf265bdfb..f470e023d190168752b4351132fd5f6c5a1f765b 100644 (file)
@@ -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),
index 2715db840830004bf59f8d049ca64407f63e6470..d295a85f0fddb824c0df37e750758dc84b175d37 100644 (file)
@@ -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;