svn commit: samba r23924 - in branches/SAMBA_3_2_0/source: include rpc_client rpc_parse rpcclient

gd at samba.org gd at samba.org
Tue Jul 17 10:22:04 GMT 2007


Author: gd
Date: 2007-07-17 10:22:02 +0000 (Tue, 17 Jul 2007)
New Revision: 23924

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23924

Log:
Merge NET_GETDCNAME from 3_2.

Guenther

Modified:
   branches/SAMBA_3_2_0/source/include/rpc_netlogon.h
   branches/SAMBA_3_2_0/source/rpc_client/cli_netlogon.c
   branches/SAMBA_3_2_0/source/rpc_parse/parse_net.c
   branches/SAMBA_3_2_0/source/rpcclient/cmd_netlogon.c


Changeset:
Modified: branches/SAMBA_3_2_0/source/include/rpc_netlogon.h
===================================================================
--- branches/SAMBA_3_2_0/source/include/rpc_netlogon.h	2007-07-17 10:14:15 UTC (rev 23923)
+++ branches/SAMBA_3_2_0/source/include/rpc_netlogon.h	2007-07-17 10:22:02 UTC (rev 23924)
@@ -31,6 +31,7 @@
 #define NET_AUTH		0x05
 #define NET_SRVPWSET		0x06
 #define NET_SAM_DELTAS		0x07
+#define NET_GETDCNAME		0x0b
 #define NET_LOGON_CTRL		0x0c
 #define NET_GETANYDCNAME	0x0d
 #define NET_AUTH2		0x0f
@@ -436,6 +437,23 @@
 	WERROR status;
 } NET_R_GETANYDCNAME;
 
+
+/* NET_Q_GETDCNAME - Ask a DC for a trusted DC name */
+
+typedef struct net_q_getdcname {
+	UNISTR2 uni_logon_server;
+	uint32  ptr_domainname;
+	UNISTR2 uni_domainname;
+} NET_Q_GETDCNAME;
+
+/* NET_R_GETDCNAME - Ask a DC for a trusted DC name */
+
+typedef struct net_r_getdcname {
+	uint32  ptr_dcname;
+	UNISTR2 uni_dcname;
+	WERROR status;
+} NET_R_GETDCNAME;
+
 /* NET_Q_TRUST_DOM_LIST - LSA Query Trusted Domains */
 typedef struct net_q_trust_dom_info {
 	uint32       ptr;             /* undocumented buffer pointer */

Modified: branches/SAMBA_3_2_0/source/rpc_client/cli_netlogon.c
===================================================================
--- branches/SAMBA_3_2_0/source/rpc_client/cli_netlogon.c	2007-07-17 10:14:15 UTC (rev 23923)
+++ branches/SAMBA_3_2_0/source/rpc_client/cli_netlogon.c	2007-07-17 10:22:02 UTC (rev 23924)
@@ -417,6 +417,44 @@
 	return result;
 }
 
+/* GetDCName */
+
+WERROR rpccli_netlogon_getdcname(struct rpc_pipe_client *cli,
+				 TALLOC_CTX *mem_ctx, const char *mydcname,
+				 const char *domainname, fstring newdcname)
+{
+	prs_struct qbuf, rbuf;
+	NET_Q_GETDCNAME q;
+	NET_R_GETDCNAME r;
+	WERROR result;
+	fstring mydcname_slash;
+
+	ZERO_STRUCT(q);
+	ZERO_STRUCT(r);
+
+	/* Initialise input parameters */
+
+	slprintf(mydcname_slash, sizeof(fstring)-1, "\\\\%s", mydcname);
+	init_net_q_getdcname(&q, mydcname_slash, domainname);
+
+	/* Marshall data and send request */
+
+	CLI_DO_RPC_WERR(cli, mem_ctx, PI_NETLOGON, NET_GETDCNAME,
+		q, r,
+		qbuf, rbuf,
+		net_io_q_getdcname,
+		net_io_r_getdcname,
+		WERR_GENERAL_FAILURE);
+
+	result = r.status;
+
+	if (W_ERROR_IS_OK(result)) {
+		rpcstr_pull_unistr2_fstring(newdcname, &r.uni_dcname);
+	}
+
+	return result;
+}
+
 static WERROR pull_domain_controller_info_from_getdcname_reply(TALLOC_CTX *mem_ctx,
 							       struct DS_DOMAIN_CONTROLLER_INFO **info_out, 
 							       NET_R_DSR_GETDCNAME *r)

Modified: branches/SAMBA_3_2_0/source/rpc_parse/parse_net.c
===================================================================
--- branches/SAMBA_3_2_0/source/rpc_parse/parse_net.c	2007-07-17 10:14:15 UTC (rev 23923)
+++ branches/SAMBA_3_2_0/source/rpc_parse/parse_net.c	2007-07-17 10:22:02 UTC (rev 23924)
@@ -565,7 +565,91 @@
 	return True;
 }
 
