svn commit: samba r19355 - in branches/SAMBA_3_0/source: include rpc_client rpcclient

gd at samba.org gd at samba.org
Mon Oct 16 23:42:17 GMT 2006


Author: gd
Date: 2006-10-16 23:42:15 +0000 (Mon, 16 Oct 2006)
New Revision: 19355

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

Log:
Add getdispenumindex2 wrapper for rpcclient.

Guenther

Modified:
   branches/SAMBA_3_0/source/include/rpc_samr.h
   branches/SAMBA_3_0/source/rpc_client/cli_samr.c
   branches/SAMBA_3_0/source/rpcclient/cmd_samr.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/rpc_samr.h
===================================================================
--- branches/SAMBA_3_0/source/include/rpc_samr.h	2006-10-16 23:28:48 UTC (rev 19354)
+++ branches/SAMBA_3_0/source/include/rpc_samr.h	2006-10-16 23:42:15 UTC (rev 19355)
@@ -130,7 +130,7 @@
 #define SAMR_UNKNOWN_2f        0x2f
 #define SAMR_QUERY_DISPINFO2   0x30 /* Alias for SAMR_QUERY_DISPINFO
 				       with info level 3 */
-#define SAMR_UNKNOWN_31        0x31
+#define SAMR_GET_DISPENUM_INDEX2 0x31
 #define SAMR_CREATE_USER       0x32
 #define SAMR_QUERY_DISPINFO3   0x33 /* Alias for SAMR_QUERY_DISPINFO
 				       with info level 4 */

Modified: branches/SAMBA_3_0/source/rpc_client/cli_samr.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_client/cli_samr.c	2006-10-16 23:28:48 UTC (rev 19354)
+++ branches/SAMBA_3_0/source/rpc_client/cli_samr.c	2006-10-16 23:42:15 UTC (rev 19355)
@@ -1459,7 +1459,7 @@
 
 	/* Return output parameters */
 
