1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

r24747: Add WINBINDD_DSGETDCNAME call.

Guenther
(This used to be commit 429496a4ccb5c4f4eda11f1b522629889b972c71)
This commit is contained in:
Günther Deschner 2007-08-28 15:20:54 +00:00 committed by Gerald (Jerry) Carter
parent a090092cd2
commit 21dd4aa82d
5 changed files with 75 additions and 0 deletions

View File

@ -500,6 +500,35 @@ static BOOL wbinfo_getdcname(const char *domain_name)
return True;
}
/* Find a DC */
static BOOL wbinfo_dsgetdcname(const char *domain_name, uint32_t flags)
{
struct winbindd_request request;
struct winbindd_response response;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
fstrcpy(request.domain_name, domain_name);
request.flags = flags;
request.flags |= DS_DIRECTORY_SERVICE_REQUIRED;
/* Send request */
if (winbindd_request_response(WINBINDD_DSGETDCNAME, &request, &response) !=
NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "Could not find dc for %s\n", domain_name);
return False;
}
/* Display response */
d_printf("%s\n", response.data.dc_name);
return True;
}
/* Check trust account password */
static BOOL wbinfo_check_secret(void)
@ -1225,6 +1254,7 @@ enum {
OPT_DOMAIN_NAME,
OPT_SEQUENCE,
OPT_GETDCNAME,
OPT_DSGETDCNAME,
OPT_USERDOMGROUPS,
OPT_USERSIDS,
OPT_ALLOCATE_UID,
@ -1284,6 +1314,7 @@ int main(int argc, char **argv, char **envp)
{ "set-auth-user", 0, POPT_ARG_STRING, &string_arg, OPT_SET_AUTH_USER, "Store user and password used by winbindd (root only)", "user%password" },
{ "getdcname", 0, POPT_ARG_STRING, &string_arg, OPT_GETDCNAME,
"Get a DC name for a foreign domain", "domainname" },
{ "dsgetdcname", 0, POPT_ARG_STRING, &string_arg, OPT_DSGETDCNAME, "Find a DC for a domain", "domainname" },
{ "get-auth-user", 0, POPT_ARG_NONE, NULL, OPT_GET_AUTH_USER, "Retrieve user and password used by winbindd (root only)", NULL },
{ "ping", 'p', POPT_ARG_NONE, 0, 'p', "Ping winbindd to see if it is alive" },
{ "domain", 0, POPT_ARG_STRING, &opt_domain_name, OPT_DOMAIN_NAME, "Define to the domain to restrict operation", "domain" },
@ -1540,6 +1571,11 @@ int main(int argc, char **argv, char **envp)
goto done;
}
break;
case OPT_DSGETDCNAME:
if (!wbinfo_dsgetdcname(string_arg, 0)) {
goto done;
}
break;
case OPT_SEPARATOR: {
const char sep = winbind_separator_int(True);
if ( !sep ) {

View File

@ -282,6 +282,7 @@ static struct winbindd_dispatch_table {
{ WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir,
"WINBINDD_PRIV_PIPE_DIR" },
{ WINBINDD_GETDCNAME, winbindd_getdcname, "GETDCNAME" },
{ WINBINDD_DSGETDCNAME, winbindd_dsgetdcname, "DSGETDCNAME" },
/* Credential cache access */
{ WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" },

View File

@ -423,6 +423,7 @@ static struct winbindd_child_dispatch_table child_dispatch_table[] = {
{ WINBINDD_LIST_TRUSTDOM, winbindd_dual_list_trusted_domains, "LIST_TRUSTDOM" },
{ WINBINDD_INIT_CONNECTION, winbindd_dual_init_connection, "INIT_CONNECTION" },
{ WINBINDD_GETDCNAME, winbindd_dual_getdcname, "GETDCNAME" },
{ WINBINDD_DSGETDCNAME, winbindd_dual_dsgetdcname, "DSGETDCNAME" },
{ WINBINDD_SHOW_SEQUENCE, winbindd_dual_show_sequence, "SHOW_SEQUENCE" },
{ WINBINDD_PAM_AUTH, winbindd_dual_pam_auth, "PAM_AUTH" },
{ WINBINDD_PAM_AUTH_CRAP, winbindd_dual_pam_auth_crap, "AUTH_CRAP" },

View File

@ -270,6 +270,42 @@ enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,
return WINBINDD_OK;
}
void winbindd_dsgetdcname(struct winbindd_cli_state *state)
{
state->request.domain_name
[sizeof(state->request.domain_name)-1] = '\0';
DEBUG(3, ("[%5lu]: DsGetDcName for %s\n", (unsigned long)state->pid,
state->request.domain_name));
sendto_domain(state, find_our_domain());
}
enum winbindd_result winbindd_dual_dsgetdcname(struct winbindd_domain *domain,
struct winbindd_cli_state *state)
{
NTSTATUS result;
struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
state->request.domain_name
[sizeof(state->request.domain_name)-1] = '\0';
DEBUG(3, ("[%5lu]: DsGetDcName for %s\n", (unsigned long)state->pid,
state->request.domain_name));
result = DsGetDcName(state->mem_ctx, NULL, state->request.domain_name,
NULL, NULL, state->request.flags, &info);
if (!NT_STATUS_IS_OK(result)) {
return WINBINDD_ERROR;
}
fstrcpy(state->response.data.dc_name, info->domain_controller_name);
return WINBINDD_OK;
}
struct sequence_state {
TALLOC_CTX *mem_ctx;
struct winbindd_cli_state *cli_state;

View File

@ -123,6 +123,7 @@ enum winbindd_cmd {
WINBINDD_DOMAIN_INFO, /* Most of what we know from
struct winbindd_domain */
WINBINDD_GETDCNAME, /* Issue a GetDCName Request */
WINBINDD_DSGETDCNAME, /* Issue a DsGetDCName Request */
WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */