summaryrefslogtreecommitdiff
path: root/source3/rpc_client/cli_samr.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_client/cli_samr.c')
-rw-r--r--source3/rpc_client/cli_samr.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index a1faade6db..41bdd0e3d1 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -546,21 +546,24 @@ BOOL samr_query_dom_info(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a SAMR enumerate groups
****************************************************************************/
-BOOL samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
+uint32 samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol,
- uint32 start_idx, uint32 size,
+ uint32 *start_idx, uint32 size,
struct acct_info **sam,
uint32 *num_sam_groups)
{
+ uint32 status = 0x0;
prs_struct data;
prs_struct rdata;
SAMR_Q_ENUM_DOM_GROUPS q_e;
- BOOL valid_pol = False;
DEBUG(4,("SAMR Enum SAM DB max size:%x\n", size));
- if (pol == NULL || num_sam_groups == NULL) return False;
+ if (pol == NULL || num_sam_groups == NULL)
+ {
+ return NT_STATUS_INVALID_PARAMETER | 0xC0000000;
+ }
/* create and send a MSRPC command with api SAMR_ENUM_DOM_GROUPS */
@@ -568,7 +571,7 @@ BOOL samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
prs_init(&rdata, 0 , 4, SAFETY_MARGIN, True );
/* store the parameters */
- make_samr_q_enum_dom_groups(&q_e, pol, start_idx, size);
+ make_samr_q_enum_dom_groups(&q_e, pol, *start_idx, size);
/* turn parameters into data stream */
samr_io_q_enum_dom_groups("", &q_e, &data, 0);
@@ -581,40 +584,37 @@ BOOL samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
samr_io_r_enum_dom_groups("", &r_e, &rdata, 0);
+ status = r_e.status;
p = rdata.offset != 0;
if (p && r_e.status != 0)
{
/* report error code */
DEBUG(4,("SAMR_R_ENUM_DOM_GROUPS: %s\n", get_nt_error_msg(r_e.status)));
- p = False;
+ p = (r_e.status == STATUS_MORE_ENTRIES);
}
if (p)
{
- uint32 i;
- int name_idx = 0;
-
- *num_sam_groups = r_e.num_entries2;
- if (*num_sam_groups > MAX_SAM_ENTRIES)
- {
- *num_sam_groups = MAX_SAM_ENTRIES;
- DEBUG(2,("samr_enum_dom_groups: sam group entries limited to %d\n",
- *num_sam_groups));
- }
+ uint32 i = (*num_sam_groups);
+ uint32 j = 0;
+ uint32 name_idx = 0;
- *sam = (struct acct_info*) malloc(sizeof(struct acct_info) * (*num_sam_groups));
+ (*num_sam_groups) += r_e.num_entries2;
+ (*sam) = (struct acct_info*) Realloc((*sam),
+ sizeof(struct acct_info) * (*num_sam_groups));
if ((*sam) == NULL)
{
- *num_sam_groups = 0;
+ (*num_sam_groups) = 0;
+ i = 0;
}
- for (i = 0; i < *num_sam_groups; i++)
+ for (j = 0; i < (*num_sam_groups) && j < r_e.num_entries2; j++, i++)
{
- (*sam)[i].rid = r_e.sam[i].rid;
+ (*sam)[i].rid = r_e.sam[j].rid;
(*sam)[i].acct_name[0] = 0;
(*sam)[i].acct_desc[0] = 0;
- if (r_e.sam[i].hdr_name.buffer)
+ if (r_e.sam[j].hdr_name.buffer)
{
unistr2_to_ascii((*sam)[i].acct_name, &r_e.uni_grp_name[name_idx], sizeof((*sam)[i].acct_name)-1);
name_idx++;
@@ -622,14 +622,19 @@ BOOL samr_enum_dom_groups(struct cli_state *cli, uint16 fnum,
DEBUG(5,("samr_enum_dom_groups: idx: %4d rid: %8x acct: %s\n",
i, (*sam)[i].rid, (*sam)[i].acct_name));
}
- valid_pol = True;
+ (*start_idx) = r_e.next_idx;
+ }
+ else if (status == 0x0)
+ {
+ status = NT_STATUS_INVALID_PARAMETER | 0xC0000000;
}
+
}
prs_mem_free(&data );
prs_mem_free(&rdata );
- return valid_pol;
+ return status;
}
/****************************************************************************
@@ -735,7 +740,6 @@ uint32 samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
prs_struct rdata;
SAMR_Q_ENUM_DOM_USERS q_e;
- BOOL valid_pol = False;
DEBUG(4,("SAMR Enum SAM DB max size:%x\n", size));
@@ -803,7 +807,6 @@ uint32 samr_enum_dom_users(struct cli_state *cli, uint16 fnum,
DEBUG(5,("samr_enum_dom_users: idx: %4d rid: %8x acct: %s\n",
i, (*sam)[i].rid, (*sam)[i].acct_name));
}
- valid_pol = True;
(*start_idx) = r_e.next_idx;
}
else if (status == 0x0)