Use strip_hostname after dsgetdcname/getdcname calls.
authorGünther Deschner <gd@samba.org>
Thu, 8 May 2008 12:23:20 +0000 (14:23 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 9 May 2008 12:59:19 +0000 (14:59 +0200)
Guenther
(This used to be commit 82cbb3269b2e764c9c2a2fbcbe9c29feae07fb62)

source3/lib/netapi/joindomain.c
source3/libnet/libnet_join.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_locator.c

index 74ed8f2302f1e66fbd83922d3eeefaece659091c..b7c9fa5acce13235a2d4f3615ac3fc0933c7c00a 100644 (file)
@@ -47,6 +47,7 @@ WERROR NetJoinDomain_l(struct libnetapi_ctx *mem_ctx,
        if (r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
                NTSTATUS status;
                struct netr_DsRGetDCNameInfo *info = NULL;
+               const char *dc = NULL;
                uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
                                 DS_WRITABLE_REQUIRED |
                                 DS_RETURN_DNS_NAME;
@@ -57,8 +58,9 @@ WERROR NetJoinDomain_l(struct libnetapi_ctx *mem_ctx,
                                "%s", get_friendly_nt_error_msg(status));
                        return ntstatus_to_werror(status);
                }
-               j->in.dc_name = talloc_strdup(mem_ctx,
-                                             info->dc_unc);
+
+               dc = strip_hostname(info->dc_unc);
+               j->in.dc_name = talloc_strdup(mem_ctx, dc);
                W_ERROR_HAVE_NO_MEMORY(j->in.dc_name);
        }
 
@@ -174,6 +176,7 @@ WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx,
        } else {
                NTSTATUS status;
                struct netr_DsRGetDCNameInfo *info = NULL;
+               const char *dc = NULL;
                uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
                                 DS_WRITABLE_REQUIRED |
                                 DS_RETURN_DNS_NAME;
@@ -186,8 +189,9 @@ WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx,
                                get_friendly_nt_error_msg(status));
                        return ntstatus_to_werror(status);
                }
-               u->in.dc_name = talloc_strdup(mem_ctx,
-                                             info->dc_unc);
+
+               dc = strip_hostname(info->dc_unc);
+               u->in.dc_name = talloc_strdup(mem_ctx, dc);
                W_ERROR_HAVE_NO_MEMORY(u->in.dc_name);
 
                u->in.domain_name = domain;
@@ -352,6 +356,7 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
        ADS_STATUS ads_status;
        ADS_STRUCT *ads = NULL;
        struct netr_DsRGetDCNameInfo *info = NULL;
+       const char *dc = NULL;
        uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
                         DS_RETURN_DNS_NAME;
 
@@ -363,7 +368,9 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
                return ntstatus_to_werror(status);
        }
 
-       ads = ads_init(r->in.domain, r->in.domain, info->dc_unc);
+       dc = strip_hostname(info->dc_unc);
+
+       ads = ads_init(r->in.domain, r->in.domain, dc);
        if (!ads) {
                return WERR_GENERAL_FAILURE;
        }
index 7e348e25a576dcb5030c10601642fc506bf2f19e..8e503382f414be5356736b7824e5ca2979848286 100644 (file)
@@ -1620,6 +1620,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 
        if (!r->in.dc_name) {
                struct netr_DsRGetDCNameInfo *info;
+               const char *dc;
                status = dsgetdcname(mem_ctx,
                                     r->in.domain_name,
                                     NULL,
@@ -1636,8 +1637,8 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
                        return WERR_DOMAIN_CONTROLLER_NOT_FOUND;
                }
 
-               r->in.dc_name = talloc_strdup(mem_ctx,
-                                             info->dc_unc);
+               dc = strip_hostname(info->dc_unc);
+               r->in.dc_name = talloc_strdup(mem_ctx, dc);
                W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
        }
 
@@ -1775,6 +1776,7 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
 
        if (!r->in.dc_name) {
                struct netr_DsRGetDCNameInfo *info;
+               const char *dc;
                status = dsgetdcname(mem_ctx,
                                     r->in.domain_name,
                                     NULL,
@@ -1791,8 +1793,8 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
                        return WERR_DOMAIN_CONTROLLER_NOT_FOUND;
                }
 
-               r->in.dc_name = talloc_strdup(mem_ctx,
-                                             info->dc_unc);
+               dc = strip_hostname(info->dc_unc);
+               r->in.dc_name = talloc_strdup(mem_ctx, dc);
                W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
        }
 
index 0b0de5ad4ff7dcf65d5dc5b3303983de22b69de7..377b1b2d2144e21ddf134e71de354deb08feab87 100644 (file)
@@ -655,13 +655,7 @@ static bool get_dc_name_via_netlogon(struct winbindd_domain *domain,
        }
 
        /* rpccli_netr_GetAnyDCName gives us a name with \\ */
-       p = tmp;
-       if (*p == '\\') {
-               p+=1;
-       }
-       if (*p == '\\') {
-               p+=1;
-       }
+       p = strip_hostname(tmp);
 
        fstrcpy(dcname, p);
 
index 10a6c5afeb8d546f961163dbd2fe4de0514b015e..f154f36c8518450ca8727f9cee10976f023ae86b 100644 (file)
@@ -75,14 +75,11 @@ static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain,
        }
 
        if (info->dc_address) {
-               dc = info->dc_address;
-               if ((dc[0] == '\\') && (dc[1] == '\\')) {
-                       dc += 2;
-               }
+               dc = strip_hostname(info->dc_address);
        }
 
        if ((!dc || !is_ipaddress_v4(dc)) && info->dc_unc) {
-               dc = info->dc_unc;
+               dc = strip_hostname(info->dc_unc);
        }
 
        if (!dc || !*dc) {