]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbind: Add async wb_lookupuseraliases
authorVolker Lendecke <vl@samba.org>
Tue, 4 Aug 2009 19:54:05 +0000 (15:54 -0400)
committerVolker Lendecke <vl@samba.org>
Wed, 5 Aug 2009 07:21:24 +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_lookupuseraliases.c [new file with mode: 0644]
source3/winbindd/winbindd_dual_srv.c
source3/winbindd/winbindd_proto.h

index 1b9b205beee47c8e0d9ec6b8487756c5a7ff2445..b1053bce05194719634bf8bcf31c4f0233f3ee7d 100644 (file)
@@ -1159,6 +1159,7 @@ WINBINDD_OBJ1 = \
                winbindd/wb_uid2sid.o \
                winbindd/wb_gid2sid.o \
                winbindd/wb_queryuser.o \
+               winbindd/wb_lookupuseraliases.o \
                winbindd/wb_getpwsid.o \
                winbindd/winbindd_lookupsid.o \
                winbindd/winbindd_lookupname.o \
index 9fdca8ecbaa04bf1ae73ec8ad6c6131b82209b9e..30eb8e53d448dc5141499badbc779dadfbce4489 100644 (file)
@@ -1323,3 +1323,164 @@ NTSTATUS rpccli_wbint_QueryUser(struct rpc_pipe_client *cli,
        return r.out.result;
 }
 
+struct rpccli_wbint_LookupUserAliases_state {
+       struct wbint_LookupUserAliases orig;
+       struct wbint_LookupUserAliases tmp;
+       TALLOC_CTX *out_mem_ctx;
+       NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+};
+
+static void rpccli_wbint_LookupUserAliases_done(struct tevent_req *subreq);
+
+struct tevent_req *rpccli_wbint_LookupUserAliases_send(TALLOC_CTX *mem_ctx,
+                                                      struct tevent_context *ev,
+                                                      struct rpc_pipe_client *cli,
+                                                      struct wbint_SidArray *_sids /* [in] [ref] */,
+                                                      struct wbint_RidArray *_rids /* [out] [ref] */)
+{
+       struct tevent_req *req;
+       struct rpccli_wbint_LookupUserAliases_state *state;
+       struct tevent_req *subreq;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct rpccli_wbint_LookupUserAliases_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       state->out_mem_ctx = NULL;
+       state->dispatch_recv = cli->dispatch_recv;
+
+       /* In parameters */
+       state->orig.in.sids = _sids;
+
+       /* Out parameters */
+       state->orig.out.rids = _rids;
+
+       /* Result */
+       ZERO_STRUCT(state->orig.out.result);
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(wbint_LookupUserAliases, &state->orig);
+       }
+
+       state->out_mem_ctx = talloc_named_const(state, 0,
+                            "rpccli_wbint_LookupUserAliases_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_LOOKUPUSERALIASES,
+                                   &state->tmp);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, rpccli_wbint_LookupUserAliases_done, req);
+       return req;
+}
+
+static void rpccli_wbint_LookupUserAliases_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct rpccli_wbint_LookupUserAliases_state *state = tevent_req_data(
+               req, struct rpccli_wbint_LookupUserAliases_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.rids = *state->tmp.out.rids;
+
+       /* 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_LookupUserAliases, &state->orig);
+       }
+
+       tevent_req_done(req);
+}
+
+NTSTATUS rpccli_wbint_LookupUserAliases_recv(struct tevent_req *req,
+                                            TALLOC_CTX *mem_ctx,
+                                            NTSTATUS *result)
+{
+       struct rpccli_wbint_LookupUserAliases_state *state = tevent_req_data(
+               req, struct rpccli_wbint_LookupUserAliases_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_LookupUserAliases(struct rpc_pipe_client *cli,
+                                       TALLOC_CTX *mem_ctx,
+                                       struct wbint_SidArray *sids /* [in] [ref] */,
+                                       struct wbint_RidArray *rids /* [out] [ref] */)
+{
+       struct wbint_LookupUserAliases r;
+       NTSTATUS status;
+
+       /* In parameters */
+       r.in.sids = sids;
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_IN_DEBUG(wbint_LookupUserAliases, &r);
+       }
+
+       status = cli->dispatch(cli,
+                               mem_ctx,
+                               &ndr_table_wbint,
+                               NDR_WBINT_LOOKUPUSERALIASES,
+                               &r);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       if (DEBUGLEVEL >= 10) {
+               NDR_PRINT_OUT_DEBUG(wbint_LookupUserAliases, &r);
+       }
+
+       if (NT_STATUS_IS_ERR(status)) {
+               return status;
+       }
+
+       /* Return variables */
+       *rids = *r.out.rids;
+
+       /* Return result */
+       return r.out.result;
+}
+
index ebceddea5f407416f1d149bc791044d71980554e..80f188f4f9aaf00605b041fecd6c6be497c5f7a9 100644 (file)
@@ -114,4 +114,16 @@ NTSTATUS rpccli_wbint_QueryUser(struct rpc_pipe_client *cli,
                                TALLOC_CTX *mem_ctx,
                                struct dom_sid *sid /* [in] [ref] */,
                                struct wbint_userinfo *info /* [out] [ref] */);
