From 9e7c6f12fdb6a8ce198359572bb9e69c7d46530a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 30 Aug 2009 09:41:43 +0200 Subject: w3:winbind: Convert WINBINDD_ALLOCATE_UID to the new API --- source3/librpc/gen_ndr/cli_wbint.c | 157 +++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) (limited to 'source3/librpc/gen_ndr/cli_wbint.c') diff --git a/source3/librpc/gen_ndr/cli_wbint.c b/source3/librpc/gen_ndr/cli_wbint.c index 3b683a73c3..710e503e3c 100644 --- a/source3/librpc/gen_ndr/cli_wbint.c +++ b/source3/librpc/gen_ndr/cli_wbint.c @@ -1162,6 +1162,163 @@ NTSTATUS rpccli_wbint_Gid2Sid(struct rpc_pipe_client *cli, return r.out.result; } +struct rpccli_wbint_AllocateUid_state { + struct wbint_AllocateUid orig; + struct wbint_AllocateUid tmp; + TALLOC_CTX *out_mem_ctx; + NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx); +}; + +static void rpccli_wbint_AllocateUid_done(struct tevent_req *subreq); + +struct tevent_req *rpccli_wbint_AllocateUid_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + uint64_t *_uid /* [out] [ref] */) +{ + struct tevent_req *req; + struct rpccli_wbint_AllocateUid_state *state; + struct tevent_req *subreq; + + req = tevent_req_create(mem_ctx, &state, + struct rpccli_wbint_AllocateUid_state); + if (req == NULL) { + return NULL; + } + state->out_mem_ctx = NULL; + state->dispatch_recv = cli->dispatch_recv; + + /* In parameters */ + + /* Out parameters */ + state->orig.out.uid = _uid; + + /* Result */ + ZERO_STRUCT(state->orig.out.result); + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_AllocateUid, &state->orig); + } + + state->out_mem_ctx = talloc_named_const(state, 0, + "rpccli_wbint_AllocateUid_out_memory"); + if (tevent_req_nomem(state->out_mem_ctx, req)) { + return tevent_req_post(req, ev); + } + + /* make a temporary copy, that we pass to the dispatch function */ + state->tmp = state->orig; + + subreq = cli->dispatch_send(state, ev, cli, + &ndr_table_wbint, + NDR_WBINT_ALLOCATEUID, + &state->tmp); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, rpccli_wbint_AllocateUid_done, req); + return req; +} + +static void rpccli_wbint_AllocateUid_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct rpccli_wbint_AllocateUid_state *state = tevent_req_data( + req, struct rpccli_wbint_AllocateUid_state); + NTSTATUS status; + TALLOC_CTX *mem_ctx; + + if (state->out_mem_ctx) { + mem_ctx = state->out_mem_ctx; + } else { + mem_ctx = state; + } + + status = state->dispatch_recv(subreq, mem_ctx); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; + } + + /* Copy out parameters */ + *state->orig.out.uid = *state->tmp.out.uid; + + /* Copy result */ + state->orig.out.result = state->tmp.out.result; + + /* Reset temporary structure */ + ZERO_STRUCT(state->tmp); + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_AllocateUid, &state->orig); + } + + tevent_req_done(req); +} + +NTSTATUS rpccli_wbint_AllocateUid_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result) +{ + struct rpccli_wbint_AllocateUid_state *state = tevent_req_data( + req, struct rpccli_wbint_AllocateUid_state); + NTSTATUS status; + + if (tevent_req_is_nterror(req, &status)) { + tevent_req_received(req); + return status; + } + + /* Steal possbile out parameters to the callers context */ + talloc_steal(mem_ctx, state->out_mem_ctx); + + /* Return result */ + *result = state->orig.out.result; + + tevent_req_received(req); + return NT_STATUS_OK; +} + +NTSTATUS rpccli_wbint_AllocateUid(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + uint64_t *uid /* [out] [ref] */) +{ + struct wbint_AllocateUid r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_AllocateUid, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_wbint, + NDR_WBINT_ALLOCATEUID, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_AllocateUid, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *uid = *r.out.uid; + + /* Return result */ + return r.out.result; +} + struct rpccli_wbint_QueryUser_state { struct wbint_QueryUser orig; struct wbint_QueryUser tmp; -- cgit