diff options
author | Volker Lendecke <vl@samba.org> | 2009-08-27 19:54:18 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-08-29 19:42:27 +0200 |
commit | 2555c12bcefa212d482c9acaa5ae87b6107fa1a2 (patch) | |
tree | b2ebcbf8afa7b73d570ce7ca346efd2a077c53ed /source3/librpc | |
parent | 50d9fb42fc771e07326f3f47103676f2ef88107e (diff) | |
download | samba-2555c12bcefa212d482c9acaa5ae87b6107fa1a2.tar.gz samba-2555c12bcefa212d482c9acaa5ae87b6107fa1a2.tar.xz samba-2555c12bcefa212d482c9acaa5ae87b6107fa1a2.zip |
s3:winbind: Add async QueryGroupList
Diffstat (limited to 'source3/librpc')
-rw-r--r-- | source3/librpc/gen_ndr/cli_wbint.c | 157 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/cli_wbint.h | 10 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_wbint.c | 71 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_wbint.h | 9 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_wbint.c | 93 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/srv_wbint.h | 2 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/wbint.h | 9 | ||||
-rw-r--r-- | source3/librpc/idl/wbint.idl | 4 |
8 files changed, 351 insertions, 4 deletions
diff --git a/source3/librpc/gen_ndr/cli_wbint.c b/source3/librpc/gen_ndr/cli_wbint.c index 55f3b3a5f7a..3b683a73c3f 100644 --- a/source3/librpc/gen_ndr/cli_wbint.c +++ b/source3/librpc/gen_ndr/cli_wbint.c @@ -2124,6 +2124,163 @@ NTSTATUS rpccli_wbint_QueryUserList(struct rpc_pipe_client *cli, return r.out.result; } +struct rpccli_wbint_QueryGroupList_state { + struct wbint_QueryGroupList orig; + struct wbint_QueryGroupList tmp; + TALLOC_CTX *out_mem_ctx; + NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx); +}; + +static void rpccli_wbint_QueryGroupList_done(struct tevent_req *subreq); + +struct tevent_req *rpccli_wbint_QueryGroupList_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + struct wbint_Principals *_groups /* [out] [ref] */) +{ + struct tevent_req *req; + struct rpccli_wbint_QueryGroupList_state *state; + struct tevent_req *subreq; + + req = tevent_req_create(mem_ctx, &state, + struct rpccli_wbint_QueryGroupList_state); + if (req == NULL) { + return NULL; + } + state->out_mem_ctx = NULL; + state->dispatch_recv = cli->dispatch_recv; + + /* In parameters */ + + /* Out parameters */ + state->orig.out.groups = _groups; + + /* Result */ + ZERO_STRUCT(state->orig.out.result); + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_QueryGroupList, &state->orig); + } + + state->out_mem_ctx = talloc_named_const(state, 0, + "rpccli_wbint_QueryGroupList_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_QUERYGROUPLIST, + &state->tmp); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, rpccli_wbint_QueryGroupList_done, req); + return req; +} + +static void rpccli_wbint_QueryGroupList_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct rpccli_wbint_QueryGroupList_state *state = tevent_req_data( + req, struct rpccli_wbint_QueryGroupList_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.groups = *state->tmp.out.groups; + + /* 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_QueryGroupList, &state->orig); + } + + tevent_req_done(req); +} + +NTSTATUS rpccli_wbint_QueryGroupList_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result) +{ + struct rpccli_wbint_QueryGroupList_state *state = tevent_req_data( + req, struct rpccli_wbint_QueryGroupList_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_QueryGroupList(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct wbint_Principals *groups /* [out] [ref] */) +{ + struct wbint_QueryGroupList r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_QueryGroupList, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_wbint, + NDR_WBINT_QUERYGROUPLIST, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_QueryGroupList, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *groups = *r.out.groups; + + /* Return result */ + return r.out.result; +} + struct rpccli_wbint_DsGetDcName_state { struct wbint_DsGetDcName orig; struct wbint_DsGetDcName tmp; diff --git a/source3/librpc/gen_ndr/cli_wbint.h b/source3/librpc/gen_ndr/cli_wbint.h index 7f8cb12edd5..cf9166a6cb6 100644 --- a/source3/librpc/gen_ndr/cli_wbint.h +++ b/source3/librpc/gen_ndr/cli_wbint.h @@ -172,6 +172,16 @@ NTSTATUS rpccli_wbint_QueryUserList_recv(struct tevent_req *req, NTSTATUS rpccli_wbint_QueryUserList(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct wbint_userinfos *users /* [out] [ref] */); +struct tevent_req *rpccli_wbint_QueryGroupList_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + struct wbint_Principals *_groups /* [out] [ref] */); +NTSTATUS rpccli_wbint_QueryGroupList_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result); +NTSTATUS rpccli_wbint_QueryGroupList(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct wbint_Principals *groups /* [out] [ref] */); struct tevent_req *rpccli_wbint_DsGetDcName_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct rpc_pipe_client *cli, diff --git a/source3/librpc/gen_ndr/ndr_wbint.c b/source3/librpc/gen_ndr/ndr_wbint.c index 681d1da492e..9dc9e6fcfb2 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.c +++ b/source3/librpc/gen_ndr/ndr_wbint.c @@ -1691,6 +1691,67 @@ _PUBLIC_ void ndr_print_wbint_QueryUserList(struct ndr_print *ndr, const char *n ndr->depth--; } +static enum ndr_err_code ndr_push_wbint_QueryGroupList(struct ndr_push *ndr, int flags, const struct wbint_QueryGroupList *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + if (r->out.groups == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_wbint_Principals(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.groups)); + NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_wbint_QueryGroupList(struct ndr_pull *ndr, int flags, struct wbint_QueryGroupList *r) +{ + TALLOC_CTX *_mem_save_groups_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_PULL_ALLOC(ndr, r->out.groups); + ZERO_STRUCTP(r->out.groups); + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.groups); + } + _mem_save_groups_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.groups, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_wbint_Principals(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.groups)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_groups_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_wbint_QueryGroupList(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QueryGroupList *r) +{ + ndr_print_struct(ndr, name, "wbint_QueryGroupList"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "wbint_QueryGroupList"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "wbint_QueryGroupList"); + ndr->depth++; + ndr_print_ptr(ndr, "groups", r->out.groups); + ndr->depth++; + ndr_print_wbint_Principals(ndr, "groups", r->out.groups); + ndr->depth--; + ndr_print_NTSTATUS(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + static enum ndr_err_code ndr_push_wbint_DsGetDcName(struct ndr_push *ndr, int flags, const struct wbint_DsGetDcName *r) { if (flags & NDR_IN) { @@ -2034,6 +2095,14 @@ static const struct ndr_interface_call wbint_calls[] = { false, }, { + "wbint_QueryGroupList", + sizeof(struct wbint_QueryGroupList), + (ndr_push_flags_fn_t) ndr_push_wbint_QueryGroupList, + (ndr_pull_flags_fn_t) ndr_pull_wbint_QueryGroupList, + (ndr_print_function_t) ndr_print_wbint_QueryGroupList, + false, + }, + { "wbint_DsGetDcName", sizeof(struct wbint_DsGetDcName), (ndr_push_flags_fn_t) ndr_push_wbint_DsGetDcName, @@ -2078,7 +2147,7 @@ const struct ndr_interface_table ndr_table_wbint = { NDR_WBINT_VERSION }, .helpstring = NDR_WBINT_HELPSTRING, - .num_calls = 15, + .num_calls = 16, .calls = wbint_calls, .endpoints = &wbint_endpoints, .authservices = &wbint_authservices diff --git a/source3/librpc/gen_ndr/ndr_wbint.h b/source3/librpc/gen_ndr/ndr_wbint.h index d183e348e6e..bdcb23b2beb 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.h +++ b/source3/librpc/gen_ndr/ndr_wbint.h @@ -37,11 +37,13 @@ extern const struct ndr_interface_table ndr_table_wbint; #define NDR_WBINT_QUERYUSERLIST (0x0c) -#define NDR_WBINT_DSGETDCNAME (0x0d) +#define NDR_WBINT_QUERYGROUPLIST (0x0d) -#define NDR_WBINT_LOOKUPRIDS (0x0e) +#define NDR_WBINT_DSGETDCNAME (0x0e) -#define NDR_WBINT_CALL_COUNT (15) +#define NDR_WBINT_LOOKUPRIDS (0x0f) + +#define NDR_WBINT_CALL_COUNT (16) enum ndr_err_code ndr_push_wbint_userinfo(struct ndr_push *ndr, int ndr_flags, const struct wbint_userinfo *r); enum ndr_err_code ndr_pull_wbint_userinfo(struct ndr_pull *ndr, int ndr_flags, struct wbint_userinfo *r); void ndr_print_wbint_userinfo(struct ndr_print *ndr, const char *name, const struct wbint_userinfo *r); @@ -73,6 +75,7 @@ void ndr_print_wbint_LookupUserGroups(struct ndr_print *ndr, const char *name, i void ndr_print_wbint_QuerySequenceNumber(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QuerySequenceNumber *r); void ndr_print_wbint_LookupGroupMembers(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupGroupMembers *r); void ndr_print_wbint_QueryUserList(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QueryUserList *r); +void ndr_print_wbint_QueryGroupList(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QueryGroupList *r); void ndr_print_wbint_DsGetDcName(struct ndr_print *ndr, const char *name, int flags, const struct wbint_DsGetDcName *r); void ndr_print_wbint_LookupRids(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupRids *r); #endif /* _HEADER_NDR_wbint */ diff --git a/source3/librpc/gen_ndr/srv_wbint.c b/source3/librpc/gen_ndr/srv_wbint.c index 2cc750c4b57..522230e8c46 100644 --- a/source3/librpc/gen_ndr/srv_wbint.c +++ b/source3/librpc/gen_ndr/srv_wbint.c @@ -1064,6 +1064,86 @@ static bool api_wbint_QueryUserList(pipes_struct *p) return true; } +static bool api_wbint_QueryGroupList(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct wbint_QueryGroupList *r; + + call = &ndr_table_wbint.calls[NDR_WBINT_QUERYGROUPLIST]; + + r = talloc(talloc_tos(), struct wbint_QueryGroupList); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_QueryGroupList, r); + } + + ZERO_STRUCT(r->out); + r->out.groups = talloc_zero(r, struct wbint_Principals); + if (r->out.groups == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _wbint_QueryGroupList(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_QueryGroupList, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + static bool api_wbint_DsGetDcName(pipes_struct *p) { const struct ndr_interface_call *call; @@ -1241,6 +1321,7 @@ static struct api_struct api_wbint_cmds[] = {"WBINT_QUERYSEQUENCENUMBER", NDR_WBINT_QUERYSEQUENCENUMBER, api_wbint_QuerySequenceNumber}, {"WBINT_LOOKUPGROUPMEMBERS", NDR_WBINT_LOOKUPGROUPMEMBERS, api_wbint_LookupGroupMembers}, {"WBINT_QUERYUSERLIST", NDR_WBINT_QUERYUSERLIST, api_wbint_QueryUserList}, + {"WBINT_QUERYGROUPLIST", NDR_WBINT_QUERYGROUPLIST, api_wbint_QueryGroupList}, {"WBINT_DSGETDCNAME", NDR_WBINT_DSGETDCNAME, api_wbint_DsGetDcName}, {"WBINT_LOOKUPRIDS", NDR_WBINT_LOOKUPRIDS, api_wbint_LookupRids}, }; @@ -1430,6 +1511,18 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co return NT_STATUS_OK; } + case NDR_WBINT_QUERYGROUPLIST: { + struct wbint_QueryGroupList *r = (struct wbint_QueryGroupList *)_r; + ZERO_STRUCT(r->out); + r->out.groups = talloc_zero(mem_ctx, struct wbint_Principals); + if (r->out.groups == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _wbint_QueryGroupList(cli->pipes_struct, r); + return NT_STATUS_OK; + } + case NDR_WBINT_DSGETDCNAME: { struct wbint_DsGetDcName *r = (struct wbint_DsGetDcName *)_r; ZERO_STRUCT(r->out); diff --git a/source3/librpc/gen_ndr/srv_wbint.h b/source3/librpc/gen_ndr/srv_wbint.h index 1203a3f26ed..c91d3c8374a 100644 --- a/source3/librpc/gen_ndr/srv_wbint.h +++ b/source3/librpc/gen_ndr/srv_wbint.h @@ -14,6 +14,7 @@ NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, struct wbint_LookupUserGroups NTSTATUS _wbint_QuerySequenceNumber(pipes_struct *p, struct wbint_QuerySequenceNumber *r); NTSTATUS _wbint_LookupGroupMembers(pipes_struct *p, struct wbint_LookupGroupMembers *r); NTSTATUS _wbint_QueryUserList(pipes_struct *p, struct wbint_QueryUserList *r); +NTSTATUS _wbint_QueryGroupList(pipes_struct *p, struct wbint_QueryGroupList *r); NTSTATUS _wbint_DsGetDcName(pipes_struct *p, struct wbint_DsGetDcName *r); NTSTATUS _wbint_LookupRids(pipes_struct *p, struct wbint_LookupRids *r); void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns); @@ -31,6 +32,7 @@ NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, struct wbint_LookupUserGroups NTSTATUS _wbint_QuerySequenceNumber(pipes_struct *p, struct wbint_QuerySequenceNumber *r); NTSTATUS _wbint_LookupGroupMembers(pipes_struct *p, struct wbint_LookupGroupMembers *r); NTSTATUS _wbint_QueryUserList(pipes_struct *p, struct wbint_QueryUserList *r); +NTSTATUS _wbint_QueryGroupList(pipes_struct *p, struct wbint_QueryGroupList *r); NTSTATUS _wbint_DsGetDcName(pipes_struct *p, struct wbint_DsGetDcName *r); NTSTATUS _wbint_LookupRids(pipes_struct *p, struct wbint_LookupRids *r); NTSTATUS rpc_wbint_init(void); diff --git a/source3/librpc/gen_ndr/wbint.h b/source3/librpc/gen_ndr/wbint.h index ddea95b7fe2..96466fdca02 100644 --- a/source3/librpc/gen_ndr/wbint.h +++ b/source3/librpc/gen_ndr/wbint.h @@ -215,6 +215,15 @@ struct wbint_QueryUserList { }; +struct wbint_QueryGroupList { + struct { + struct wbint_Principals *groups;/* [ref] */ + NTSTATUS result; + } out; + +}; + + struct wbint_DsGetDcName { struct { const char *domain_name;/* [ref,charset(UTF8)] */ diff --git a/source3/librpc/idl/wbint.idl b/source3/librpc/idl/wbint.idl index ab258c58327..cf42cb92693 100644 --- a/source3/librpc/idl/wbint.idl +++ b/source3/librpc/idl/wbint.idl @@ -119,6 +119,10 @@ interface wbint [out] wbint_userinfos *users ); + NTSTATUS wbint_QueryGroupList( + [out] wbint_Principals *groups + ); + NTSTATUS wbint_DsGetDcName( [in,string,charset(UTF8)] char *domain_name, [in,unique] GUID *domain_guid, |