+struct tevent_req *rpccli_wbint_LookupUserAliases_send(TALLOC_CTX *mem_ctx,
+                                                      struct tevent_context *ev,
+                                                      struct rpc_pipe_client *cli,
+                                                      struct wbint_SidArray *_sids /* [in] [ref] */,
+                                                      struct wbint_RidArray *_rids /* [out] [ref] */);
+NTSTATUS rpccli_wbint_LookupUserAliases_recv(struct tevent_req *req,
+                                            TALLOC_CTX *mem_ctx,
+                                            NTSTATUS *result);
+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] */);
 #endif /* __CLI_WBINT__ */
index 2b773f3f45d79f30a213dca4c49a10566ca08349..87e675edafbb33655feafc97c22648bdba57f5c9 100644 (file)
@@ -172,6 +172,124 @@ _PUBLIC_ void ndr_print_wbint_userinfo(struct ndr_print *ndr, const char *name,
        ndr->depth--;
 }
 
+_PUBLIC_ enum ndr_err_code ndr_push_wbint_SidArray(struct ndr_push *ndr, int ndr_flags, const struct wbint_SidArray *r)
+{
+       uint32_t cntr_sids_0;
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_sids));
+               NDR_CHECK(ndr_push_align(ndr, 4));
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_sids));
+               for (cntr_sids_0 = 0; cntr_sids_0 < r->num_sids; cntr_sids_0++) {
+                       NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, &r->sids[cntr_sids_0]));
+               }
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_wbint_SidArray(struct ndr_pull *ndr, int ndr_flags, struct wbint_SidArray *r)
+{
+       uint32_t cntr_sids_0;
+       TALLOC_CTX *_mem_save_sids_0;
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_pull_array_size(ndr, &r->sids));
+               NDR_CHECK(ndr_pull_align(ndr, 4));
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_sids));
+               NDR_PULL_ALLOC_N(ndr, r->sids, ndr_get_array_size(ndr, &r->sids));
+               _mem_save_sids_0 = NDR_PULL_GET_MEM_CTX(ndr);
+               NDR_PULL_SET_MEM_CTX(ndr, r->sids, 0);
+               for (cntr_sids_0 = 0; cntr_sids_0 < r->num_sids; cntr_sids_0++) {
+                       NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, &r->sids[cntr_sids_0]));
+               }
+               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sids_0, 0);
+               if (r->sids) {
+                       NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->sids, r->num_sids));
+               }
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_wbint_SidArray(struct ndr_print *ndr, const char *name, const struct wbint_SidArray *r)
+{
+       uint32_t cntr_sids_0;
+       ndr_print_struct(ndr, name, "wbint_SidArray");
+       ndr->depth++;
+       ndr_print_uint32(ndr, "num_sids", r->num_sids);
+       ndr->print(ndr, "%s: ARRAY(%d)", "sids", (int)r->num_sids);
+       ndr->depth++;
+       for (cntr_sids_0=0;cntr_sids_0<r->num_sids;cntr_sids_0++) {
+               char *idx_0=NULL;
+               if (asprintf(&idx_0, "[%d]", cntr_sids_0) != -1) {
+                       ndr_print_dom_sid(ndr, "sids", &r->sids[cntr_sids_0]);
+                       free(idx_0);
+               }
+       }
+       ndr->depth--;
+       ndr->depth--;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_wbint_RidArray(struct ndr_push *ndr, int ndr_flags, const struct wbint_RidArray *r)
+{
+       uint32_t cntr_rids_0;
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_rids));
+               NDR_CHECK(ndr_push_align(ndr, 4));
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_rids));
+               for (cntr_rids_0 = 0; cntr_rids_0 < r->num_rids; cntr_rids_0++) {
+                       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->rids[cntr_rids_0]));
+               }
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_wbint_RidArray(struct ndr_pull *ndr, int ndr_flags, struct wbint_RidArray *r)
+{
+       uint32_t cntr_rids_0;
+       TALLOC_CTX *_mem_save_rids_0;
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_pull_array_size(ndr, &r->rids));
+               NDR_CHECK(ndr_pull_align(ndr, 4));
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_rids));
+               NDR_PULL_ALLOC_N(ndr, r->rids, ndr_get_array_size(ndr, &r->rids));
+               _mem_save_rids_0 = NDR_PULL_GET_MEM_CTX(ndr);
+               NDR_PULL_SET_MEM_CTX(ndr, r->rids, 0);
+               for (cntr_rids_0 = 0; cntr_rids_0 < r->num_rids; cntr_rids_0++) {
+                       NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->rids[cntr_rids_0]));
+               }
+               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_rids_0, 0);
+               if (r->rids) {
+                       NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->rids, r->num_rids));
+               }
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_wbint_RidArray(struct ndr_print *ndr, const char *name, const struct wbint_RidArray *r)
+{
+       uint32_t cntr_rids_0;
+       ndr_print_struct(ndr, name, "wbint_RidArray");
+       ndr->depth++;
+       ndr_print_uint32(ndr, "num_rids", r->num_rids);
+       ndr->print(ndr, "%s: ARRAY(%d)", "rids", (int)r->num_rids);
+       ndr->depth++;
+       for (cntr_rids_0=0;cntr_rids_0<r->num_rids;cntr_rids_0++) {
+               char *idx_0=NULL;
+               if (asprintf(&idx_0, "[%d]", cntr_rids_0) != -1) {
+                       ndr_print_uint32(ndr, "rids", r->rids[cntr_rids_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) {
@@ -1015,6 +1133,83 @@ _PUBLIC_ void ndr_print_wbint_QueryUser(struct ndr_print *ndr, const char *name,
        ndr->depth--;
 }
 
+static enum ndr_err_code ndr_push_wbint_LookupUserAliases(struct ndr_push *ndr, int flags, const struct wbint_LookupUserAliases *r)
+{
+       if (flags & NDR_IN) {
+               if (r->in.sids == NULL) {
+                       return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+               }
+               NDR_CHECK(ndr_push_wbint_SidArray(ndr, NDR_SCALARS, r->in.sids));
+       }
+       if (flags & NDR_OUT) {
+               if (r->out.rids == NULL) {
+                       return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+               }
+               NDR_CHECK(ndr_push_wbint_RidArray(ndr, NDR_SCALARS, r->out.rids));
+               NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_wbint_LookupUserAliases(struct ndr_pull *ndr, int flags, struct wbint_LookupUserAliases *r)
+{
+       TALLOC_CTX *_mem_save_sids_0;
+       TALLOC_CTX *_mem_save_rids_0;
+       if (flags & NDR_IN) {
+               ZERO_STRUCT(r->out);
+
+               if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+                       NDR_PULL_ALLOC(ndr, r->in.sids);
+               }
+               _mem_save_sids_0 = NDR_PULL_GET_MEM_CTX(ndr);
+               NDR_PULL_SET_MEM_CTX(ndr, r->in.sids, LIBNDR_FLAG_REF_ALLOC);
+               NDR_CHECK(ndr_pull_wbint_SidArray(ndr, NDR_SCALARS, r->in.sids));
+               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sids_0, LIBNDR_FLAG_REF_ALLOC);
+               NDR_PULL_ALLOC(ndr, r->out.rids);
+               ZERO_STRUCTP(r->out.rids);
+       }
+       if (flags & NDR_OUT) {
+               if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+                       NDR_PULL_ALLOC(ndr, r->out.rids);
+               }
+               _mem_save_rids_0 = NDR_PULL_GET_MEM_CTX(ndr);
+               NDR_PULL_SET_MEM_CTX(ndr, r->out.rids, LIBNDR_FLAG_REF_ALLOC);
+               NDR_CHECK(ndr_pull_wbint_RidArray(ndr, NDR_SCALARS, r->out.rids));
+               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_rids_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_LookupUserAliases(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupUserAliases *r)
+{
+       ndr_print_struct(ndr, name, "wbint_LookupUserAliases");
+       ndr->depth++;
+       if (flags & NDR_SET_VALUES) {
+               ndr->flags |= LIBNDR_PRINT_SET_VALUES;
+       }
+       if (flags & NDR_IN) {
+               ndr_print_struct(ndr, "in", "wbint_LookupUserAliases");
+               ndr->depth++;
+               ndr_print_ptr(ndr, "sids", r->in.sids);
+               ndr->depth++;
+               ndr_print_wbint_SidArray(ndr, "sids", r->in.sids);
+               ndr->depth--;
+               ndr->depth--;
+       }
+       if (flags & NDR_OUT) {
+               ndr_print_struct(ndr, "out", "wbint_LookupUserAliases");
+               ndr->depth++;
+               ndr_print_ptr(ndr, "rids", r->out.rids);
+               ndr->depth++;
+               ndr_print_wbint_RidArray(ndr, "rids", r->out.rids);
+               ndr->depth--;
+               ndr_print_NTSTATUS(ndr, "result", r->out.result);
+               ndr->depth--;
+       }
+       ndr->depth--;
+}
+
 static const struct ndr_interface_call wbint_calls[] = {
        {
                "wbint_Ping",
@@ -1080,6 +1275,14 @@ static const struct ndr_interface_call wbint_calls[] = {
                (ndr_print_function_t) ndr_print_wbint_QueryUser,
                false,
        },
+       {
+               "wbint_LookupUserAliases",
+               sizeof(struct wbint_LookupUserAliases),
+               (ndr_push_flags_fn_t) ndr_push_wbint_LookupUserAliases,
+               (ndr_pull_flags_fn_t) ndr_pull_wbint_LookupUserAliases,
+               (ndr_print_function_t) ndr_print_wbint_LookupUserAliases,
+               false,
+       },
        { NULL, 0, NULL, NULL, NULL, false }
 };
 
@@ -1109,7 +1312,7 @@ const struct ndr_interface_table ndr_table_wbint = {
                NDR_WBINT_VERSION
        },
        .helpstring     = NDR_WBINT_HELPSTRING,
-       .num_calls      = 8,
+       .num_calls      = 9,
        .calls          = wbint_calls,
        .endpoints      = &wbint_endpoints,
        .authservices   = &wbint_authservices
index 5db488e69c6656892ae74a208d9f12957a25c849..f862fae651d6d4531fc57f62b88d040c07f92f48 100644 (file)
@@ -27,10 +27,18 @@ extern const struct ndr_interface_table ndr_table_wbint;
 
 #define NDR_WBINT_QUERYUSER (0x07)
 
-#define NDR_WBINT_CALL_COUNT (8)
+#define NDR_WBINT_LOOKUPUSERALIASES (0x08)
+
+#define NDR_WBINT_CALL_COUNT (9)
 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);
+enum ndr_err_code ndr_push_wbint_SidArray(struct ndr_push *ndr, int ndr_flags, const struct wbint_SidArray *r);
+enum ndr_err_code ndr_pull_wbint_SidArray(struct ndr_pull *ndr, int ndr_flags, struct wbint_SidArray *r);
+void ndr_print_wbint_SidArray(struct ndr_print *ndr, const char *name, const struct wbint_SidArray *r);
+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);
 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);
@@ -39,4 +47,5 @@ void ndr_print_wbint_Sid2Gid(struct ndr_print *ndr, const char *name, int flags,
 void ndr_print_wbint_Uid2Sid(struct ndr_print *ndr, const char *name, int flags, const struct wbint_Uid2Sid *r);
 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);
 #endif /* _HEADER_NDR_wbint */
index 121d3fa79db16b3bd1c46c23bb904e1d933af129..19d2d2eabf2312d9201d70cebe5c29eba46f1adf 100644 (file)
@@ -664,6 +664,86 @@ static bool api_wbint_QueryUser(pipes_struct *p)
        return true;
 }
 
+static bool api_wbint_LookupUserAliases(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_LookupUserAliases *r;
+
+       call = &ndr_table_wbint.calls[NDR_WBINT_LOOKUPUSERALIASES];
+
+       r = talloc(talloc_tos(), struct wbint_LookupUserAliases);
+       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_LookupUserAliases, r);
+       }
+
+       ZERO_STRUCT(r->out);
+       r->out.rids = talloc_zero(r, struct wbint_RidArray);
+       if (r->out.rids == NULL) {
+               talloc_free(r);
+               return false;
+       }
+
+       r->out.result = _wbint_LookupUserAliases(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_LookupUserAliases, 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[] =
@@ -676,6 +756,7 @@ static struct api_struct api_wbint_cmds[] =
        {"WBINT_UID2SID", NDR_WBINT_UID2SID, api_wbint_Uid2Sid},
        {"WBINT_GID2SID", NDR_WBINT_GID2SID, api_wbint_Gid2Sid},
        {"WBINT_QUERYUSER", NDR_WBINT_QUERYUSER, api_wbint_QueryUser},
+       {"WBINT_LOOKUPUSERALIASES", NDR_WBINT_LOOKUPUSERALIASES, api_wbint_LookupUserAliases},
 };
 
 void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns)
@@ -803,6 +884,18 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co
                        return NT_STATUS_OK;
                }
 
