From a130ad27c4d913f9d8a8f4bf3fde6c44ba33587d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 24 Sep 2009 20:15:11 -0700 Subject: s4-repl: use GUID to resolve target in linked attributes When we vampire from w2k8-r2, the DC sends us a linked attribute for our machine account which has a target DN with a GUID of the OU=Domain Controllers objects, but has a DN of CN=Computers. We need to use the GUID to resolve the real DN. --- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'source4') diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index f729d5c88f..c83fb0f01b 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -2076,10 +2076,10 @@ static int replmd_process_linked_attribute(struct ldb_module *module, struct ldb_message_element *ret_el; TALLOC_CTX *tmp_ctx = talloc_new(la_entry); enum ndr_err_code ndr_err; - char *target_dn; struct ldb_request *mod_req; int ret; const struct dsdb_attribute *attr; + struct ldb_dn *target_dn; /* linked_attributes[0]: @@ -2176,16 +2176,15 @@ linked_attributes[0]: } ret_el->num_values = 1; - target_dn = talloc_asprintf(tmp_ctx, ";;%s", - GUID_string(tmp_ctx, &target.guid), - dom_sid_string(tmp_ctx, &target.sid), - target.dn); - if (target_dn == NULL) { - ldb_oom(ldb); + ret = dsdb_find_dn_by_guid(ldb, tmp_ctx, GUID_string(tmp_ctx, &target.guid), &target_dn); + if (ret != LDB_SUCCESS) { + DEBUG(0,(__location__ ": Failed to map GUID %s to DN\n", GUID_string(tmp_ctx, &target.guid))); talloc_free(tmp_ctx); return LDB_ERR_OPERATIONS_ERROR; } - ret_el->values[0] = data_blob_string_const(target_dn); + + ret_el->values[0].data = (uint8_t *)ldb_dn_get_extended_linearized(tmp_ctx, target_dn, 1); + ret_el->values[0].length = strlen((char *)ret_el->values[0].data); ret = ldb_build_mod_req(&mod_req, ldb, tmp_ctx, msg, -- cgit