summaryrefslogtreecommitdiff
path: root/source3/rpc_client
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-10-28 20:34:28 +0000
committerLuke Leighton <lkcl@samba.org>1999-10-28 20:34:28 +0000
commit326b011b2df0dc83aa59fda9ab7dd8bcc0909a2e (patch)
tree7b5cda9cfd60f3a6d7770e9c43f9ed9923b96ce2 /source3/rpc_client
parentc7c77cbfd75052c73723b1b6783f254d2ff49e65 (diff)
downloadsamba-326b011b2df0dc83aa59fda9ab7dd8bcc0909a2e.tar.gz
samba-326b011b2df0dc83aa59fda9ab7dd8bcc0909a2e.tar.bz2
samba-326b011b2df0dc83aa59fda9ab7dd8bcc0909a2e.zip
restructuring sam enum dom groups code to do multiple calls to
sam_enum_dom_groups. enum dom aliases is still left to do (dom users already done). (This used to be commit 8d181924cedb7a2d34a0b40cee600494665fe923)
Diffstat (limited to 'source3/rpc_client')
-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)