+               case NDR_WBINT_LOOKUPUSERALIASES: {
+                       struct wbint_LookupUserAliases *r = (struct wbint_LookupUserAliases *)_r;
+                       ZERO_STRUCT(r->out);
+                       r->out.rids = talloc_zero(mem_ctx, struct wbint_RidArray);
+                       if (r->out.rids == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+                       }
+
+                       r->out.result = _wbint_LookupUserAliases(cli->pipes_struct, r);
+                       return NT_STATUS_OK;
+               }
+
                default:
                        return NT_STATUS_NOT_IMPLEMENTED;
        }
index ddefa6acce0ac367cc99d60d300611c5adfcf4a3..af48fa3320f1f84f9bb260b91c3992e1c43efd8c 100644 (file)
@@ -9,6 +9,7 @@ NTSTATUS _wbint_Sid2Gid(pipes_struct *p, struct wbint_Sid2Gid *r);
 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);
 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);
@@ -19,5 +20,6 @@ NTSTATUS _wbint_Sid2Gid(pipes_struct *p, struct wbint_Sid2Gid *r);
 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 rpc_wbint_init(void);
 #endif /* __SRV_WBINT__ */
index eb3dd0cd333be0cb4c702b28a0d82ba8d278e0a2..6eeef0ebdf815d75265319ad1884857f4951101a 100644 (file)
@@ -18,6 +18,16 @@ struct wbint_userinfo {
        struct dom_sid group_sid;
 }/* [public] */;
 
