krb5pac.idl: add PAC_CREDENTIAL related structures
[Samba.git] / source3 / winbindd / wb_query_group_list.c
blob703d3316376481c54db436e591087c7da56adbe1
1 /*
2 Unix SMB/CIFS implementation.
3 async query_group_list
4 Copyright (C) Volker Lendecke 2009
5 Copyright (C) Michael Adam 2015
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "winbindd.h"
23 #include "librpc/gen_ndr/ndr_winbind_c.h"
26 struct wb_query_group_list_state {
27 struct wbint_Principals groups;
30 static void wb_query_group_list_done(struct tevent_req *subreq);
32 struct tevent_req *wb_query_group_list_send(TALLOC_CTX *mem_ctx,
33 struct tevent_context *ev,
34 struct winbindd_domain *domain)
36 struct tevent_req *req, *subreq;
37 struct wb_query_group_list_state *state;
39 req = tevent_req_create(mem_ctx, &state,
40 struct wb_query_group_list_state);
41 if (req == NULL) {
42 return NULL;
45 subreq = dcerpc_wbint_QueryGroupList_send(state, ev,
46 dom_child_handle(domain),
47 &state->groups);
48 if (tevent_req_nomem(subreq, req)) {
49 return tevent_req_post(req, ev);
52 tevent_req_set_callback(subreq, wb_query_group_list_done, req);
53 return req;
56 static void wb_query_group_list_done(struct tevent_req *subreq)
58 struct tevent_req *req = tevent_req_callback_data(
59 subreq, struct tevent_req);
60 struct wb_query_group_list_state *state = tevent_req_data(
61 req, struct wb_query_group_list_state);
62 NTSTATUS status, result;
64 status = dcerpc_wbint_QueryGroupList_recv(subreq, state, &result);
65 TALLOC_FREE(subreq);
66 if (any_nt_status_not_ok(status, result, &status)) {
67 tevent_req_nterror(req, status);
68 return;
71 DEBUG(10, ("dcerpc_wbint_QueryGroupList returned %d groups\n",
72 state->groups.num_principals));
74 tevent_req_done(req);
77 NTSTATUS wb_query_group_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
78 int *num_groups,
79 struct wbint_Principal **groups)
81 struct wb_query_group_list_state *state = tevent_req_data(
82 req, struct wb_query_group_list_state);
83 NTSTATUS status;
85 if (tevent_req_is_nterror(req, &status)) {
86 return status;
89 *num_groups = state->groups.num_principals;
90 *groups = talloc_move(mem_ctx, &state->groups.principals);
92 return NT_STATUS_OK;