-        result = r.status;
+	result = r.status;
 
 	if (!NT_STATUS_IS_OK(result) &&
 	    NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
@@ -1511,7 +1511,7 @@
 
 	/* Return output parameters */
 
-        result = r.status;
+	result = r.status;
 
 	if (!NT_STATUS_IS_OK(result) &&
 	    NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
@@ -1562,7 +1562,7 @@
 
 	/* Return output parameters */
 
-        result = r.status;
+	result = r.status;
 
 	if (!NT_STATUS_IS_OK(result) &&
 	    NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) {
@@ -1610,16 +1610,57 @@
 
 	*idx = 0;
 
-        result = r.status;
+	result = r.status;
 
-	if (NT_STATUS_IS_OK(result)) {
+	if (!NT_STATUS_IS_ERR(result)) {
 		*idx = r.idx;
 	}
 
 	return result;
 }
 
+NTSTATUS rpccli_samr_get_dispenum_index2(struct rpc_pipe_client *cli,
+					 TALLOC_CTX *mem_ctx, 
+					 POLICY_HND *domain_pol,
+					 uint16 switch_value,
+					 const char *name,
+					 uint32 *idx)
+{
+	prs_struct qbuf, rbuf;
+	SAMR_Q_GET_DISPENUM_INDEX q;
+	SAMR_R_GET_DISPENUM_INDEX r;
+	NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
 
+	DEBUG(10,("cli_samr_get_dispenum_index2 for name = %s\n", name));
+
+	ZERO_STRUCT(q);
+	ZERO_STRUCT(r);
+
+	/* Marshall data and send request */
+
+	init_samr_q_get_dispenum_index(&q, domain_pol, switch_value, name);
+
+	CLI_DO_RPC(cli, mem_ctx, PI_SAMR, SAMR_GET_DISPENUM_INDEX2,
+		q, r,
+		qbuf, rbuf,
+		samr_io_q_get_dispenum_index,
+		samr_io_r_get_dispenum_index,
+		NT_STATUS_UNSUCCESSFUL); 
+
+	/* Return output parameters */
+
+	*idx = 0;
+
+	result = r.status;
+
+	if (!NT_STATUS_IS_ERR(result)) {
+		*idx = r.idx;
+	}
+
+	return result;
+}
+
+
 /* Lookup rids.  Note that NT4 seems to crash if more than ~1000 rids are
    looked up in one packet. */
 

Modified: branches/SAMBA_3_0/source/rpcclient/cmd_samr.c
===================================================================
--- branches/SAMBA_3_0/source/rpcclient/cmd_samr.c	2006-10-16 23:28:48 UTC (rev 19354)
+++ branches/SAMBA_3_0/source/rpcclient/cmd_samr.c	2006-10-16 23:42:15 UTC (rev 19355)
@@ -1370,9 +1370,10 @@
 
 /* Query display info index */
 
-static NTSTATUS cmd_samr_get_dispenum_index(struct rpc_pipe_client *cli, 
-					    TALLOC_CTX *mem_ctx,
-					    int argc, const char **argv)
+static NTSTATUS cmd_samr_get_dispenum_index_int(struct rpc_pipe_client *cli, 
+						TALLOC_CTX *mem_ctx,
+						int argc, const char **argv,
+						int opcode)
 {
 	POLICY_HND connect_pol, domain_pol;
 	NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
@@ -1381,21 +1382,22 @@
 	uint32 idx;
 
 	if (argc < 2 || argc > 3) {
-		printf("Usage: %s mame [info level]\n", argv[0]);
+		printf("Usage: %s name [info level]\n", argv[0]);
 		return NT_STATUS_OK;
 	}
 
-	if (argc >= 3)
+	if (argc >= 3) {
 		sscanf(argv[2], "%hd", &info_level);
-        
+	}
 
 	/* Get sam policy handle */
 
 	result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, 
 				   &connect_pol);
 
-	if (!NT_STATUS_IS_OK(result))
+	if (!NT_STATUS_IS_OK(result)) {
 		goto done;
+	}
 
 	/* Get domain policy handle */
 
@@ -1403,18 +1405,31 @@
 					 access_mask, 
 					 &domain_sid, &domain_pol);
 
-	if (!NT_STATUS_IS_OK(result))
+	if (!NT_STATUS_IS_OK(result)) {
 		goto done;
+	}
 
 	/* Query display info index */
 
-	result = rpccli_samr_get_dispenum_index(cli, mem_ctx, &domain_pol,
-						info_level, argv[1], &idx);
-	if (!NT_STATUS_IS_OK(result)) {
+	switch (opcode) {
+	case SAMR_GET_DISPENUM_INDEX:
+		result = rpccli_samr_get_dispenum_index(cli, mem_ctx, &domain_pol,
+							info_level, argv[1], &idx);
+		break;
+	case SAMR_GET_DISPENUM_INDEX2:
+		result = rpccli_samr_get_dispenum_index2(cli, mem_ctx, &domain_pol,
+							info_level, argv[1], &idx);
+		break;
+	default:
+		printf("unknown opcode\n");
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+	
+	if (NT_STATUS_IS_ERR(result)) {
 		goto done;
 	};
 
-	printf("idx is: %d\n", idx);
+	printf("idx is: %d (0x%08x)\n", idx, idx);
 
 	rpccli_samr_close(cli, mem_ctx, &domain_pol);
 	rpccli_samr_close(cli, mem_ctx, &connect_pol);
@@ -1422,8 +1437,24 @@
 	return result;
 }
 
+/* Query display info index */
 
+static NTSTATUS cmd_samr_get_dispenum_index(struct rpc_pipe_client *cli, 
+					    TALLOC_CTX *mem_ctx,
+					    int argc, const char **argv)
+{
+	return cmd_samr_get_dispenum_index_int(cli, mem_ctx, argc, argv, SAMR_GET_DISPENUM_INDEX);
+}
 
+/* Query display info index2 */
+
+static NTSTATUS cmd_samr_get_dispenum_index2(struct rpc_pipe_client *cli, 
+					     TALLOC_CTX *mem_ctx,
+					     int argc, const char **argv)
+{
+	return cmd_samr_get_dispenum_index_int(cli, mem_ctx, argc, argv, SAMR_GET_DISPENUM_INDEX2);
+}
+
 /* Query domain info */
 
 static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli, 
@@ -2230,6 +2261,7 @@
 	{ "querydispinfo2", 	RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo2, 	NULL, PI_SAMR, NULL,	"Query display info 2",      "" },
 	{ "querydispinfo3", 	RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo3, 	NULL, PI_SAMR, NULL,	"Query display info 3",      "" },
 	{ "getdispenumindex", 	RPC_RTYPE_NTSTATUS, cmd_samr_get_dispenum_index, 	NULL, PI_SAMR, NULL,	"Query display info index",      "" },
+	{ "getdispenumindex2", 	RPC_RTYPE_NTSTATUS, cmd_samr_get_dispenum_index2, 	NULL, PI_SAMR, NULL,	"Query display info index",      "" },
 	{ "querydominfo", 	RPC_RTYPE_NTSTATUS, cmd_samr_query_dominfo, 	NULL, PI_SAMR, NULL,	"Query domain info",       "" },
 	{ "enumdomusers",      RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users,       NULL, PI_SAMR, NULL,	"Enumerate domain users", "" },
 	{ "enumdomgroups",      RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups,       NULL, PI_SAMR, NULL,	"Enumerate domain groups", "" },



More information about the samba-cvs mailing list