summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2006-10-16 23:42:15 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:31 -0500
commitdbcb4b12669fee8726b1b9a194ac508afd5f237a (patch)
tree9f21e8204e519723213f87c0bcf71d170872f896 /source3
parent8b31fccafe3bdae9407d69c0fa5061cfa6ffda3f (diff)
downloadsamba-dbcb4b12669fee8726b1b9a194ac508afd5f237a.tar.gz
samba-dbcb4b12669fee8726b1b9a194ac508afd5f237a.tar.bz2
samba-dbcb4b12669fee8726b1b9a194ac508afd5f237a.zip
r19355: Add getdispenumindex2 wrapper for rpcclient.
Guenther (This used to be commit 27c35848ebc6d72fd4fccbb6597b63787230f80c)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/rpc_samr.h2
-rw-r--r--source3/rpc_client/cli_samr.c51
-rw-r--r--source3/rpcclient/cmd_samr.c56
3 files changed, 91 insertions, 18 deletions
diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h
index a561b64cd6..2d931e67fc 100644
--- a/source3/include/rpc_samr.h
+++ b/source3/include/rpc_samr.h
@@ -130,7 +130,7 @@ SamrTestPrivateFunctionsUser
#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 */
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index fceafeca85..7a4d9fd58a 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -1459,7 +1459,7 @@ NTSTATUS rpccli_samr_query_dispinfo(struct rpc_pipe_client *cli,
/* 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 @@ NTSTATUS rpccli_samr_query_dispinfo2(struct rpc_pipe_client *cli,
/* 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 @@ NTSTATUS rpccli_samr_query_dispinfo3(struct rpc_pipe_client *cli,
/* 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,9 +1610,50 @@ NTSTATUS rpccli_samr_get_dispenum_index(struct rpc_pipe_client *cli,
*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;
}
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index a899efb64b..c65e466fe5 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1370,9 +1370,10 @@ static NTSTATUS cmd_samr_query_dispinfo3(struct rpc_pipe_client *cli,
/* 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 @@ static NTSTATUS cmd_samr_get_dispenum_index(struct rpc_pipe_client *cli,
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 @@ static NTSTATUS cmd_samr_get_dispenum_index(struct rpc_pipe_client *cli,
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,7 +1437,23 @@ static NTSTATUS cmd_samr_get_dispenum_index(struct rpc_pipe_client *cli,
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 */
@@ -2230,6 +2261,7 @@ struct cmd_set samr_commands[] = {
{ "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", "" },