+struct wbint_SidArray {
+       uint32_t num_sids;
+       struct dom_sid *sids;/* [size_is(num_sids)] */
+}/* [public] */;
+
+struct wbint_RidArray {
+       uint32_t num_rids;
+       uint32_t *rids;/* [size_is(num_rids)] */
+}/* [public] */;
+
 
 struct wbint_Ping {
        struct {
@@ -130,4 +140,17 @@ struct wbint_QueryUser {
 
 };
 
+
+struct wbint_LookupUserAliases {
+       struct {
+               struct wbint_SidArray *sids;/* [ref] */
+       } in;
+
+       struct {
+               struct wbint_RidArray *rids;/* [ref] */
+               NTSTATUS result;
+       } out;
+
+};
+
 #endif /* _HEADER_wbint */
index 15c4e1f3021c4ea9136425033cc318b783416cfa..571c212ecdfa4e3e29eadecc9de0f99c85624d53 100644 (file)
@@ -68,4 +68,19 @@ interface wbint
        [in] dom_sid *sid,
        [out] wbint_userinfo *info
        );
+
+    typedef [public] struct {
+       uint32 num_sids;
+       [size_is(num_sids)] dom_sid sids[];
+    } wbint_SidArray;
+
+    typedef [public] struct {
+       uint32 num_rids;
+       [size_is(num_rids)] uint32 rids[];
+    } wbint_RidArray;
+
+    NTSTATUS wbint_LookupUserAliases(
+       [in] wbint_SidArray *sids,
+       [out] wbint_RidArray *rids
+       );
 }
