replmd: replmd_check_upgrade_links() needs to first parses DNs
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 29 Dec 2016 02:09:15 +0000 (15:09 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 9 Feb 2017 02:17:15 +0000 (03:17 +0100)
Because we now load the dns with get_parsed_dns_trusted we have
to manually explode them in the upgrade tests.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 46f29942d847e3218f317a40bc931bdbfa34535d..b4dacccd8e83069f4f0e0ad9be5703116119fc36 100644 (file)
@@ -2092,15 +2092,24 @@ static int replmd_update_la_val(TALLOC_CTX *mem_ctx, struct ldb_val *v, struct d
 /*
   check if any links need upgrading from w2k format
  */
-static int replmd_check_upgrade_links(struct parsed_dn *dns, uint32_t count,
+static int replmd_check_upgrade_links(struct ldb_context *ldb,
+                                     struct parsed_dn *dns, uint32_t count,
                                      struct ldb_message_element *el,
-                                     const struct GUID *invocation_id)
+                                     const struct GUID *invocation_id,
+                                     const char *ldap_oid)
 {
        uint32_t i;
        for (i=0; i<count; i++) {
                NTSTATUS status;
                uint32_t version;
                int ret;
+               if (dns[i].dsdb_dn == NULL) {
+                       dns[i].dsdb_dn = dsdb_dn_parse(dns, ldb, dns[i].v,
+                                                      ldap_oid);
+                       if (dns[i].dsdb_dn == NULL) {
+                               return LDB_ERR_INVALID_DN_SYNTAX;
+                       }
+               }
 
                status = dsdb_get_extended_dn_uint32(dns[i].dsdb_dn->dn,
                                                     &version, "RMD_VERSION");
@@ -2279,7 +2288,9 @@ static int replmd_modify_la_add(struct ldb_module *module,
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       ret = replmd_check_upgrade_links(old_dns, old_num_values, old_el, invocation_id);
+       ret = replmd_check_upgrade_links(ldb, old_dns, old_num_values,
+                                        old_el, invocation_id,
+                                        schema_attr->syntax->ldap_oid);
        if (ret != LDB_SUCCESS) {
                talloc_free(tmp_ctx);
                return ret;
@@ -2433,7 +2444,9 @@ static int replmd_modify_la_delete(struct ldb_module *module,
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       ret = replmd_check_upgrade_links(old_dns, old_el->num_values, old_el, invocation_id);
+       ret = replmd_check_upgrade_links(ldb, old_dns, old_el->num_values,
+                                        old_el, invocation_id,
+                                        schema_attr->syntax->ldap_oid);
        if (ret != LDB_SUCCESS) {
                talloc_free(tmp_ctx);
                return ret;
@@ -2672,7 +2685,9 @@ static int replmd_modify_la_replace(struct ldb_module *module,
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       ret = replmd_check_upgrade_links(old_dns, old_num_values, old_el, invocation_id);
+       ret = replmd_check_upgrade_links(ldb, old_dns, old_num_values,
+                                        old_el, invocation_id,
+                                        schema_attr->syntax->ldap_oid);
        if (ret != LDB_SUCCESS) {
                talloc_free(tmp_ctx);
                return ret;
@@ -6421,7 +6436,9 @@ linked_attributes[0]:
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       ret = replmd_check_upgrade_links(pdn_list, old_el->num_values, old_el, our_invocation_id);
+       ret = replmd_check_upgrade_links(ldb, pdn_list, old_el->num_values,
+                                        old_el, our_invocation_id,
+                                        attr->syntax->ldap_oid);
        if (ret != LDB_SUCCESS) {
                talloc_free(tmp_ctx);
                return ret;