s3:winbind: Add async wb_lookupusergroups
authorVolker Lendecke <vl@samba.org>
Tue, 4 Aug 2009 20:07:01 +0000 (16:07 -0400)
committerVolker Lendecke <vl@samba.org>
Wed, 5 Aug 2009 07:21:25 +0000 (03:21 -0400)
12 files changed:
source3/Makefile.in
source3/librpc/gen_ndr/cli_wbint.c
source3/librpc/gen_ndr/cli_wbint.h
source3/librpc/gen_ndr/ndr_wbint.c
source3/librpc/gen_ndr/ndr_wbint.h
source3/librpc/gen_ndr/srv_wbint.c
source3/librpc/gen_ndr/srv_wbint.h
source3/librpc/gen_ndr/wbint.h
source3/librpc/idl/wbint.idl
source3/winbindd/wb_lookupusergroups.c [new file with mode: 0644]
source3/winbindd/winbindd_dual_srv.c
source3/winbindd/winbindd_proto.h

index 7879d939f852e622416cf15684e57303ffe55639..974499594ace8520a52e00672ddec2a7ae051d72 100644 (file)
@@ -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 \
index 30eb8e53d448dc5141499badbc779dadfbce4489..de6b345a0eea567e01b498095829797ab929fb77 100644 (file)
@@ -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;
+}
+
index 80f188f4f9aaf00605b041fecd6c6be497c5f7a9..e9927c1c3589d3ddf9badc8bf52b2f4c2284d45e 100644 (file)
@@ -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__ */
index 87e675edafbb33655feafc97c22648bdba57f5c9..5a8c1c33d72bea75395c6de8835eb2da7f85a905 100644 (file)
@@ -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
index f862fae651d6d4531fc57f62b88d040c07f92f48..6fd6b1d74d371a0fdab6816bf4e003e6b85b677d 100644 (file)
@@ -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 */
index 19d2d2eabf2312d9201d70cebe5c29eba46f1adf..95c061905835b0859ff407348c522b159be4b4f6 100644 (file)
@@ -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;
        }
index af48fa3320f1f84f9bb260b91c3992e1c43efd8c..20ca316375f4129c7f8433405dfb15fbd53ffd46 100644 (file)
@@ -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__ */
index 6eeef0ebdf815d75265319ad1884857f4951101a..28382ec3464fa238ed96b56ebf0e56306710fc2d 100644 (file)
@@ -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 */
index 571c212ecdfa4e3e29eadecc9de0f99c85624d53..f9941267112f0fd1897abbf2571cde697fd24500 100644 (file)
@@ -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 (file)
index 0000000..4e96b45
--- /dev/null
@@ -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;
+}
index 1a8cbd9b926b465039c04f105a359e2962351cb5..9be295ffdca4b8c39c55eed228081f3d85353e37 100644 (file)
@@ -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);
+}
index fd67abbf6dbfb1d83fb87049ef847c8a0dc81b8a..42acb9eea6ad6faa97dc7ceeeb8d947fdb8601fe 100644 (file)
@@ -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_  */