s4-repl: fixed _msdcs DNS name
authorAndrew Tridgell <tridge@samba.org>
Mon, 22 Aug 2011 07:30:15 +0000 (17:30 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 24 Aug 2011 21:39:38 +0000 (07:39 +1000)
another multi-domain fix

source4/dsdb/repl/drepl_extended.c
source4/dsdb/repl/drepl_out_helpers.c
source4/dsdb/repl/drepl_partitions.c

index 4d645941bbe3d1e8c8a712d9ba51bd0e6434f14a..69cccb84092edb0d0da6604eef7b85042491c262 100644 (file)
@@ -93,10 +93,9 @@ static WERROR drepl_create_extended_source_dsa(struct dreplsrv_service *service,
                return WERR_NOMEM;
        }
 
-       sdsa->repsFrom1->other_info->dns_name =
-               talloc_asprintf(sdsa->repsFrom1->other_info, "%s._msdcs.%s",
-                               GUID_string(sdsa->repsFrom1->other_info, &sdsa->repsFrom1->source_dsa_obj_guid),
-                               lpcfg_dnsdomain(service->task->lp_ctx));
+       sdsa->repsFrom1->other_info->dns_name = samdb_ntds_msdcs_dns_name(ldb,
+                                                                         sdsa->repsFrom1->other_info,
+                                                                         &sdsa->repsFrom1->source_dsa_obj_guid);
        if (!sdsa->repsFrom1->other_info->dns_name) {
                talloc_free(sdsa);
                return WERR_NOMEM;
index 7b513a805034e46c34967b4c58afe34305bbf3bd..19d09572c4c2178ce4f567ee2172e4c644340530 100644 (file)
@@ -691,7 +691,6 @@ static void dreplsrv_update_refs_trigger(struct tevent_req *req)
        struct dreplsrv_partition *partition = state->op->source_dsa->partition;
        struct dreplsrv_drsuapi_connection *drsuapi = state->op->source_dsa->conn->drsuapi;
        struct drsuapi_DsReplicaUpdateRefs *r;
-       char *ntds_guid_str;
        char *ntds_dns_name;
        struct tevent_req *subreq;
 
@@ -700,15 +699,9 @@ static void dreplsrv_update_refs_trigger(struct tevent_req *req)
                return;
        }
 
-       ntds_guid_str = GUID_string(r, &service->ntds_guid);
-       if (tevent_req_nomem(ntds_guid_str, req)) {
-               return;
-       }
-
-       ntds_dns_name = talloc_asprintf(r, "%s._msdcs.%s",
-                                       ntds_guid_str,
-                                       lpcfg_dnsdomain(service->task->lp_ctx));
+       ntds_dns_name = samdb_ntds_msdcs_dns_name(service->samdb, r, &service->ntds_guid);
        if (tevent_req_nomem(ntds_dns_name, req)) {
+               talloc_free(r);
                return;
        }
 
@@ -728,6 +721,7 @@ static void dreplsrv_update_refs_trigger(struct tevent_req *req)
                                                           drsuapi->drsuapi_handle,
                                                           r);
        if (tevent_req_nomem(subreq, req)) {
+               talloc_free(r);
                return;
        }
        tevent_req_set_callback(subreq, dreplsrv_update_refs_done, req);
index 470a88f76de5d9d91b76faf638e87e9b589c7407..e0f404511edd8251b874a6ac9f91b469cb1f8f2a 100644 (file)
@@ -107,6 +107,7 @@ NTSTATUS dreplsrv_get_target_principal(struct dreplsrv_service *s,
        int ret;
        const char *hostname;
        struct ldb_dn *dn;
+       struct ldb_dn *forest_dn;
 
        *target_principal = NULL;
 
@@ -148,9 +149,15 @@ NTSTATUS dreplsrv_get_target_principal(struct dreplsrv_service *s,
         * on it's record, it must also have GC/hostname/realm
         * servicePrincipalName */
 
+       forest_dn = ldb_get_root_basedn(s->samdb);
+       if (forest_dn == NULL) {
+               talloc_free(tmp_ctx);
+               return NT_STATUS_OK;
+       }
+
        *target_principal = talloc_asprintf(mem_ctx, "GC/%s/%s",
                                            hostname,
-                                           lpcfg_dnsdomain(s->task->lp_ctx));
+                                           samdb_dn_to_dns_domain(tmp_ctx, forest_dn));
        talloc_free(tmp_ctx);
        return NT_STATUS_OK;
 }