summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-02-26 00:06:59 +0000
committerTim Potter <tpot@samba.org>2003-02-26 00:06:59 +0000
commit681c932a758f471180da531fd6309d75737800cd (patch)
tree31e663deb971e6436c975ec553ab3773690ced34
parent2057d3c39fbd7739406dbe81229d2a760a9a5ae1 (diff)
downloadsamba-681c932a758f471180da531fd6309d75737800cd.tar.gz
samba-681c932a758f471180da531fd6309d75737800cd.tar.bz2
samba-681c932a758f471180da531fd6309d75737800cd.zip
Merge of exit path cleanup for EnumDomainUsers.
(This used to be commit c2e9673328b2d989f13626632442f095727a03c6)
-rw-r--r--source3/rpc_client/cli_samr.c64
1 files changed, 23 insertions, 41 deletions
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index f0035ca22e..c451ee2e42 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -561,8 +561,8 @@ NTSTATUS cli_samr_enum_dom_users(struct cli_state *cli, TALLOC_CTX *mem_ctx,
uint32 size, char ***dom_users, uint32 **rids,
uint32 *num_dom_users)
{
- prs_struct qdata;
- prs_struct rdata;
+ prs_struct qbuf;
+ prs_struct rbuf;
SAMR_Q_ENUM_DOM_USERS q;
SAMR_R_ENUM_DOM_USERS r;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
@@ -571,51 +571,33 @@ NTSTATUS cli_samr_enum_dom_users(struct cli_state *cli, TALLOC_CTX *mem_ctx,
ZERO_STRUCT(q);
ZERO_STRUCT(r);
- if (cli == NULL || pol == NULL)
- return result;
-
- /* initialise parse structures */
- prs_init(&qdata, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
- prs_init(&rdata, 0, mem_ctx, UNMARSHALL);
-
- DEBUG(4, ("SAMR Enum Domain Users. start_idx: %d, acb: %d, size: %d\n",
- *start_idx, acb_mask, size));
+ /* Initialise parse structures */
+
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
- /* fill query structure with parameters */
+ /* Fill query structure with parameters */
+
init_samr_q_enum_dom_users(&q, pol, *start_idx, acb_mask, 0, size);
- /* prepare query stream */
- if (!samr_io_q_enum_dom_users("", &q, &qdata, 0)) {
- prs_mem_free(&qdata);
- prs_mem_free(&rdata);
- return result;
- }
-
- /* send rpc call over the pipe */
- if (!rpc_api_pipe_req(cli, SAMR_ENUM_DOM_USERS, &qdata, &rdata)) {
- prs_mem_free(&qdata);
- prs_mem_free(&rdata);
- return result;
+ if (!samr_io_q_enum_dom_users("", &q, &qbuf, 0) ||
+ !rpc_api_pipe_req(cli, SAMR_ENUM_DOM_USERS, &qbuf, &rbuf)) {
+ goto done;
}
-
+
/* unpack received stream */
- if(!samr_io_r_enum_dom_users("", &r, &rdata, 0)) {
- prs_mem_free(&qdata);
- prs_mem_free(&rdata);
- result = r.status;
- return result;
- }
+
+ if(!samr_io_r_enum_dom_users("", &r, &rbuf, 0))
+ goto done;
- /* return the data obtained in response */
- if (!NT_STATUS_IS_OK(r.status) &&
- (NT_STATUS_EQUAL(r.status, STATUS_MORE_ENTRIES) ||
- NT_STATUS_EQUAL(r.status, NT_STATUS_NO_MORE_ENTRIES))) {
- return r.status;
- }
+ result = r.status;
+
+ if (!NT_STATUS_IS_OK(result) &&
+ NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES))
+ goto done;
*start_idx = r.next_idx;
*num_dom_users = r.num_entries2;
- result = r.status;
if (r.num_entries2) {
/* allocate memory needed to return received data */
@@ -641,13 +623,13 @@ NTSTATUS cli_samr_enum_dom_users(struct cli_state *cli, TALLOC_CTX *mem_ctx,
}
}
- prs_mem_free(&qdata);
- prs_mem_free(&rdata);
+done:
+ prs_mem_free(&qbuf);
+ prs_mem_free(&rbuf);
return result;
};
-
/* Enumerate domain groups */
NTSTATUS cli_samr_enum_dom_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx,