1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

r18677: quickly add samr_GetDisplayEnumerationIndex for debugging to rpcclient.

Guenther
This commit is contained in:
Günther Deschner 2006-09-19 15:53:44 +00:00 committed by Gerald (Jerry) Carter
parent 65013a8d9e
commit bd546edc48
4 changed files with 194 additions and 2 deletions

View File

@ -121,7 +121,7 @@ SamrTestPrivateFunctionsUser
#define SAMR_QUERY_USERGROUPS 0x27
#define SAMR_QUERY_DISPINFO 0x28
#define SAMR_UNKNOWN_29 0x29
#define SAMR_GET_DISPENUM_INDEX 0x29
#define SAMR_UNKNOWN_2a 0x2a
#define SAMR_UNKNOWN_2b 0x2b
#define SAMR_GET_USRDOM_PWINFO 0x2c
@ -1047,6 +1047,22 @@ typedef struct r_samr_query_dispinfo_info
} SAMR_R_QUERY_DISPINFO;
/* SAMR_Q_GET_DISPENUM_INDEX */
typedef struct q_samr_get_dispenum_index
{
POLICY_HND domain_pol;
uint16 switch_level;
LSA_STRING name;
} SAMR_Q_GET_DISPENUM_INDEX;
/* SAMR_R_GET_DISPENUM_INDEX */
typedef struct r_samr_get_dispenum_index
{
uint32 idx;
NTSTATUS status;
} SAMR_R_GET_DISPENUM_INDEX;
/* SAMR_Q_DELETE_DOM_GROUP - delete domain group */
typedef struct q_samr_delete_dom_group_info

View File

@ -1576,6 +1576,49 @@ NTSTATUS rpccli_samr_query_dispinfo3(struct rpc_pipe_client *cli,
return result;
}
/* Query display info index */
NTSTATUS rpccli_samr_get_dispenum_index(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_index 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_INDEX,
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_OK(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. */

View File

@ -2172,6 +2172,76 @@ BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u,
return True;
}
/*******************************************************************
inits a SAMR_Q_GET_DISPENUM_INDEX structure.
********************************************************************/
void init_samr_q_get_dispenum_index(SAMR_Q_GET_DISPENUM_INDEX * q_e, POLICY_HND *pol,
uint16 switch_level, const char *name)
{
DEBUG(5, ("init_samr_q_get_dispenum_index\n"));
q_e->domain_pol = *pol;
q_e->switch_level = switch_level;
init_lsa_string(&q_e->name, name);
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
BOOL samr_io_q_get_dispenum_index(const char *desc, SAMR_Q_GET_DISPENUM_INDEX * q_e,
prs_struct *ps, int depth)
{
if (q_e == NULL)
return False;
prs_debug(ps, depth, desc, "samr_io_q_get_dispenum_index");
depth++;
if(!prs_align(ps))
return False;
if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))
return False;
if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))
return False;
if (!smb_io_lsa_string("name", &q_e->name, ps, depth))
return False;
return True;
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
BOOL samr_io_r_get_dispenum_index(const char *desc, SAMR_R_GET_DISPENUM_INDEX * r_u,
prs_struct *ps, int depth)
{
if (r_u == NULL)
return False;
prs_debug(ps, depth, desc, "samr_io_r_get_dispenum_index");
depth++;
if(!prs_align(ps))
return False;
if(!prs_uint32("idx", ps, depth, &r_u->idx))
return False;
if(!prs_ntstatus("status", ps, depth, &r_u->status))
return False;
return True;
}
/*******************************************************************
inits a SAMR_Q_OPEN_GROUP structure.
********************************************************************/

View File

@ -1192,7 +1192,7 @@ static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli,
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries, i;
uint32 start_idx=0, max_entries=250, max_size = (uint32) -1, num_entries, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
uint32 info_level = 1;
SAM_DISPINFO_CTR ctr;
@ -1228,6 +1228,7 @@ static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli,
if (argc >= 6)
sscanf(argv[5], "%x", &access_mask);
/* Get sam policy handle */
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
@ -1360,6 +1361,67 @@ static NTSTATUS cmd_samr_query_dispinfo3(struct rpc_pipe_client *cli,
{
return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO3);
}
/* 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)
{
POLICY_HND connect_pol, domain_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
uint16 info_level = 1;
uint32 idx;
const char *name;
if (argc > 6) {
printf("Usage: %s mame [info level]\n", argv[0]);
return NT_STATUS_OK;
}
if (argc >= 2)
name = argv[1];
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))
goto done;
/* Get domain policy handle */
result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
access_mask,
&domain_sid, &domain_pol);
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, name, &idx);
if (!NT_STATUS_IS_OK(result)) {
goto done;
};
printf("idx is: %d\n", idx);
rpccli_samr_close(cli, mem_ctx, &domain_pol);
rpccli_samr_close(cli, mem_ctx, &connect_pol);
done:
return result;
}
/* Query domain info */
static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
@ -2165,6 +2227,7 @@ struct cmd_set samr_commands[] = {
{ "querydispinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo, NULL, PI_SAMR, NULL, "Query display info", "" },
{ "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", "" },
{ "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", "" },