diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 1 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/cli_wbint.c | 161 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/cli_wbint.h | 12 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_wbint.c | 87 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_wbint.h | 5 | ||||
-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 | 13 | ||||
-rw-r--r-- | source3/librpc/idl/wbint.idl | 5 | ||||
-rw-r--r-- | source3/winbindd/wb_lookupusergroups.c | 99 | ||||
-rw-r--r-- | source3/winbindd/winbindd_dual_srv.c | 14 | ||||
-rw-r--r-- | source3/winbindd/winbindd_proto.h | 7 |
12 files changed, 497 insertions, 2 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 7879d939f8..974499594a 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1160,6 +1160,7 @@ WINBINDD_OBJ1 = \ winbindd/wb_gid2sid.o \ winbindd/wb_queryuser.o \ winbindd/wb_lookupuseraliases.o \ + winbindd/wb_lookupusergroups.o \ winbindd/wb_getpwsid.o \ winbindd/winbindd_lookupsid.o \ winbindd/winbindd_lookupname.o \ diff --git a/source3/librpc/gen_ndr/cli_wbint.c b/source3/librpc/gen_ndr/cli_wbint.c index 30eb8e53d4..de6b345a0e 100644 --- a/source3/librpc/gen_ndr/cli_wbint.c +++ b/source3/librpc/gen_ndr/cli_wbint.c @@ -1484,3 +1484,164 @@ NTSTATUS rpccli_wbint_LookupUserAliases(struct rpc_pipe_client *cli, return r.out.result; } +struct rpccli_wbint_LookupUserGroups_state { + struct wbint_LookupUserGroups orig; + struct wbint_LookupUserGroups tmp; + TALLOC_CTX *out_mem_ctx; + NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx); +}; + +static void rpccli_wbint_LookupUserGroups_done(struct tevent_req *subreq); + +struct tevent_req *rpccli_wbint_LookupUserGroups_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + struct dom_sid *_sid /* [in] [ref] */, + struct wbint_SidArray *_sids /* [out] [ref] */) +{ + struct tevent_req *req; + struct rpccli_wbint_LookupUserGroups_state *state; + struct tevent_req *subreq; + + req = tevent_req_create(mem_ctx, &state, + struct rpccli_wbint_LookupUserGroups_state); + if (req == NULL) { + return NULL; + } + state->out_mem_ctx = NULL; + state->dispatch_recv = cli->dispatch_recv; + + /* In parameters */ + state->orig.in.sid = _sid; + + /* Out parameters */ + state->orig.out.sids = _sids; + + /* Result */ + ZERO_STRUCT(state->orig.out.result); + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_LookupUserGroups, &state->orig); + } + + state->out_mem_ctx = talloc_named_const(state, 0, + "rpccli_wbint_LookupUserGroups_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_LOOKUPUSERGROUPS, + &state->tmp); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, rpccli_wbint_LookupUserGroups_done, req); + return req; +} + +static void rpccli_wbint_LookupUserGroups_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct rpccli_wbint_LookupUserGroups_state *state = tevent_req_data( + req, struct rpccli_wbint_LookupUserGroups_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.sids = *state->tmp.out.sids; + + /* 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_LookupUserGroups, &state->orig); + } + + tevent_req_done(req); +} + +NTSTATUS rpccli_wbint_LookupUserGroups_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result) +{ + struct rpccli_wbint_LookupUserGroups_state *state = tevent_req_data( + req, struct rpccli_wbint_LookupUserGroups_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_LookupUserGroups(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct dom_sid *sid /* [in] [ref] */, + struct wbint_SidArray *sids /* [out] [ref] */) +{ + struct wbint_LookupUserGroups r; + NTSTATUS status; + + /* In parameters */ + r.in.sid = sid; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_LookupUserGroups, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_wbint, + NDR_WBINT_LOOKUPUSERGROUPS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_LookupUserGroups, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *sids = *r.out.sids; + + /* Return result */ + return r.out.result; +} + diff --git a/source3/librpc/gen_ndr/cli_wbint.h b/source3/librpc/gen_ndr/cli_wbint.h index 80f188f4f9..e9927c1c35 100644 --- a/source3/librpc/gen_ndr/cli_wbint.h +++ b/source3/librpc/gen_ndr/cli_wbint.h @@ -126,4 +126,16 @@ NTSTATUS rpccli_wbint_LookupUserAliases(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct wbint_SidArray *sids /* [in] [ref] */, struct wbint_RidArray *rids /* [out] [ref] */); +struct tevent_req *rpccli_wbint_LookupUserGroups_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + struct dom_sid *_sid /* [in] [ref] */, + struct wbint_SidArray *_sids /* [out] [ref] */); +NTSTATUS rpccli_wbint_LookupUserGroups_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result); +NTSTATUS rpccli_wbint_LookupUserGroups(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct dom_sid *sid /* [in] [ref] */, + struct wbint_SidArray *sids /* [out] [ref] */); #endif /* __CLI_WBINT__ */ diff --git a/source3/librpc/gen_ndr/ndr_wbint.c b/source3/librpc/gen_ndr/ndr_wbint.c index 87e675edaf..5a8c1c33d7 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.c +++ b/source3/librpc/gen_ndr/ndr_wbint.c @@ -1210,6 +1210,83 @@ _PUBLIC_ void ndr_print_wbint_LookupUserAliases(struct ndr_print *ndr, const cha ndr->depth--; } +static enum ndr_err_code ndr_push_wbint_LookupUserGroups(struct ndr_push *ndr, int flags, const struct wbint_LookupUserGroups *r) +{ + if (flags & NDR_IN) { + if (r->in.sid == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->in.sid)); + } + if (flags & NDR_OUT) { + if (r->out.sids == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_wbint_SidArray(ndr, NDR_SCALARS, r->out.sids)); + NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_wbint_LookupUserGroups(struct ndr_pull *ndr, int flags, struct wbint_LookupUserGroups *r) +{ + TALLOC_CTX *_mem_save_sid_0; + TALLOC_CTX *_mem_save_sids_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.sid); + } + _mem_save_sid_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.sid, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->in.sid)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sid_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.sids); + ZERO_STRUCTP(r->out.sids); + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.sids); + } + _mem_save_sids_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.sids, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_wbint_SidArray(ndr, NDR_SCALARS, r->out.sids)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sids_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_LookupUserGroups(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupUserGroups *r) +{ + ndr_print_struct(ndr, name, "wbint_LookupUserGroups"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "wbint_LookupUserGroups"); + ndr->depth++; + ndr_print_ptr(ndr, "sid", r->in.sid); + ndr->depth++; + ndr_print_dom_sid(ndr, "sid", r->in.sid); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "wbint_LookupUserGroups"); + ndr->depth++; + ndr_print_ptr(ndr, "sids", r->out.sids); + ndr->depth++; + ndr_print_wbint_SidArray(ndr, "sids", r->out.sids); + ndr->depth--; + ndr_print_NTSTATUS(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + static const struct ndr_interface_call wbint_calls[] = { { "wbint_Ping", @@ -1283,6 +1360,14 @@ static const struct ndr_interface_call wbint_calls[] = { (ndr_print_function_t) ndr_print_wbint_LookupUserAliases, false, }, + { + "wbint_LookupUserGroups", + sizeof(struct wbint_LookupUserGroups), + (ndr_push_flags_fn_t) ndr_push_wbint_LookupUserGroups, + (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupUserGroups, + (ndr_print_function_t) ndr_print_wbint_LookupUserGroups, + false, + }, { NULL, 0, NULL, NULL, NULL, false } }; @@ -1312,7 +1397,7 @@ const struct ndr_interface_table ndr_table_wbint = { NDR_WBINT_VERSION }, .helpstring = NDR_WBINT_HELPSTRING, - .num_calls = 9, + .num_calls = 10, .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 f862fae651..6fd6b1d74d 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.h +++ b/source3/librpc/gen_ndr/ndr_wbint.h @@ -29,7 +29,9 @@ extern const struct ndr_interface_table ndr_table_wbint; #define NDR_WBINT_LOOKUPUSERALIASES (0x08) -#define NDR_WBINT_CALL_COUNT (9) +#define NDR_WBINT_LOOKUPUSERGROUPS (0x09) + +#define NDR_WBINT_CALL_COUNT (10) 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); @@ -48,4 +50,5 @@ void ndr_print_wbint_Uid2Sid(struct ndr_print *ndr, const char *name, int flags, void ndr_print_wbint_Gid2Sid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_Gid2Sid *r); void ndr_print_wbint_QueryUser(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QueryUser *r); void ndr_print_wbint_LookupUserAliases(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupUserAliases *r); +void ndr_print_wbint_LookupUserGroups(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupUserGroups *r); #endif /* _HEADER_NDR_wbint */ diff --git a/source3/librpc/gen_ndr/srv_wbint.c b/source3/librpc/gen_ndr/srv_wbint.c index 19d2d2eabf..95c0619058 100644 --- a/source3/librpc/gen_ndr/srv_wbint.c +++ b/source3/librpc/gen_ndr/srv_wbint.c @@ -744,6 +744,86 @@ static bool api_wbint_LookupUserAliases(pipes_struct *p) return true; } +static bool api_wbint_LookupUserGroups(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_LookupUserGroups *r; + + call = &ndr_table_wbint.calls[NDR_WBINT_LOOKUPUSERGROUPS]; + + r = talloc(talloc_tos(), struct wbint_LookupUserGroups); + 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_LookupUserGroups, r); + } + + ZERO_STRUCT(r->out); + r->out.sids = talloc_zero(r, struct wbint_SidArray); + if (r->out.sids == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _wbint_LookupUserGroups(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_LookupUserGroups, 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; +} + /* Tables */ static struct api_struct api_wbint_cmds[] = @@ -757,6 +837,7 @@ static struct api_struct api_wbint_cmds[] = {"WBINT_GID2SID", NDR_WBINT_GID2SID, api_wbint_Gid2Sid}, {"WBINT_QUERYUSER", NDR_WBINT_QUERYUSER, api_wbint_QueryUser}, {"WBINT_LOOKUPUSERALIASES", NDR_WBINT_LOOKUPUSERALIASES, api_wbint_LookupUserAliases}, + {"WBINT_LOOKUPUSERGROUPS", NDR_WBINT_LOOKUPUSERGROUPS, api_wbint_LookupUserGroups}, }; void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns) @@ -896,6 +977,18 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co return NT_STATUS_OK; } + case NDR_WBINT_LOOKUPUSERGROUPS: { + struct wbint_LookupUserGroups *r = (struct wbint_LookupUserGroups *)_r; + ZERO_STRUCT(r->out); + r->out.sids = talloc_zero(mem_ctx, struct wbint_SidArray); + if (r->out.sids == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _wbint_LookupUserGroups(cli->pipes_struct, r); + return NT_STATUS_OK; + } + default: return NT_STATUS_NOT_IMPLEMENTED; } diff --git a/source3/librpc/gen_ndr/srv_wbint.h b/source3/librpc/gen_ndr/srv_wbint.h index af48fa3320..20ca316375 100644 --- a/source3/librpc/gen_ndr/srv_wbint.h +++ b/source3/librpc/gen_ndr/srv_wbint.h @@ -10,6 +10,7 @@ NTSTATUS _wbint_Uid2Sid(pipes_struct *p, struct wbint_Uid2Sid *r); NTSTATUS _wbint_Gid2Sid(pipes_struct *p, struct wbint_Gid2Sid *r); NTSTATUS _wbint_QueryUser(pipes_struct *p, struct wbint_QueryUser *r); NTSTATUS _wbint_LookupUserAliases(pipes_struct *p, struct wbint_LookupUserAliases *r); +NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, struct wbint_LookupUserGroups *r); void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns); NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r); void _wbint_Ping(pipes_struct *p, struct wbint_Ping *r); @@ -21,5 +22,6 @@ NTSTATUS _wbint_Uid2Sid(pipes_struct *p, struct wbint_Uid2Sid *r); NTSTATUS _wbint_Gid2Sid(pipes_struct *p, struct wbint_Gid2Sid *r); NTSTATUS _wbint_QueryUser(pipes_struct *p, struct wbint_QueryUser *r); NTSTATUS _wbint_LookupUserAliases(pipes_struct *p, struct wbint_LookupUserAliases *r); +NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, struct wbint_LookupUserGroups *r); NTSTATUS rpc_wbint_init(void); #endif /* __SRV_WBINT__ */ diff --git a/source3/librpc/gen_ndr/wbint.h b/source3/librpc/gen_ndr/wbint.h index 6eeef0ebdf..28382ec346 100644 --- a/source3/librpc/gen_ndr/wbint.h +++ b/source3/librpc/gen_ndr/wbint.h @@ -153,4 +153,17 @@ struct wbint_LookupUserAliases { }; + +struct wbint_LookupUserGroups { + struct { + struct dom_sid *sid;/* [ref] */ + } in; + + struct { + struct wbint_SidArray *sids;/* [ref] */ + NTSTATUS result; + } out; + +}; + #endif /* _HEADER_wbint */ diff --git a/source3/librpc/idl/wbint.idl b/source3/librpc/idl/wbint.idl index 571c212ecd..f994126711 100644 --- a/source3/librpc/idl/wbint.idl +++ b/source3/librpc/idl/wbint.idl @@ -83,4 +83,9 @@ interface wbint [in] wbint_SidArray *sids, [out] wbint_RidArray *rids ); + + NTSTATUS wbint_LookupUserGroups( + [in] dom_sid *sid, + [out] wbint_SidArray *sids + ); }
\ No newline at end of file diff --git a/source3/winbindd/wb_lookupusergroups.c b/source3/winbindd/wb_lookupusergroups.c new file mode 100644 index 0000000000..4e96b45c57 --- /dev/null +++ b/source3/winbindd/wb_lookupusergroups.c @@ -0,0 +1,99 @@ +/* + Unix SMB/CIFS implementation. + async lookupusergroups + Copyright (C) Volker Lendecke 2009 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "includes.h" +#include "winbindd.h" +#include "librpc/gen_ndr/cli_wbint.h" + +struct wb_lookupusergroups_state { + struct tevent_context *ev; + struct dom_sid sid; + struct wbint_SidArray sids; +}; + +static void wb_lookupusergroups_done(struct tevent_req *subreq); + +struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct winbindd_domain *domain, + const struct dom_sid *sid) +{ + struct tevent_req *req, *subreq; + struct wb_lookupusergroups_state *state; + NTSTATUS status; + + req = tevent_req_create(mem_ctx, &state, + struct wb_lookupusergroups_state); + if (req == NULL) { + return NULL; + } + sid_copy(&state->sid, sid); + + status = wcache_lookup_usergroups(domain, state, sid, + &state->sids.num_sids, + &state->sids.sids); + if (NT_STATUS_IS_OK(status)) { + tevent_req_done(req); + return tevent_req_post(req, ev); + } + + subreq = rpccli_wbint_LookupUserGroups_send( + state, ev, domain->child.rpccli, &state->sid, &state->sids); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, wb_lookupusergroups_done, req); + return req; +} + +static void wb_lookupusergroups_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_lookupusergroups_state *state = tevent_req_data( + req, struct wb_lookupusergroups_state); + NTSTATUS status, result; + + status = rpccli_wbint_LookupUserGroups_recv(subreq, state, &result); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; + } + if (!NT_STATUS_IS_OK(result)) { + tevent_req_nterror(req, result); + return; + } + tevent_req_done(req); +} + +NTSTATUS wb_lookupusergroups_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + int *num_sids, struct dom_sid **sids) +{ + struct wb_lookupusergroups_state *state = tevent_req_data( + req, struct wb_lookupusergroups_state); + NTSTATUS status; + + if (tevent_req_is_nterror(req, &status)) { + return status; + } + *num_sids = state->sids.num_sids; + *sids = talloc_move(mem_ctx, &state->sids.sids); + return NT_STATUS_OK; +} diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c index 1a8cbd9b92..9be295ffdc 100644 --- a/source3/winbindd/winbindd_dual_srv.c +++ b/source3/winbindd/winbindd_dual_srv.c @@ -158,3 +158,17 @@ NTSTATUS _wbint_LookupUserAliases(pipes_struct *p, domain, p->mem_ctx, r->in.sids->num_sids, r->in.sids->sids, &r->out.rids->num_rids, &r->out.rids->rids); } + +NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, + struct wbint_LookupUserGroups *r) +{ + struct winbindd_domain *domain = wb_child_domain(); + + if (domain == NULL) { + return NT_STATUS_REQUEST_NOT_ACCEPTED; + } + + return domain->methods->lookup_usergroups( + domain, p->mem_ctx, r->in.sid, + &r->out.sids->num_sids, &r->out.sids->sids); +} diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index fd67abbf6d..42acb9eea6 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -184,6 +184,7 @@ NTSTATUS wcache_lookup_usergroups(struct winbindd_domain *domain, const struct dom_sid *user_sid, uint32_t *pnum_sids, struct dom_sid **psids); + void wcache_flush_cache(void); NTSTATUS wcache_count_cached_creds(struct winbindd_domain *domain, int *count); NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const DOM_SID *sid) ; @@ -743,6 +744,12 @@ struct tevent_req *winbindd_getsidaliases_send(TALLOC_CTX *mem_ctx, struct winbindd_request *request); NTSTATUS winbindd_getsidaliases_recv(struct tevent_req *req, struct winbindd_response *response); +struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct winbindd_domain *domain, + const struct dom_sid *sid); +NTSTATUS wb_lookupusergroups_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + int *num_sids, struct dom_sid **sids); #endif /* _WINBINDD_PROTO_H_ */ |