\ No newline at end of file
diff --git a/source3/winbindd/wb_lookupuseraliases.c b/source3/winbindd/wb_lookupuseraliases.c
new file mode 100644 (file)
index 0000000..e2e5e2d
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+   Unix SMB/CIFS implementation.
+   async lookupuseraliases
+   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_lookupuseraliases_state {
+       struct tevent_context *ev;
+       struct wbint_SidArray sids;
+       struct wbint_RidArray rids;
+};
+
+static void wb_lookupuseraliases_done(struct tevent_req *subreq);
+
+struct tevent_req *wb_lookupuseraliases_send(TALLOC_CTX *mem_ctx,
+                                            struct tevent_context *ev,
+                                            struct winbindd_domain *domain,
+                                            int num_sids,
+                                            const struct dom_sid *sids)
+{
+       struct tevent_req *req, *subreq;
+       struct wb_lookupuseraliases_state *state;
+       NTSTATUS status;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct wb_lookupuseraliases_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       state->sids.num_sids = num_sids;
+       state->sids.sids = CONST_DISCARD(struct dom_sid *, sids);
+
+       status = wcache_lookup_useraliases(domain, state, num_sids, sids,
+                                          &state->rids.num_rids,
+                                          &state->rids.rids);
+       if (NT_STATUS_IS_OK(status)) {
+               tevent_req_done(req);
+               return tevent_req_post(req, ev);
+       }
+
+       subreq = rpccli_wbint_LookupUserAliases_send(
+               state, ev, domain->child.rpccli, &state->sids, &state->rids);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, wb_lookupuseraliases_done, req);
+       return req;
+}
+
+static void wb_lookupuseraliases_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct wb_lookupuseraliases_state *state = tevent_req_data(
+               req, struct wb_lookupuseraliases_state);
+       NTSTATUS status, result;
+
+       status = rpccli_wbint_LookupUserAliases_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_lookupuseraliases_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+                                  uint32_t *num_aliases, uint32_t **aliases)
+{
+       struct wb_lookupuseraliases_state *state = tevent_req_data(
+               req, struct wb_lookupuseraliases_state);
+       NTSTATUS status;
+
+       if (tevent_req_is_nterror(req, &status)) {
+               return status;
+       }
+       *num_aliases = state->rids.num_rids;
+       *aliases = talloc_move(mem_ctx, &state->rids.rids);
+       return NT_STATUS_OK;
+}
index 202cca44340f7072f393a7d4d07866cb70333568..1a8cbd9b926b465039c04f105a359e2962351cb5 100644 (file)
@@ -144,3 +144,17 @@ NTSTATUS _wbint_QueryUser(pipes_struct *p, struct wbint_QueryUser *r)
 
        return NT_STATUS_OK;
 }
