svn commit: samba r24747 - in branches: SAMBA_3_2/source/nsswitch
SAMBA_3_2_0/source/nsswitch
gd at samba.org
gd at samba.org
Tue Aug 28 15:20:56 GMT 2007
Author: gd
Date: 2007-08-28 15:20:54 +0000 (Tue, 28 Aug 2007)
New Revision: 24747
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24747
Log:
Add WINBINDD_DSGETDCNAME call.
Guenther
Modified:
branches/SAMBA_3_2/source/nsswitch/wbinfo.c
branches/SAMBA_3_2/source/nsswitch/winbindd.c
branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c
branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c
branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h
branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c
branches/SAMBA_3_2_0/source/nsswitch/winbindd.c
branches/SAMBA_3_2_0/source/nsswitch/winbindd_dual.c
branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c
branches/SAMBA_3_2_0/source/nsswitch/winbindd_nss.h
Changeset:
Modified: branches/SAMBA_3_2/source/nsswitch/wbinfo.c
===================================================================
--- branches/SAMBA_3_2/source/nsswitch/wbinfo.c 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2/source/nsswitch/wbinfo.c 2007-08-28 15:20:54 UTC (rev 24747)
@@ -500,6 +500,35 @@
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 @@
OPT_DOMAIN_NAME,
OPT_SEQUENCE,
OPT_GETDCNAME,
+ OPT_DSGETDCNAME,
OPT_USERDOMGROUPS,
OPT_USERSIDS,
OPT_ALLOCATE_UID,
@@ -1284,6 +1314,7 @@
{ "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 @@
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 ) {
Modified: branches/SAMBA_3_2/source/nsswitch/winbindd.c
===================================================================
--- branches/SAMBA_3_2/source/nsswitch/winbindd.c 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2/source/nsswitch/winbindd.c 2007-08-28 15:20:54 UTC (rev 24747)
@@ -282,6 +282,7 @@
{ 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" },
Modified: branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c
===================================================================
--- branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c 2007-08-28 15:20:54 UTC (rev 24747)
@@ -423,6 +423,7 @@
{ 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" },
Modified: branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c
===================================================================
--- branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c 2007-08-28 15:20:54 UTC (rev 24747)
@@ -270,6 +270,42 @@
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;
Modified: branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h
===================================================================
--- branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h 2007-08-28 15:20:54 UTC (rev 24747)
@@ -123,6 +123,7 @@
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 */
Modified: branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c
===================================================================
--- branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c 2007-08-28 15:20:54 UTC (rev 24747)
@@ -493,6 +493,35 @@
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)
@@ -1218,6 +1247,7 @@
OPT_DOMAIN_NAME,
OPT_SEQUENCE,
OPT_GETDCNAME,
+ OPT_DSGETDCNAME,
OPT_USERDOMGROUPS,
OPT_USERSIDS,
OPT_ALLOCATE_UID,
@@ -1277,6 +1307,7 @@
{ "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" },
@@ -1533,6 +1564,11 @@
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 ) {
Modified: branches/SAMBA_3_2_0/source/nsswitch/winbindd.c
===================================================================
--- branches/SAMBA_3_2_0/source/nsswitch/winbindd.c 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2_0/source/nsswitch/winbindd.c 2007-08-28 15:20:54 UTC (rev 24747)
@@ -287,6 +287,7 @@
{ 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" },
Modified: branches/SAMBA_3_2_0/source/nsswitch/winbindd_dual.c
===================================================================
--- branches/SAMBA_3_2_0/source/nsswitch/winbindd_dual.c 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2_0/source/nsswitch/winbindd_dual.c 2007-08-28 15:20:54 UTC (rev 24747)
@@ -423,6 +423,7 @@
{ 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" },
Modified: branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c
===================================================================
--- branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c 2007-08-28 15:20:54 UTC (rev 24747)
@@ -270,6 +270,42 @@
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;
Modified: branches/SAMBA_3_2_0/source/nsswitch/winbindd_nss.h
===================================================================
--- branches/SAMBA_3_2_0/source/nsswitch/winbindd_nss.h 2007-08-28 15:16:42 UTC (rev 24746)
+++ branches/SAMBA_3_2_0/source/nsswitch/winbindd_nss.h 2007-08-28 15:20:54 UTC (rev 24747)
@@ -116,6 +116,7 @@
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 */
More information about the samba-cvs
mailing list