+
 /*******************************************************************
+ Inits an NET_R_GETDCNAME structure.
+********************************************************************/
+void init_net_q_getdcname(NET_Q_GETDCNAME *r_t, const char *logon_server,
+			  const char *domainname)
+{
+	DEBUG(5,("init_q_getdcname\n"));
+
+	init_unistr2(&r_t->uni_logon_server, logon_server, UNI_STR_TERMINATE);
+	r_t->ptr_domainname = (domainname != NULL);
+	init_unistr2(&r_t->uni_domainname, domainname, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes an NET_Q_GETDCNAME structure.
+********************************************************************/
+
+BOOL net_io_q_getdcname(const char *desc, NET_Q_GETDCNAME *r_t, prs_struct *ps,
+			int depth)
+{
+	if (r_t == NULL)
+		return False;
+
+	prs_debug(ps, depth, desc, "net_io_q_getdcname");
+	depth++;
+
+	if (!smb_io_unistr2("logon_server", &r_t->uni_logon_server,
+			    1, ps, depth))
+		return False;
+
+	if (!prs_align(ps))
+		return False;
+
+	if (!prs_uint32("ptr_domainname", ps, depth, &r_t->ptr_domainname))
+		return False;
+
+	if (!smb_io_unistr2("domainname", &r_t->uni_domainname,
+			    r_t->ptr_domainname, ps, depth))
+		return False;
+
+	return True;
+}
+
+
+/*******************************************************************
+ Inits an NET_R_GETDCNAME structure.
+********************************************************************/
+void init_net_r_getdcname(NET_R_GETDCNAME *r_t, const char *dcname)
+{
+	DEBUG(5,("init_r_getdcname\n"));
+
+	init_unistr2(&r_t->uni_dcname, dcname, UNI_STR_TERMINATE);
+}
+
+/*******************************************************************
+ Reads or writes an NET_R_GETDCNAME structure.
+********************************************************************/
+
+BOOL net_io_r_getdcname(const char *desc, NET_R_GETDCNAME *r_t, prs_struct *ps,
+			int depth)
+{
+	if (r_t == NULL)
+		return False;
+
+	prs_debug(ps, depth, desc, "net_io_r_getdcname");
+	depth++;
+
+	if (!prs_uint32("ptr_dcname", ps, depth, &r_t->ptr_dcname))
+		return False;
+
+	if (!smb_io_unistr2("dcname", &r_t->uni_dcname,
+			    r_t->ptr_dcname, ps, depth))
+		return False;
+
+	if (!prs_align(ps))
+		return False;
+
+	if (!prs_werror("status", ps, depth, &r_t->status))
+		return False;
+
+	return True;
+}
+
+/*******************************************************************
  Inits an NET_R_TRUST_DOM_LIST structure.
 ********************************************************************/
 

Modified: branches/SAMBA_3_2_0/source/rpcclient/cmd_netlogon.c
===================================================================
--- branches/SAMBA_3_2_0/source/rpcclient/cmd_netlogon.c	2007-07-17 10:14:15 UTC (rev 23923)
+++ branches/SAMBA_3_2_0/source/rpcclient/cmd_netlogon.c	2007-07-17 10:22:02 UTC (rev 23924)
@@ -50,14 +50,20 @@
 {
 	fstring dcname;
 	WERROR result = WERR_GENERAL_FAILURE;
+	int old_timeout;
 
 	if (argc != 2) {
 		fprintf(stderr, "Usage: %s domainname\n", argv[0]);
 		return WERR_OK;
 	}
 
+	/* 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);
 
+	cli_set_timeout(cli->cli, old_timeout);
+
 	if (!W_ERROR_IS_OK(result))
 		goto done;
 
@@ -69,6 +75,37 @@
 	return result;
 }
 
+static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, 
+				     TALLOC_CTX *mem_ctx, int argc, 
+				     const char **argv)
+{
+	fstring dcname;
+	WERROR result = WERR_GENERAL_FAILURE;
+	int old_timeout;
+
+	if (argc != 2) {
+		fprintf(stderr, "Usage: %s domainname\n", argv[0]);
+		return WERR_OK;
+	}
+
+	/* 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);
+
+	cli_set_timeout(cli->cli, old_timeout);
+
+	if (!W_ERROR_IS_OK(result))
+		goto done;
+
+	/* Display results */
+
+	printf("%s\n", dcname);
+
+ done:
+	return result;
+}
+
 static void display_ds_domain_controller_info(TALLOC_CTX *mem_ctx, const struct DS_DOMAIN_CONTROLLER_INFO *info)
 {
 	d_printf("domain_controller_name: %s\n", info->domain_controller_name);
@@ -542,6 +579,7 @@
 
 	{ "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2",     "" },
 	{ "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name",     "" },
+	{ "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name",     "" },
 	{ "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name",     "" },
 	{ "dsr_getdcnameex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex, PI_NETLOGON, NULL, "Get trusted DC name",     "" },
 	{ "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name",     "" },



More information about the samba-cvs mailing list