summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-08-04 15:54:05 -0400
committerVolker Lendecke <vl@samba.org>2009-08-05 03:21:24 -0400
commitce42ea3ab8c69a3f650d4c9bc787e4805aad928d (patch)
treec54ca89752da885dfd3c930abdf6f7bbc1ffacb3 /source3
parentf09a95aaff4542df4225f3828a0d737497f0f2e8 (diff)
downloadsamba-ce42ea3ab8c69a3f650d4c9bc787e4805aad928d.tar.gz
samba-ce42ea3ab8c69a3f650d4c9bc787e4805aad928d.tar.bz2
samba-ce42ea3ab8c69a3f650d4c9bc787e4805aad928d.zip
s3:winbind: Add async wb_lookupuseraliases
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in1
-rw-r--r--source3/librpc/gen_ndr/cli_wbint.c161
-rw-r--r--source3/librpc/gen_ndr/cli_wbint.h12
-rw-r--r--source3/librpc/gen_ndr/ndr_wbint.c205
-rw-r--r--source3/librpc/gen_ndr/ndr_wbint.h11
-rw-r--r--source3/librpc/gen_ndr/srv_wbint.c93
-rw-r--r--source3/librpc/gen_ndr/srv_wbint.h2
-rw-r--r--source3/librpc/gen_ndr/wbint.h23
-rw-r--r--source3/librpc/idl/wbint.idl15
-rw-r--r--source3/winbindd/wb_lookupuseraliases.c101
-rw-r--r--source3/winbindd/winbindd_dual_srv.c14
-rw-r--r--source3/winbindd/winbindd_proto.h7
12 files changed, 643 insertions, 2 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 1b9b205bee..b1053bce05 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -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 \
diff --git a/source3/librpc/gen_ndr/cli_wbint.c b/source3/librpc/gen_ndr/cli_wbint.c
index 9fdca8ecba..30eb8e53d4 100644
--- a/source3/librpc/gen_ndr/cli_wbint.c
+++ b/source3/librpc/gen_ndr/cli_wbint.c
@@ -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;
+}
+
diff --git a/source3/librpc/gen_ndr/cli_wbint.h b/source3/librpc/gen_ndr/cli_wbint.h
index ebceddea5f..80f188f4f9 100644
--- a/source3/librpc/gen_ndr/cli_wbint.h
+++ b/source3/librpc/gen_ndr/cli_wbint.h
@@ -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__ */
diff --git a/source3/librpc/gen_ndr/ndr_wbint.c b/source3/librpc/gen_ndr/ndr_wbint.c
index 2b773f3f45..87e675edaf 100644
--- a/source3/librpc/gen_ndr/ndr_wbint.c
+++ b/source3/librpc/gen_ndr/ndr_wbint.c
@@ -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
diff --git a/source3/librpc/gen_ndr/ndr_wbint.h b/source3/librpc/gen_ndr/ndr_wbint.h
index 5db488e69c..f862fae651 100644
--- a/source3/librpc/gen_ndr/ndr_wbint.h
+++ b/source3/librpc/gen_ndr/ndr_wbint.h
@@ -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 */
diff --git a/source3/librpc/gen_ndr/srv_wbint.c b/source3/librpc/gen_ndr/srv_wbint.c
index 121d3fa79d..19d2d2eabf 100644
--- a/source3/librpc/gen_ndr/srv_wbint.c
+++ b/source3/librpc/gen_ndr/srv_wbint.c
@@ -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;
}
diff --git a/source3/librpc/gen_ndr/srv_wbint.h b/source3/librpc/gen_ndr/srv_wbint.h
index ddefa6acce..af48fa3320 100644
--- a/source3/librpc/gen_ndr/srv_wbint.h
+++ b/source3/librpc/gen_ndr/srv_wbint.h
@@ -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__ */
diff --git a/source3/librpc/gen_ndr/wbint.h b/source3/librpc/gen_ndr/wbint.h
index eb3dd0cd33..6eeef0ebdf 100644
--- a/source3/librpc/gen_ndr/wbint.h
+++ b/source3/librpc/gen_ndr/wbint.h
@@ -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 */
diff --git a/source3/librpc/idl/wbint.idl b/source3/librpc/idl/wbint.idl
index 15c4e1f302..571c212ecd 100644
--- a/source3/librpc/idl/wbint.idl
+++ b/source3/librpc/idl/wbint.idl
@@ -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
index 0000000000..e2e5e2da08
--- /dev/null
+++ b/source3/winbindd/wb_lookupuseraliases.c
@@ -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;
+}
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index 202cca4434..1a8cbd9b92 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -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);
+}
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 2202537777..8dda3f8c8f 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -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_ */