mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
Use strip_hostname after dsgetdcname/getdcname calls.
Guenther
This commit is contained in:
parent
dbf96120d8
commit
82cbb3269b
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user