mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
Use rpccli_netr_GetAnyDCName and rpccli_netr_GetDCName everywhere.
Guenther
(This used to be commit 8abeea9922
)
This commit is contained in:
@ -48,8 +48,9 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli,
|
||||
TALLOC_CTX *mem_ctx, int argc,
|
||||
const char **argv)
|
||||
{
|
||||
char *dcname = NULL;
|
||||
WERROR result = WERR_GENERAL_FAILURE;
|
||||
const char *dcname = NULL;
|
||||
WERROR werr;
|
||||
NTSTATUS status;
|
||||
int old_timeout;
|
||||
|
||||
if (argc != 2) {
|
||||
@ -60,27 +61,35 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli,
|
||||
/* Make sure to wait for our DC's reply */
|
||||
old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
|
||||
|
||||
result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], &dcname);
|
||||
|
||||
status = rpccli_netr_GetAnyDCName(cli, mem_ctx,
|
||||
cli->cli->desthost,
|
||||
argv[1],
|
||||
&dcname,
|
||||
&werr);
|
||||
cli_set_timeout(cli->cli, old_timeout);
|
||||
|
||||
if (!W_ERROR_IS_OK(result))
|
||||
goto done;
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return ntstatus_to_werror(status);
|
||||
}
|
||||
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
return werr;
|
||||
}
|
||||
|
||||
/* Display results */
|
||||
|
||||
printf("%s\n", dcname);
|
||||
|
||||
done:
|
||||
return result;
|
||||
return werr;
|
||||
}
|
||||
|
||||
static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
|
||||
TALLOC_CTX *mem_ctx, int argc,
|
||||
static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
|
||||
TALLOC_CTX *mem_ctx, int argc,
|
||||
const char **argv)
|
||||
{
|
||||
char *dcname = NULL;
|
||||
WERROR result = WERR_GENERAL_FAILURE;
|
||||
const char *dcname = NULL;
|
||||
NTSTATUS status;
|
||||
WERROR werr;
|
||||
int old_timeout;
|
||||
|
||||
if (argc != 2) {
|
||||
@ -91,19 +100,26 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli,
|
||||
/* Make sure to wait for our DC's reply */
|
||||
old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
|
||||
|
||||
result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], &dcname);
|
||||
|
||||
status = rpccli_netr_GetDcName(cli, mem_ctx,
|
||||
cli->cli->desthost,
|
||||
argv[1],
|
||||
&dcname,
|
||||
&werr);
|
||||
cli_set_timeout(cli->cli, old_timeout);
|
||||
|
||||
if (!W_ERROR_IS_OK(result))
|
||||
goto done;
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return ntstatus_to_werror(status);
|
||||
}
|
||||
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
return werr;
|
||||
}
|
||||
|
||||
/* Display results */
|
||||
|
||||
printf("%s\n", dcname);
|
||||
|
||||
done:
|
||||
return result;
|
||||
return werr;
|
||||
}
|
||||
|
||||
static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
|
||||
|
@ -570,8 +570,8 @@ static bool get_dc_name_via_netlogon(struct winbindd_domain *domain,
|
||||
WERROR werr;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
unsigned int orig_timeout;
|
||||
char *tmp = NULL;
|
||||
char *p;
|
||||
const char *tmp = NULL;
|
||||
const char *p;
|
||||
|
||||
/* Hmmmm. We can only open one connection to the NETLOGON pipe at the
|
||||
* moment.... */
|
||||
@ -630,25 +630,31 @@ static bool get_dc_name_via_netlogon(struct winbindd_domain *domain,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
werr = rpccli_netlogon_getanydcname(netlogon_pipe,
|
||||
mem_ctx,
|
||||
our_domain->dcname,
|
||||
domain->name,
|
||||
&tmp);
|
||||
result = rpccli_netr_GetAnyDCName(netlogon_pipe, mem_ctx,
|
||||
our_domain->dcname,
|
||||
domain->name,
|
||||
&tmp,
|
||||
&werr);
|
||||
}
|
||||
|
||||
/* And restore our original timeout. */
|
||||
cli_set_timeout(netlogon_pipe->cli, orig_timeout);
|
||||
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
DEBUG(10, ("rpccli_netlogon_getanydcname failed: %s\n",
|
||||
dos_errstr(werr)));
|
||||
if (!NT_STATUS_IS_OK(result)) {
|
||||
DEBUG(10,("rpccli_netr_GetAnyDCName failed: %s\n",
|
||||
nt_errstr(result)));
|
||||
talloc_destroy(mem_ctx);
|
||||
return False;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* cli_netlogon_getanydcname gives us a name with \\ */
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
DEBUG(10,("rpccli_netr_GetAnyDCName failed: %s\n",
|
||||
dos_errstr(werr)));
|
||||
talloc_destroy(mem_ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* rpccli_netr_GetAnyDCName gives us a name with \\ */
|
||||
p = tmp;
|
||||
if (*p == '\\') {
|
||||
p+=1;
|
||||
@ -661,7 +667,7 @@ static bool get_dc_name_via_netlogon(struct winbindd_domain *domain,
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
DEBUG(10, ("rpccli_netlogon_getanydcname returned %s\n", dcname));
|
||||
DEBUG(10,("rpccli_netr_GetAnyDCName returned %s\n", dcname));
|
||||
|
||||
if (!resolve_name(dcname, dc_ss, 0x20)) {
|
||||
return False;
|
||||
|
@ -231,8 +231,8 @@ void winbindd_getdcname(struct winbindd_cli_state *state)
|
||||
enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,
|
||||
struct winbindd_cli_state *state)
|
||||
{
|
||||
char *dcname_slash = NULL;
|
||||
char *p;
|
||||
const char *dcname_slash = NULL;
|
||||
const char *p;
|
||||
struct rpc_pipe_client *netlogon_pipe;
|
||||
NTSTATUS result;
|
||||
WERROR werr;
|
||||
@ -259,19 +259,29 @@ enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,
|
||||
|
||||
req_domain = find_domain_from_name_noinit(state->request.domain_name);
|
||||
if (req_domain == domain) {
|
||||
werr = rpccli_netlogon_getdcname(netlogon_pipe, state->mem_ctx,
|
||||
domain->dcname,
|
||||
state->request.domain_name,
|
||||
&dcname_slash);
|
||||
result = rpccli_netr_GetDcName(netlogon_pipe,
|
||||
state->mem_ctx,
|
||||
domain->dcname,
|
||||
state->request.domain_name,
|
||||
&dcname_slash,
|
||||
&werr);
|
||||
} else {
|
||||
werr = rpccli_netlogon_getanydcname(netlogon_pipe, state->mem_ctx,
|
||||
domain->dcname,
|
||||
state->request.domain_name,
|
||||
&dcname_slash);
|
||||
result = rpccli_netr_GetAnyDCName(netlogon_pipe,
|
||||
state->mem_ctx,
|
||||
domain->dcname,
|
||||
state->request.domain_name,
|
||||
&dcname_slash,
|
||||
&werr);
|
||||
}
|
||||
/* And restore our original timeout. */
|
||||
cli_set_timeout(netlogon_pipe->cli, orig_timeout);
|
||||
|
||||
if (!NT_STATUS_IS_OK(result)) {
|
||||
DEBUG(5,("Error requesting DCname for domain %s: %s\n",
|
||||
state->request.domain_name, nt_errstr(result)));
|
||||
return WINBINDD_ERROR;
|
||||
}
|
||||
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
DEBUG(5, ("Error requesting DCname for domain %s: %s\n",
|
||||
state->request.domain_name, dos_errstr(werr)));
|
||||
|
Reference in New Issue
Block a user