diff options
-rw-r--r-- | source3/Makefile.in | 1 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/cli_wbint.c | 165 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/cli_wbint.h | 14 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_wbint.c | 224 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_wbint.h | 11 | ||||
-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 | 25 | ||||
-rw-r--r-- | source3/librpc/idl/wbint.idl | 17 | ||||
-rw-r--r-- | source3/winbindd/wb_group_members.c | 496 | ||||
-rw-r--r-- | source3/winbindd/winbindd_dual_srv.c | 38 | ||||
-rw-r--r-- | source3/winbindd/winbindd_proto.h | 7 |
12 files changed, 1091 insertions, 2 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 3cb510cef4..80df78eac5 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1167,6 +1167,7 @@ WINBINDD_OBJ1 = \ winbindd/wb_gettoken.o \ winbindd/wb_seqnum.o \ winbindd/wb_seqnums.o \ + winbindd/wb_group_members.o \ winbindd/winbindd_lookupsid.o \ winbindd/winbindd_lookupname.o \ winbindd/winbindd_sid_to_uid.o \ diff --git a/source3/librpc/gen_ndr/cli_wbint.c b/source3/librpc/gen_ndr/cli_wbint.c index 07486c2e40..ab9d984a83 100644 --- a/source3/librpc/gen_ndr/cli_wbint.c +++ b/source3/librpc/gen_ndr/cli_wbint.c @@ -1801,3 +1801,168 @@ NTSTATUS rpccli_wbint_QuerySequenceNumber(struct rpc_pipe_client *cli, /* Return result */ return r.out.result; } + +struct rpccli_wbint_LookupGroupMembers_state { + struct wbint_LookupGroupMembers orig; + struct wbint_LookupGroupMembers tmp; + TALLOC_CTX *out_mem_ctx; + NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx); +}; + +static void rpccli_wbint_LookupGroupMembers_done(struct tevent_req *subreq); + +struct tevent_req *rpccli_wbint_LookupGroupMembers_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + struct dom_sid *_sid /* [in] [ref] */, + enum lsa_SidType _type /* [in] */, + struct wbint_GroupMembers *_members /* [out] [ref] */) +{ + struct tevent_req *req; + struct rpccli_wbint_LookupGroupMembers_state *state; + struct tevent_req *subreq; + + req = tevent_req_create(mem_ctx, &state, + struct rpccli_wbint_LookupGroupMembers_state); + if (req == NULL) { + return NULL; + } + state->out_mem_ctx = NULL; + state->dispatch_recv = cli->dispatch_recv; + + /* In parameters */ + state->orig.in.sid = _sid; + state->orig.in.type = _type; + + /* Out parameters */ + state->orig.out.members = _members; + + /* Result */ + ZERO_STRUCT(state->orig.out.result); + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_LookupGroupMembers, &state->orig); + } + + state->out_mem_ctx = talloc_named_const(state, 0, + "rpccli_wbint_LookupGroupMembers_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_LOOKUPGROUPMEMBERS, + &state->tmp); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, rpccli_wbint_LookupGroupMembers_done, req); + return req; +} + +static void rpccli_wbint_LookupGroupMembers_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct rpccli_wbint_LookupGroupMembers_state *state = tevent_req_data( + req, struct rpccli_wbint_LookupGroupMembers_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.members = *state->tmp.out.members; + + /* 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_LookupGroupMembers, &state->orig); + } + + tevent_req_done(req); +} + +NTSTATUS rpccli_wbint_LookupGroupMembers_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result) +{ + struct rpccli_wbint_LookupGroupMembers_state *state = tevent_req_data( + req, struct rpccli_wbint_LookupGroupMembers_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_LookupGroupMembers(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct dom_sid *sid /* [in] [ref] */, + enum lsa_SidType type /* [in] */, + struct wbint_GroupMembers *members /* [out] [ref] */) +{ + struct wbint_LookupGroupMembers r; + NTSTATUS status; + + /* In parameters */ + r.in.sid = sid; + r.in.type = type; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(wbint_LookupGroupMembers, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_wbint, + NDR_WBINT_LOOKUPGROUPMEMBERS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(wbint_LookupGroupMembers, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *members = *r.out.members; + + /* 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 ded93309ae..d5b333f42a 100644 --- a/source3/librpc/gen_ndr/cli_wbint.h +++ b/source3/librpc/gen_ndr/cli_wbint.h @@ -148,4 +148,18 @@ NTSTATUS rpccli_wbint_QuerySequenceNumber_recv(struct tevent_req *req, NTSTATUS rpccli_wbint_QuerySequenceNumber(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32_t *sequence /* [out] [ref] */); +struct tevent_req *rpccli_wbint_LookupGroupMembers_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct rpc_pipe_client *cli, + struct dom_sid *_sid /* [in] [ref] */, + enum lsa_SidType _type /* [in] */, + struct wbint_GroupMembers *_members /* [out] [ref] */); +NTSTATUS rpccli_wbint_LookupGroupMembers_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + NTSTATUS *result); +NTSTATUS rpccli_wbint_LookupGroupMembers(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct dom_sid *sid /* [in] [ref] */, + enum lsa_SidType type /* [in] */, + struct wbint_GroupMembers *members /* [out] [ref] */); #endif /* __CLI_WBINT__ */ diff --git a/source3/librpc/gen_ndr/ndr_wbint.c b/source3/librpc/gen_ndr/ndr_wbint.c index 295b72f1cf..bb0d01b0b7 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.c +++ b/source3/librpc/gen_ndr/ndr_wbint.c @@ -290,6 +290,140 @@ _PUBLIC_ void ndr_print_wbint_RidArray(struct ndr_print *ndr, const char *name, ndr->depth--; } +_PUBLIC_ enum ndr_err_code ndr_push_wbint_GroupMember(struct ndr_push *ndr, int ndr_flags, const struct wbint_GroupMember *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, &r->sid)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->name)); + NDR_CHECK(ndr_push_lsa_SidType(ndr, NDR_SCALARS, r->type)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->name) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->name, CH_UTF8))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->name, CH_UTF8))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, ndr_charset_length(r->name, CH_UTF8), sizeof(uint8_t), CH_UTF8)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_wbint_GroupMember(struct ndr_pull *ndr, int ndr_flags, struct wbint_GroupMember *r) +{ + uint32_t _ptr_name; + TALLOC_CTX *_mem_save_name_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, &r->sid)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name)); + if (_ptr_name) { + NDR_PULL_ALLOC(ndr, r->name); + } else { + r->name = NULL; + } + NDR_CHECK(ndr_pull_lsa_SidType(ndr, NDR_SCALARS, &r->type)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->name) { + _mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->name, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->name)); + if (ndr_get_array_length(ndr, &r->name) > ndr_get_array_size(ndr, &r->name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->name), ndr_get_array_length(ndr, &r->name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->name), sizeof(uint8_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->name, ndr_get_array_length(ndr, &r->name), sizeof(uint8_t), CH_UTF8)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_wbint_GroupMember(struct ndr_print *ndr, const char *name, const struct wbint_GroupMember *r) +{ + ndr_print_struct(ndr, name, "wbint_GroupMember"); + ndr->depth++; + ndr_print_dom_sid(ndr, "sid", &r->sid); + ndr_print_ptr(ndr, "name", r->name); + ndr->depth++; + if (r->name) { + ndr_print_string(ndr, "name", r->name); + } + ndr->depth--; + ndr_print_lsa_SidType(ndr, "type", r->type); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_wbint_GroupMembers(struct ndr_push *ndr, int ndr_flags, const struct wbint_GroupMembers *r) +{ + uint32_t cntr_members_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_members)); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_int32(ndr, NDR_SCALARS, r->num_members)); + for (cntr_members_0 = 0; cntr_members_0 < r->num_members; cntr_members_0++) { + NDR_CHECK(ndr_push_wbint_GroupMember(ndr, NDR_SCALARS, &r->members[cntr_members_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + for (cntr_members_0 = 0; cntr_members_0 < r->num_members; cntr_members_0++) { + NDR_CHECK(ndr_push_wbint_GroupMember(ndr, NDR_BUFFERS, &r->members[cntr_members_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_wbint_GroupMembers(struct ndr_pull *ndr, int ndr_flags, struct wbint_GroupMembers *r) +{ + uint32_t cntr_members_0; + TALLOC_CTX *_mem_save_members_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_array_size(ndr, &r->members)); + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_int32(ndr, NDR_SCALARS, &r->num_members)); + NDR_PULL_ALLOC_N(ndr, r->members, ndr_get_array_size(ndr, &r->members)); + _mem_save_members_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->members, 0); + for (cntr_members_0 = 0; cntr_members_0 < r->num_members; cntr_members_0++) { + NDR_CHECK(ndr_pull_wbint_GroupMember(ndr, NDR_SCALARS, &r->members[cntr_members_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_members_0, 0); + if (r->members) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->members, r->num_members)); + } + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_members_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->members, 0); + for (cntr_members_0 = 0; cntr_members_0 < r->num_members; cntr_members_0++) { + NDR_CHECK(ndr_pull_wbint_GroupMember(ndr, NDR_BUFFERS, &r->members[cntr_members_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_members_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_wbint_GroupMembers(struct ndr_print *ndr, const char *name, const struct wbint_GroupMembers *r) +{ + uint32_t cntr_members_0; + ndr_print_struct(ndr, name, "wbint_GroupMembers"); + ndr->depth++; + ndr_print_int32(ndr, "num_members", r->num_members); + ndr->print(ndr, "%s: ARRAY(%d)", "members", (int)r->num_members); + ndr->depth++; + for (cntr_members_0=0;cntr_members_0<r->num_members;cntr_members_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_members_0) != -1) { + ndr_print_wbint_GroupMember(ndr, "members", &r->members[cntr_members_0]); + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + static enum ndr_err_code ndr_push_wbint_Ping(struct ndr_push *ndr, int flags, const struct wbint_Ping *r) { if (flags & NDR_IN) { @@ -1348,6 +1482,86 @@ _PUBLIC_ void ndr_print_wbint_QuerySequenceNumber(struct ndr_print *ndr, const c ndr->depth--; } +static enum ndr_err_code ndr_push_wbint_LookupGroupMembers(struct ndr_push *ndr, int flags, const struct wbint_LookupGroupMembers *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)); + NDR_CHECK(ndr_push_lsa_SidType(ndr, NDR_SCALARS, r->in.type)); + } + if (flags & NDR_OUT) { + if (r->out.members == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_wbint_GroupMembers(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.members)); + NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_wbint_LookupGroupMembers(struct ndr_pull *ndr, int flags, struct wbint_LookupGroupMembers *r) +{ + TALLOC_CTX *_mem_save_sid_0; + TALLOC_CTX *_mem_save_members_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_CHECK(ndr_pull_lsa_SidType(ndr, NDR_SCALARS, &r->in.type)); + NDR_PULL_ALLOC(ndr, r->out.members); + ZERO_STRUCTP(r->out.members); + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.members); + } + _mem_save_members_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.members, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_wbint_GroupMembers(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.members)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_members_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_LookupGroupMembers(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupGroupMembers *r) +{ + ndr_print_struct(ndr, name, "wbint_LookupGroupMembers"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "wbint_LookupGroupMembers"); + ndr->depth++; + ndr_print_ptr(ndr, "sid", r->in.sid); + ndr->depth++; + ndr_print_dom_sid(ndr, "sid", r->in.sid); + ndr->depth--; + ndr_print_lsa_SidType(ndr, "type", r->in.type); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "wbint_LookupGroupMembers"); + ndr->depth++; + ndr_print_ptr(ndr, "members", r->out.members); + ndr->depth++; + ndr_print_wbint_GroupMembers(ndr, "members", r->out.members); + ndr->depth--; + ndr_print_NTSTATUS(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + static const struct ndr_interface_call wbint_calls[] = { { "wbint_Ping", @@ -1437,6 +1651,14 @@ static const struct ndr_interface_call wbint_calls[] = { (ndr_print_function_t) ndr_print_wbint_QuerySequenceNumber, false, }, + { + "wbint_LookupGroupMembers", + sizeof(struct wbint_LookupGroupMembers), + (ndr_push_flags_fn_t) ndr_push_wbint_LookupGroupMembers, + (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupGroupMembers, + (ndr_print_function_t) ndr_print_wbint_LookupGroupMembers, + false, + }, { NULL, 0, NULL, NULL, NULL, false } }; @@ -1466,7 +1688,7 @@ const struct ndr_interface_table ndr_table_wbint = { NDR_WBINT_VERSION }, .helpstring = NDR_WBINT_HELPSTRING, - .num_calls = 11, + .num_calls = 12, .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 4acdc404ec..f6871ada6b 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.h +++ b/source3/librpc/gen_ndr/ndr_wbint.h @@ -33,7 +33,9 @@ extern const struct ndr_interface_table ndr_table_wbint; #define NDR_WBINT_QUERYSEQUENCENUMBER (0x0a) -#define NDR_WBINT_CALL_COUNT (11) +#define NDR_WBINT_LOOKUPGROUPMEMBERS (0x0b) + +#define NDR_WBINT_CALL_COUNT (12) 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); @@ -43,6 +45,12 @@ void ndr_print_wbint_SidArray(struct ndr_print *ndr, const char *name, const str enum ndr_err_code ndr_push_wbint_RidArray(struct ndr_push *ndr, int ndr_flags, const struct wbint_RidArray *r); enum ndr_err_code ndr_pull_wbint_RidArray(struct ndr_pull *ndr, int ndr_flags, struct wbint_RidArray *r); void ndr_print_wbint_RidArray(struct ndr_print *ndr, const char *name, const struct wbint_RidArray *r); +enum ndr_err_code ndr_push_wbint_GroupMember(struct ndr_push *ndr, int ndr_flags, const struct wbint_GroupMember *r); +enum ndr_err_code ndr_pull_wbint_GroupMember(struct ndr_pull *ndr, int ndr_flags, struct wbint_GroupMember *r); +void ndr_print_wbint_GroupMember(struct ndr_print *ndr, const char *name, const struct wbint_GroupMember *r); +enum ndr_err_code ndr_push_wbint_GroupMembers(struct ndr_push *ndr, int ndr_flags, const struct wbint_GroupMembers *r); +enum ndr_err_code ndr_pull_wbint_GroupMembers(struct ndr_pull *ndr, int ndr_flags, struct wbint_GroupMembers *r); +void ndr_print_wbint_GroupMembers(struct ndr_print *ndr, const char *name, const struct wbint_GroupMembers *r); void ndr_print_wbint_Ping(struct ndr_print *ndr, const char *name, int flags, const struct wbint_Ping *r); void ndr_print_wbint_LookupSid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupSid *r); void ndr_print_wbint_LookupName(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupName *r); @@ -54,4 +62,5 @@ void ndr_print_wbint_QueryUser(struct ndr_print *ndr, const char *name, int flag 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); 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); #endif /* _HEADER_NDR_wbint */ diff --git a/source3/librpc/gen_ndr/srv_wbint.c b/source3/librpc/gen_ndr/srv_wbint.c index 1c2799c165..f8fb3209e6 100644 --- a/source3/librpc/gen_ndr/srv_wbint.c +++ b/source3/librpc/gen_ndr/srv_wbint.c @@ -904,6 +904,86 @@ static bool api_wbint_QuerySequenceNumber(pipes_struct *p) return true; } +static bool api_wbint_LookupGroupMembers(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_LookupGroupMembers *r; + + call = &ndr_table_wbint.calls[NDR_WBINT_LOOKUPGROUPMEMBERS]; + + r = talloc(talloc_tos(), struct wbint_LookupGroupMembers); + 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_LookupGroupMembers, r); + } + + ZERO_STRUCT(r->out); + r->out.members = talloc_zero(r, struct wbint_GroupMembers); + if (r->out.members == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _wbint_LookupGroupMembers(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_LookupGroupMembers, 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[] = @@ -919,6 +999,7 @@ static struct api_struct api_wbint_cmds[] = {"WBINT_LOOKUPUSERALIASES", NDR_WBINT_LOOKUPUSERALIASES, api_wbint_LookupUserAliases}, {"WBINT_LOOKUPUSERGROUPS", NDR_WBINT_LOOKUPUSERGROUPS, api_wbint_LookupUserGroups}, {"WBINT_QUERYSEQUENCENUMBER", NDR_WBINT_QUERYSEQUENCENUMBER, api_wbint_QuerySequenceNumber}, + {"WBINT_LOOKUPGROUPMEMBERS", NDR_WBINT_LOOKUPGROUPMEMBERS, api_wbint_LookupGroupMembers}, }; void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns) @@ -1082,6 +1163,18 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co return NT_STATUS_OK; } + case NDR_WBINT_LOOKUPGROUPMEMBERS: { + struct wbint_LookupGroupMembers *r = (struct wbint_LookupGroupMembers *)_r; + ZERO_STRUCT(r->out); + r->out.members = talloc_zero(mem_ctx, struct wbint_GroupMembers); + if (r->out.members == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _wbint_LookupGroupMembers(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 5749b1e9ae..324425a248 100644 --- a/source3/librpc/gen_ndr/srv_wbint.h +++ b/source3/librpc/gen_ndr/srv_wbint.h @@ -12,6 +12,7 @@ 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 _wbint_QuerySequenceNumber(pipes_struct *p, struct wbint_QuerySequenceNumber *r); +NTSTATUS _wbint_LookupGroupMembers(pipes_struct *p, struct wbint_LookupGroupMembers *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); @@ -25,5 +26,6 @@ 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 _wbint_QuerySequenceNumber(pipes_struct *p, struct wbint_QuerySequenceNumber *r); +NTSTATUS _wbint_LookupGroupMembers(pipes_struct *p, struct wbint_LookupGroupMembers *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 c5caa79a4b..7ed1fb2753 100644 --- a/source3/librpc/gen_ndr/wbint.h +++ b/source3/librpc/gen_ndr/wbint.h @@ -28,6 +28,17 @@ struct wbint_RidArray { uint32_t *rids;/* [size_is(num_rids)] */ }/* [public] */; +struct wbint_GroupMember { + struct dom_sid sid; + const char *name;/* [unique,charset(UTF8)] */ + enum lsa_SidType type; +}/* [public] */; + +struct wbint_GroupMembers { + int32_t num_members; + struct wbint_GroupMember *members;/* [size_is(num_members)] */ +}/* [public] */; + struct wbint_Ping { struct { @@ -175,4 +186,18 @@ struct wbint_QuerySequenceNumber { }; + +struct wbint_LookupGroupMembers { + struct { + struct dom_sid *sid;/* [ref] */ + enum lsa_SidType type; + } in; + + struct { + struct wbint_GroupMembers *members;/* [ref] */ + NTSTATUS result; + } out; + +}; + #endif /* _HEADER_wbint */ diff --git a/source3/librpc/idl/wbint.idl b/source3/librpc/idl/wbint.idl index a4aab7c1ac..b7a1ce37ad 100644 --- a/source3/librpc/idl/wbint.idl +++ b/source3/librpc/idl/wbint.idl @@ -92,4 +92,21 @@ interface wbint NTSTATUS wbint_QuerySequenceNumber( [out] uint32 *sequence ); + + typedef [public] struct { + dom_sid sid; + [string,charset(UTF8)] char *name; + lsa_SidType type; + } wbint_GroupMember; + + typedef [public] struct { + int num_members; + [size_is(num_members)] wbint_GroupMember members[]; + } wbint_GroupMembers; + + NTSTATUS wbint_LookupGroupMembers( + [in] dom_sid *sid, + [in] lsa_SidType type, + [out] wbint_GroupMembers *members + ); }
\ No newline at end of file diff --git a/source3/winbindd/wb_group_members.c b/source3/winbindd/wb_group_members.c new file mode 100644 index 0000000000..5de4d51e09 --- /dev/null +++ b/source3/winbindd/wb_group_members.c @@ -0,0 +1,496 @@ +/* + Unix SMB/CIFS implementation. + async lookupgroupmembers + 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" + +/* + * We have 3 sets of routines here: + * + * wb_lookupgroupmem is the low-level one-group routine + * + * wb_groups_members walks a list of groups + * + * wb_group_members finally is the high-level routine expanding groups + * recursively + */ + +/* + * Look up members of a single group. Essentially a wrapper around the + * lookup_groupmem winbindd_methods routine. + */ + +struct wb_lookupgroupmem_state { + struct dom_sid sid; + struct wbint_GroupMembers members; +}; + +static void wb_lookupgroupmem_done(struct tevent_req *subreq); + +static struct tevent_req *wb_lookupgroupmem_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + const struct dom_sid *group_sid, + enum lsa_SidType type) +{ + struct tevent_req *req, *subreq; + struct wb_lookupgroupmem_state *state; + struct winbindd_domain *domain; + uint32_t num_names; + struct dom_sid *sid_mem; + char **names; + uint32_t *name_types; + NTSTATUS status; + + req = tevent_req_create(mem_ctx, &state, + struct wb_lookupgroupmem_state); + if (req == NULL) { + return NULL; + } + sid_copy(&state->sid, group_sid); + + domain = find_domain_from_sid_noinit(group_sid); + if (domain == NULL) { + tevent_req_nterror(req, NT_STATUS_NO_SUCH_GROUP); + return tevent_req_post(req, ev); + } + + status = wcache_lookup_groupmem(domain, state, &state->sid, &num_names, + &sid_mem, &names, &name_types); + if (NT_STATUS_IS_OK(status)) { + int i; + state->members.members = talloc_array( + state, struct wbint_GroupMember, num_names); + if (tevent_req_nomem(state->members.members, req)) { + return tevent_req_post(req, ev); + } + state->members.num_members = num_names; + for (i=0; i<num_names; i++) { + struct wbint_GroupMember *m; + const char *name; + m = &state->members.members[i]; + sid_copy(&m->sid, &sid_mem[i]); + name = names[i]; + m->name = talloc_move(state->members.members, &name); + m->type = (enum lsa_SidType)name_types[i]; + } + TALLOC_FREE(sid_mem); + TALLOC_FREE(names); + TALLOC_FREE(name_types); + tevent_req_done(req); + return tevent_req_post(req, ev); + } + + subreq = rpccli_wbint_LookupGroupMembers_send( + state, ev, domain->child.rpccli, &state->sid, type, + &state->members); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, wb_lookupgroupmem_done, req); + return req; +} + +static void wb_lookupgroupmem_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_lookupgroupmem_state *state = tevent_req_data( + req, struct wb_lookupgroupmem_state); + NTSTATUS status, result; + + status = rpccli_wbint_LookupGroupMembers_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); +} + +static NTSTATUS wb_lookupgroupmem_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + int *num_members, + struct wbint_GroupMember **members) +{ + struct wb_lookupgroupmem_state *state = tevent_req_data( + req, struct wb_lookupgroupmem_state); + NTSTATUS status; + + if (tevent_req_is_nterror(req, &status)) { + return status; + } + + *num_members = state->members.num_members; + *members = talloc_move(mem_ctx, &state->members.members); + return NT_STATUS_OK; +} + +/* + * Same as wb_lookupgroupmem for a list of groups + */ + +struct wb_groups_members_state { + struct tevent_context *ev; + struct wbint_GroupMember *groups; + int num_groups; + int next_group; + struct wbint_GroupMember *all_members; +}; + +static NTSTATUS wb_groups_members_next_subreq( + struct wb_groups_members_state *state, + TALLOC_CTX *mem_ctx, struct tevent_req **psubreq); +static void wb_groups_members_done(struct tevent_req *subreq); + +static struct tevent_req *wb_groups_members_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + int num_groups, + struct wbint_GroupMember *groups) +{ + struct tevent_req *req, *subreq; + struct wb_groups_members_state *state; + NTSTATUS status; + + req = tevent_req_create(mem_ctx, &state, + struct wb_groups_members_state); + if (req == NULL) { + return NULL; + } + state->ev = ev; + state->groups = groups; + state->num_groups = num_groups; + state->next_group = 0; + state->all_members = NULL; + + status = wb_groups_members_next_subreq(state, state, &subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return tevent_req_post(req, ev); + } + if (subreq == NULL) { + tevent_req_done(req); + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, wb_groups_members_done, req); + return req; +} + +static NTSTATUS wb_groups_members_next_subreq( + struct wb_groups_members_state *state, + TALLOC_CTX *mem_ctx, struct tevent_req **psubreq) +{ + struct tevent_req *subreq; + struct wbint_GroupMember *g; + + if (state->next_group >= state->num_groups) { + *psubreq = NULL; + return NT_STATUS_OK; + } + + g = &state->groups[state->next_group]; + state->next_group += 1; + + subreq = wb_lookupgroupmem_send(mem_ctx, state->ev, &g->sid, + g->type); + if (subreq == NULL) { + return NT_STATUS_NO_MEMORY; + } + *psubreq = subreq; + return NT_STATUS_OK; +} + +static void wb_groups_members_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_groups_members_state *state = tevent_req_data( + req, struct wb_groups_members_state); + int i, num_all_members; + int num_members = 0; + struct wbint_GroupMember *members = NULL; + NTSTATUS status; + + status = wb_lookupgroupmem_recv(subreq, state, &num_members, + &members); + TALLOC_FREE(subreq); + + /* + * In this error handling here we might have to be a bit more generous + * and just continue if an error occured. + */ + + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; + } + + num_all_members = talloc_array_length(state->all_members); + + state->all_members = talloc_realloc( + state, state->all_members, struct wbint_GroupMember, + num_all_members + num_members); + if ((num_all_members + num_members != 0) + && tevent_req_nomem(state->all_members, req)) { + return; + } + for (i=0; i<num_members; i++) { + struct wbint_GroupMember *src, *dst; + src = &members[i]; + dst = &state->all_members[num_all_members + i]; + sid_copy(&dst->sid, &src->sid); + dst->name = talloc_move(state->all_members, &src->name); + dst->type = src->type; + } + TALLOC_FREE(members); + + status = wb_groups_members_next_subreq(state, state, &subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; + } + if (subreq == NULL) { + tevent_req_done(req); + return; + } + tevent_req_set_callback(subreq, wb_groups_members_done, req); +} + +static NTSTATUS wb_groups_members_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + int *num_members, + struct wbint_GroupMember **members) +{ + struct wb_groups_members_state *state = tevent_req_data( + req, struct wb_groups_members_state); + NTSTATUS status; + + if (tevent_req_is_nterror(req, &status)) { + return status; + } + *num_members = talloc_array_length(state->all_members); + *members = talloc_move(mem_ctx, &state->all_members); + return NT_STATUS_OK; +} + + +/* + * This is the routine expanding a list of groups up to a certain level. We + * collect the users in a talloc_dict: We have to add them without duplicates, + * and and talloc_dict is an indexed (here indexed by SID) data structure. + */ + +struct wb_group_members_state { + struct tevent_context *ev; + int depth; + struct talloc_dict *users; + struct wbint_GroupMember *groups; +}; + +static NTSTATUS wb_group_members_next_subreq( + struct wb_group_members_state *state, + TALLOC_CTX *mem_ctx, struct tevent_req **psubreq); +static void wb_group_members_done(struct tevent_req *subreq); + +struct tevent_req *wb_group_members_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + const struct dom_sid *sid, + enum lsa_SidType type, + int max_depth) +{ + struct tevent_req *req, *subreq; + struct wb_group_members_state *state; + NTSTATUS status; + + req = tevent_req_create(mem_ctx, &state, + struct wb_group_members_state); + if (req == NULL) { + return NULL; + } + state->ev = ev; + state->depth = max_depth; + state->users = talloc_dict_init(state); + if (tevent_req_nomem(state->users, req)) { + return tevent_req_post(req, ev); + } + + state->groups = talloc(state, struct wbint_GroupMember); + if (tevent_req_nomem(state->groups, req)) { + return tevent_req_post(req, ev); + } + state->groups->name = NULL; + sid_copy(&state->groups->sid, sid); + state->groups->type = type; + + status = wb_group_members_next_subreq(state, state, &subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return tevent_req_post(req, ev); + } + if (subreq == NULL) { + tevent_req_done(req); + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, wb_group_members_done, req); + return req; +} + +static NTSTATUS wb_group_members_next_subreq( + struct wb_group_members_state *state, + TALLOC_CTX *mem_ctx, struct tevent_req **psubreq) +{ + struct tevent_req *subreq; + + if ((talloc_array_length(state->groups) == 0) + || (state->depth <= 0)) { + *psubreq = NULL; + return NT_STATUS_OK; + } + state->depth -= 1; + + subreq = wb_groups_members_send( + mem_ctx, state->ev, talloc_array_length(state->groups), + state->groups); + if (subreq == NULL) { + return NT_STATUS_NO_MEMORY; + } + *psubreq = subreq; + return NT_STATUS_OK; +} + +static void wb_group_members_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_group_members_state *state = tevent_req_data( + req, struct wb_group_members_state); + int i, num_groups, new_users, new_groups; + int num_members = 0; + struct wbint_GroupMember *members = NULL; + NTSTATUS status; + + status = wb_groups_members_recv(subreq, state, &num_members, &members); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; + } + + new_users = new_groups = 0; + for (i=0; i<num_members; i++) { + switch (members[i].type) { + case SID_NAME_DOM_GRP: + case SID_NAME_ALIAS: + case SID_NAME_WKN_GRP: + new_groups += 1; + break; + default: + /* Ignore everything else */ + break; + } + } + + num_groups = 0; + TALLOC_FREE(state->groups); + state->groups = talloc_array(state, struct wbint_GroupMember, + new_groups); + + /* + * Collect the users into state->users and the groups into + * state->groups for the next iteration. + */ + + for (i=0; i<num_members; i++) { + switch (members[i].type) { + case SID_NAME_USER: + case SID_NAME_COMPUTER: { + /* + * Add a copy of members[i] to state->users + */ + struct wbint_GroupMember *m; + struct dom_sid *sid; + DATA_BLOB key; + + m = talloc(talloc_tos(), struct wbint_GroupMember); + if (tevent_req_nomem(m, req)) { + return; + } + sid_copy(&m->sid, &members[i].sid); + m->name = talloc_move(m, &members[i].name); + m->type = members[i].type; + + sid = &members[i].sid; + key = data_blob_const( + sid, ndr_size_dom_sid(sid, NULL, 0)); + + if (!talloc_dict_set(state->users, key, &m)) { + tevent_req_nterror(req, NT_STATUS_NO_MEMORY); + return; + } + break; + } + case SID_NAME_DOM_GRP: + case SID_NAME_ALIAS: + case SID_NAME_WKN_GRP: { + struct wbint_GroupMember *g; + /* + * Save members[i] for the next round + */ + g = &state->groups[num_groups]; + sid_copy(&g->sid, &members[i].sid); + g->name = talloc_move(state->groups, &members[i].name); + g->type = members[i].type; + num_groups += 1; + break; + } + default: + /* Ignore everything else */ + break; + } + } + + status = wb_group_members_next_subreq(state, state, &subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; + } + if (subreq == NULL) { + tevent_req_done(req); + return; + } + tevent_req_set_callback(subreq, wb_group_members_done, req); +} + +NTSTATUS wb_group_members_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + struct talloc_dict **members) +{ + struct wb_group_members_state *state = tevent_req_data( + req, struct wb_group_members_state); + NTSTATUS status; + + if (tevent_req_is_nterror(req, &status)) { + return status; + } + *members = talloc_move(mem_ctx, &state->users); + return NT_STATUS_OK; +} diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c index 92233188de..6e69cce86d 100644 --- a/source3/winbindd/winbindd_dual_srv.c +++ b/source3/winbindd/winbindd_dual_srv.c @@ -157,3 +157,41 @@ NTSTATUS _wbint_QuerySequenceNumber(pipes_struct *p, return domain->methods->sequence_number(domain, r->out.sequence); } + +NTSTATUS _wbint_LookupGroupMembers(pipes_struct *p, + struct wbint_LookupGroupMembers *r) +{ + struct winbindd_domain *domain = wb_child_domain(); + uint32_t i, num_names; + struct dom_sid *sid_mem; + char **names; + uint32_t *name_types; + NTSTATUS status; + + if (domain == NULL) { + return NT_STATUS_REQUEST_NOT_ACCEPTED; + } + + status = domain->methods->lookup_groupmem( + domain, p->mem_ctx, r->in.sid, + &num_names, &sid_mem, &names, &name_types); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + r->out.members->num_members = num_names; + r->out.members->members = talloc_array( + r->out.members, struct wbint_GroupMember, num_names); + if (r->out.members->members == NULL) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i<num_names; i++) { + struct wbint_GroupMember *m = &r->out.members->members[i]; + sid_copy(&m->sid, &sid_mem[i]); + m->name = talloc_move(r->out.members->members, &names[i]); + m->type = (enum lsa_SidType)name_types[i]; + } + + return NT_STATUS_OK; +} diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 0fea00d7f0..50da2c6aab 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -790,5 +790,12 @@ struct tevent_req *winbindd_show_sequence_send(TALLOC_CTX *mem_ctx, NTSTATUS winbindd_show_sequence_recv(struct tevent_req *req, struct winbindd_response *response); +struct tevent_req *wb_group_members_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + const struct dom_sid *sid, + enum lsa_SidType type, + int max_depth); +NTSTATUS wb_group_members_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + struct talloc_dict **members); #endif /* _WINBINDD_PROTO_H_ */ |