+
+NTSTATUS _wbint_LookupUserAliases(pipes_struct *p,
+                                 struct wbint_LookupUserAliases *r)
+{
+       struct winbindd_domain *domain = wb_child_domain();
+
+       if (domain == NULL) {
+               return NT_STATUS_REQUEST_NOT_ACCEPTED;
+       }
+
+       return domain->methods->lookup_useraliases(
+               domain, p->mem_ctx, r->in.sids->num_sids, r->in.sids->sids,
+               &r->out.rids->num_rids, &r->out.rids->rids);
+}
index 220253777758c9dd6e5ac42273767cc12118cce5..8dda3f8c8fbf2645de3d26cde23338088ee7e028 100644 (file)
@@ -726,6 +726,13 @@ struct tevent_req *winbindd_getpwuid_send(TALLOC_CTX *mem_ctx,
                                          struct winbindd_request *request);
 NTSTATUS winbindd_getpwuid_recv(struct tevent_req *req,
                                struct winbindd_response *response);
+struct tevent_req *wb_lookupuseraliases_send(TALLOC_CTX *mem_ctx,
+                                            struct tevent_context *ev,
+                                            struct winbindd_domain *domain,
+                                            int num_sids,
+                                            const struct dom_sid *sids);
+NTSTATUS wb_lookupuseraliases_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+                                  uint32_t *num_aliases, uint32_t **aliases);
 
 
 #endif /*  _WINBINDD_PROTO_H_  */