summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-08-17 22:40:19 +0200
committerVolker Lendecke <vl@samba.org>2009-08-29 19:42:26 +0200
commitc325ba89cfeb9c4bbf1733d15e063809f4bc1332 (patch)
tree742355d901ff2a7b8c721458bc14738a3207eced /source3
parent9ef2c7096341f849bd1b52bf92e01936c3869eee (diff)
downloadsamba-c325ba89cfeb9c4bbf1733d15e063809f4bc1332.tar.gz
samba-c325ba89cfeb9c4bbf1733d15e063809f4bc1332.tar.bz2
samba-c325ba89cfeb9c4bbf1733d15e063809f4bc1332.zip
s3:winbind: Add async query_user_list
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in1
-rw-r--r--source3/librpc/gen_ndr/cli_wbint.c158
-rw-r--r--source3/librpc/gen_ndr/cli_wbint.h10
-rw-r--r--source3/librpc/gen_ndr/ndr_wbint.c143
-rw-r--r--source3/librpc/gen_ndr/ndr_wbint.h8
-rw-r--r--source3/librpc/gen_ndr/srv_wbint.c95
-rw-r--r--source3/librpc/gen_ndr/srv_wbint.h2
-rw-r--r--source3/librpc/gen_ndr/wbint.h14
-rw-r--r--source3/librpc/idl/wbint.idl9
-rw-r--r--source3/winbindd/wb_query_user_list.c92
-rw-r--r--source3/winbindd/winbindd_dual_srv.c13
-rw-r--r--source3/winbindd/winbindd_proto.h7
12 files changed, 547 insertions, 5 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index b183cfd7f9..37b2da6940 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -1179,6 +1179,7 @@ WINBINDD_OBJ1 = \
winbindd/wb_seqnums.o \
winbindd/wb_group_members.o \
winbindd/wb_getgrsid.o \
+ winbindd/wb_query_user_list.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 06e0bf748c..a13565c96f 100644
--- a/source3/librpc/gen_ndr/cli_wbint.c
+++ b/source3/librpc/gen_ndr/cli_wbint.c
@@ -1966,3 +1966,161 @@ NTSTATUS rpccli_wbint_LookupGroupMembers(struct rpc_pipe_client *cli,
/* Return result */
return r.out.result;
}
+
+struct rpccli_wbint_QueryUserList_state {
+ struct wbint_QueryUserList orig;
+ struct wbint_QueryUserList tmp;
+ TALLOC_CTX *out_mem_ctx;
+ NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+};
+
+static void rpccli_wbint_QueryUserList_done(struct tevent_req *subreq);
+
+struct tevent_req *rpccli_wbint_QueryUserList_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct rpc_pipe_client *cli,
+ struct wbint_userinfos *_users /* [out] [ref] */)
+{
+ struct tevent_req *req;
+ struct rpccli_wbint_QueryUserList_state *state;
+ struct tevent_req *subreq;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct rpccli_wbint_QueryUserList_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->out_mem_ctx = NULL;
+ state->dispatch_recv = cli->dispatch_recv;
+
+ /* In parameters */
+
+ /* Out parameters */
+ state->orig.out.users = _users;
+
+ /* Result */
+ ZERO_STRUCT(state->orig.out.result);
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_IN_DEBUG(wbint_QueryUserList, &state->orig);
+ }
+
+ state->out_mem_ctx = talloc_named_const(state, 0,
+ "rpccli_wbint_QueryUserList_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_QUERYUSERLIST,
+ &state->tmp);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, rpccli_wbint_QueryUserList_done, req);
+ return req;
+}
+
+static void rpccli_wbint_QueryUserList_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct rpccli_wbint_QueryUserList_state *state = tevent_req_data(
+ req, struct rpccli_wbint_QueryUserList_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.users = *state->tmp.out.users;
+
+ /* 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_QueryUserList, &state->orig);
+ }
+
+ tevent_req_done(req);
+}
+
+NTSTATUS rpccli_wbint_QueryUserList_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ NTSTATUS *result)
+{
+ struct rpccli_wbint_QueryUserList_state *state = tevent_req_data(
+ req, struct rpccli_wbint_QueryUserList_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_QueryUserList(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct wbint_userinfos *users /* [out] [ref] */)
+{
+ struct wbint_QueryUserList r;
+ NTSTATUS status;
+
+ /* In parameters */
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_IN_DEBUG(wbint_QueryUserList, &r);
+ }
+
+ status = cli->dispatch(cli,
+ mem_ctx,
+ &ndr_table_wbint,
+ NDR_WBINT_QUERYUSERLIST,
+ &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_OUT_DEBUG(wbint_QueryUserList, &r);
+ }
+
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+
+ /* Return variables */
+ *users = *r.out.users;
+
+ /* 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 8e9c31e8ba..9aa2f41a89 100644
--- a/source3/librpc/gen_ndr/cli_wbint.h
+++ b/source3/librpc/gen_ndr/cli_wbint.h
@@ -162,4 +162,14 @@ NTSTATUS rpccli_wbint_LookupGroupMembers(struct rpc_pipe_client *cli,
struct dom_sid *sid /* [in] [ref] */,
enum lsa_SidType type /* [in] */,
struct wbint_Principals *members /* [out] [ref] */);
+struct tevent_req *rpccli_wbint_QueryUserList_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct rpc_pipe_client *cli,
+ struct wbint_userinfos *_users /* [out] [ref] */);
+NTSTATUS rpccli_wbint_QueryUserList_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ NTSTATUS *result);
+NTSTATUS rpccli_wbint_QueryUserList(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct wbint_userinfos *users /* [out] [ref] */);
#endif /* __CLI_WBINT__ */
diff --git a/source3/librpc/gen_ndr/ndr_wbint.c b/source3/librpc/gen_ndr/ndr_wbint.c
index 996fbb5b6c..2c2676f069 100644
--- a/source3/librpc/gen_ndr/ndr_wbint.c
+++ b/source3/librpc/gen_ndr/ndr_wbint.c
@@ -424,6 +424,74 @@ _PUBLIC_ void ndr_print_wbint_Principals(struct ndr_print *ndr, const char *name
ndr->depth--;
}
+_PUBLIC_ enum ndr_err_code ndr_push_wbint_userinfos(struct ndr_push *ndr, int ndr_flags, const struct wbint_userinfos *r)
+{
+ uint32_t cntr_userinfos_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_userinfos));
+ NDR_CHECK(ndr_push_align(ndr, 8));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_userinfos));
+ for (cntr_userinfos_0 = 0; cntr_userinfos_0 < r->num_userinfos; cntr_userinfos_0++) {
+ NDR_CHECK(ndr_push_wbint_userinfo(ndr, NDR_SCALARS, &r->userinfos[cntr_userinfos_0]));
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ for (cntr_userinfos_0 = 0; cntr_userinfos_0 < r->num_userinfos; cntr_userinfos_0++) {
+ NDR_CHECK(ndr_push_wbint_userinfo(ndr, NDR_BUFFERS, &r->userinfos[cntr_userinfos_0]));
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_wbint_userinfos(struct ndr_pull *ndr, int ndr_flags, struct wbint_userinfos *r)
+{
+ uint32_t cntr_userinfos_0;
+ TALLOC_CTX *_mem_save_userinfos_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->userinfos));
+ NDR_CHECK(ndr_pull_align(ndr, 8));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_userinfos));
+ NDR_PULL_ALLOC_N(ndr, r->userinfos, ndr_get_array_size(ndr, &r->userinfos));
+ _mem_save_userinfos_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->userinfos, 0);
+ for (cntr_userinfos_0 = 0; cntr_userinfos_0 < r->num_userinfos; cntr_userinfos_0++) {
+ NDR_CHECK(ndr_pull_wbint_userinfo(ndr, NDR_SCALARS, &r->userinfos[cntr_userinfos_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_userinfos_0, 0);
+ if (r->userinfos) {
+ NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->userinfos, r->num_userinfos));
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ _mem_save_userinfos_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->userinfos, 0);
+ for (cntr_userinfos_0 = 0; cntr_userinfos_0 < r->num_userinfos; cntr_userinfos_0++) {
+ NDR_CHECK(ndr_pull_wbint_userinfo(ndr, NDR_BUFFERS, &r->userinfos[cntr_userinfos_0]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_userinfos_0, 0);
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_wbint_userinfos(struct ndr_print *ndr, const char *name, const struct wbint_userinfos *r)
+{
+ uint32_t cntr_userinfos_0;
+ ndr_print_struct(ndr, name, "wbint_userinfos");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "num_userinfos", r->num_userinfos);
+ ndr->print(ndr, "%s: ARRAY(%d)", "userinfos", (int)r->num_userinfos);
+ ndr->depth++;
+ for (cntr_userinfos_0=0;cntr_userinfos_0<r->num_userinfos;cntr_userinfos_0++) {
+ char *idx_0=NULL;
+ if (asprintf(&idx_0, "[%d]", cntr_userinfos_0) != -1) {
+ ndr_print_wbint_userinfo(ndr, "userinfos", &r->userinfos[cntr_userinfos_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) {
@@ -1562,6 +1630,67 @@ _PUBLIC_ void ndr_print_wbint_LookupGroupMembers(struct ndr_print *ndr, const ch
ndr->depth--;
}
+static enum ndr_err_code ndr_push_wbint_QueryUserList(struct ndr_push *ndr, int flags, const struct wbint_QueryUserList *r)
+{
+ if (flags & NDR_IN) {
+ }
+ if (flags & NDR_OUT) {
+ if (r->out.users == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_wbint_userinfos(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.users));
+ NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_wbint_QueryUserList(struct ndr_pull *ndr, int flags, struct wbint_QueryUserList *r)
+{
+ TALLOC_CTX *_mem_save_users_0;
+ if (flags & NDR_IN) {
+ ZERO_STRUCT(r->out);
+
+ NDR_PULL_ALLOC(ndr, r->out.users);
+ ZERO_STRUCTP(r->out.users);
+ }
+ if (flags & NDR_OUT) {
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->out.users);
+ }
+ _mem_save_users_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->out.users, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_wbint_userinfos(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.users));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_users_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_QueryUserList(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QueryUserList *r)
+{
+ ndr_print_struct(ndr, name, "wbint_QueryUserList");
+ ndr->depth++;
+ if (flags & NDR_SET_VALUES) {
+ ndr->flags |= LIBNDR_PRINT_SET_VALUES;
+ }
+ if (flags & NDR_IN) {
+ ndr_print_struct(ndr, "in", "wbint_QueryUserList");
+ ndr->depth++;
+ ndr->depth--;
+ }
+ if (flags & NDR_OUT) {
+ ndr_print_struct(ndr, "out", "wbint_QueryUserList");
+ ndr->depth++;
+ ndr_print_ptr(ndr, "users", r->out.users);
+ ndr->depth++;
+ ndr_print_wbint_userinfos(ndr, "users", r->out.users);
+ ndr->depth--;
+ ndr_print_NTSTATUS(ndr, "result", r->out.result);
+ ndr->depth--;
+ }
+ ndr->depth--;
+}
+
static const struct ndr_interface_call wbint_calls[] = {
{
"wbint_Ping",
@@ -1659,11 +1788,19 @@ static const struct ndr_interface_call wbint_calls[] = {
(ndr_print_function_t) ndr_print_wbint_LookupGroupMembers,
false,
},
+ {
+ "wbint_QueryUserList",
+ sizeof(struct wbint_QueryUserList),
+ (ndr_push_flags_fn_t) ndr_push_wbint_QueryUserList,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_QueryUserList,
+ (ndr_print_function_t) ndr_print_wbint_QueryUserList,
+ false,
+ },
{ NULL, 0, NULL, NULL, NULL, false }
};
static const char * const wbint_endpoint_strings[] = {
- "ncalrpc:",
+ "ncalrpc:",
};
static const struct ndr_interface_string_array wbint_endpoints = {
@@ -1672,7 +1809,7 @@ static const struct ndr_interface_string_array wbint_endpoints = {
};
static const char * const wbint_authservice_strings[] = {
- "host",
+ "host",
};
static const struct ndr_interface_string_array wbint_authservices = {
@@ -1688,7 +1825,7 @@ const struct ndr_interface_table ndr_table_wbint = {
NDR_WBINT_VERSION
},
.helpstring = NDR_WBINT_HELPSTRING,
- .num_calls = 12,
+ .num_calls = 13,
.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 00b7c54731..5a838f9dd4 100644
--- a/source3/librpc/gen_ndr/ndr_wbint.h
+++ b/source3/librpc/gen_ndr/ndr_wbint.h
@@ -35,7 +35,9 @@ extern const struct ndr_interface_table ndr_table_wbint;
#define NDR_WBINT_LOOKUPGROUPMEMBERS (0x0b)
-#define NDR_WBINT_CALL_COUNT (12)
+#define NDR_WBINT_QUERYUSERLIST (0x0c)
+
+#define NDR_WBINT_CALL_COUNT (13)
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);
@@ -51,6 +53,9 @@ void ndr_print_wbint_Principal(struct ndr_print *ndr, const char *name, const st
enum ndr_err_code ndr_push_wbint_Principals(struct ndr_push *ndr, int ndr_flags, const struct wbint_Principals *r);
enum ndr_err_code ndr_pull_wbint_Principals(struct ndr_pull *ndr, int ndr_flags, struct wbint_Principals *r);
void ndr_print_wbint_Principals(struct ndr_print *ndr, const char *name, const struct wbint_Principals *r);
+enum ndr_err_code ndr_push_wbint_userinfos(struct ndr_push *ndr, int ndr_flags, const struct wbint_userinfos *r);
+enum ndr_err_code ndr_pull_wbint_userinfos(struct ndr_pull *ndr, int ndr_flags, struct wbint_userinfos *r);
+void ndr_print_wbint_userinfos(struct ndr_print *ndr, const char *name, const struct wbint_userinfos *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);
@@ -63,4 +68,5 @@ void ndr_print_wbint_LookupUserAliases(struct ndr_print *ndr, const char *name,
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);
+void ndr_print_wbint_QueryUserList(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QueryUserList *r);
#endif /* _HEADER_NDR_wbint */
diff --git a/source3/librpc/gen_ndr/srv_wbint.c b/source3/librpc/gen_ndr/srv_wbint.c
index fcf84fe1ba..579164b13f 100644
--- a/source3/librpc/gen_ndr/srv_wbint.c
+++ b/source3/librpc/gen_ndr/srv_wbint.c
@@ -984,9 +984,89 @@ static bool api_wbint_LookupGroupMembers(pipes_struct *p)
return true;
}
+static bool api_wbint_QueryUserList(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_QueryUserList *r;
+
+ call = &ndr_table_wbint.calls[NDR_WBINT_QUERYUSERLIST];
+
+ r = talloc(talloc_tos(), struct wbint_QueryUserList);
+ 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_QueryUserList, r);
+ }
+
+ ZERO_STRUCT(r->out);
+ r->out.users = talloc_zero(r, struct wbint_userinfos);
+ if (r->out.users == NULL) {
+ talloc_free(r);
+ return false;
+ }
+
+ r->out.result = _wbint_QueryUserList(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_QueryUserList, 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[] =
+static struct api_struct api_wbint_cmds[] =
{
{"WBINT_PING", NDR_WBINT_PING, api_wbint_Ping},
{"WBINT_LOOKUPSID", NDR_WBINT_LOOKUPSID, api_wbint_LookupSid},
@@ -1000,6 +1080,7 @@ static struct api_struct api_wbint_cmds[] =
{"WBINT_LOOKUPUSERGROUPS", NDR_WBINT_LOOKUPUSERGROUPS, api_wbint_LookupUserGroups},
{"WBINT_QUERYSEQUENCENUMBER", NDR_WBINT_QUERYSEQUENCENUMBER, api_wbint_QuerySequenceNumber},
{"WBINT_LOOKUPGROUPMEMBERS", NDR_WBINT_LOOKUPGROUPMEMBERS, api_wbint_LookupGroupMembers},
+ {"WBINT_QUERYUSERLIST", NDR_WBINT_QUERYUSERLIST, api_wbint_QueryUserList},
};
void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns)
@@ -1175,6 +1256,18 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co
return NT_STATUS_OK;
}
+ case NDR_WBINT_QUERYUSERLIST: {
+ struct wbint_QueryUserList *r = (struct wbint_QueryUserList *)_r;
+ ZERO_STRUCT(r->out);
+ r->out.users = talloc_zero(mem_ctx, struct wbint_userinfos);
+ if (r->out.users == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ r->out.result = _wbint_QueryUserList(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 324425a248..46bdd8bb61 100644
--- a/source3/librpc/gen_ndr/srv_wbint.h
+++ b/source3/librpc/gen_ndr/srv_wbint.h
@@ -13,6 +13,7 @@ NTSTATUS _wbint_LookupUserAliases(pipes_struct *p, struct wbint_LookupUserAliase
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 _wbint_QueryUserList(pipes_struct *p, struct wbint_QueryUserList *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);
@@ -27,5 +28,6 @@ NTSTATUS _wbint_LookupUserAliases(pipes_struct *p, struct wbint_LookupUserAliase
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 _wbint_QueryUserList(pipes_struct *p, struct wbint_QueryUserList *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 2f1be14d58..0b942d1968 100644
--- a/source3/librpc/gen_ndr/wbint.h
+++ b/source3/librpc/gen_ndr/wbint.h
@@ -39,6 +39,11 @@ struct wbint_Principals {
struct wbint_Principal *principals;/* [size_is(num_principals)] */
}/* [public] */;
+struct wbint_userinfos {
+ uint32_t num_userinfos;
+ struct wbint_userinfo *userinfos;/* [size_is(num_userinfos)] */
+}/* [public] */;
+
struct wbint_Ping {
struct {
@@ -200,4 +205,13 @@ struct wbint_LookupGroupMembers {
};
+
+struct wbint_QueryUserList {
+ struct {
+ struct wbint_userinfos *users;/* [ref] */
+ NTSTATUS result;
+ } out;
+
+};
+
#endif /* _HEADER_wbint */
diff --git a/source3/librpc/idl/wbint.idl b/source3/librpc/idl/wbint.idl
index 8e2611c02e..1e3ef9e988 100644
--- a/source3/librpc/idl/wbint.idl
+++ b/source3/librpc/idl/wbint.idl
@@ -109,4 +109,13 @@ interface wbint
[in] lsa_SidType type,
[out] wbint_Principals *members
);
+
+ typedef [public] struct {
+ uint32 num_userinfos;
+ [size_is(num_userinfos)] wbint_userinfo userinfos[];
+ } wbint_userinfos;
+
+ NTSTATUS wbint_QueryUserList(
+ [out] wbint_userinfos *users
+ );
} \ No newline at end of file
diff --git a/source3/winbindd/wb_query_user_list.c b/source3/winbindd/wb_query_user_list.c
new file mode 100644
index 0000000000..d7c9b7f5ad
--- /dev/null
+++ b/source3/winbindd/wb_query_user_list.c
@@ -0,0 +1,92 @@
+/*
+ Unix SMB/CIFS implementation.
+ async query_user_list
+ 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_query_user_list_state {
+ struct wbint_userinfos users;
+};
+
+static void wb_query_user_list_done(struct tevent_req *subreq);
+
+struct tevent_req *wb_query_user_list_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_domain *domain)
+{
+ struct tevent_req *req, *subreq;
+ struct wb_query_user_list_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct wb_query_user_list_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ subreq = rpccli_wbint_QueryUserList_send(state, ev,
+ domain->child.rpccli,
+ &state->users);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, wb_query_user_list_done, req);
+ return req;
+}
+
+static void wb_query_user_list_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct wb_query_user_list_state *state = tevent_req_data(
+ req, struct wb_query_user_list_state);
+ NTSTATUS status, result;
+
+ status = rpccli_wbint_QueryUserList_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;
+ }
+
+ DEBUG(10, ("rpccli_wbint_QueryUserList returned %d users\n",
+ state->users.num_userinfos));
+
+ tevent_req_done(req);
+}
+
+NTSTATUS wb_query_user_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ int *num_users, struct wbint_userinfo **users)
+{
+ struct wb_query_user_list_state *state = tevent_req_data(
+ req, struct wb_query_user_list_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+
+ *num_users = state->users.num_userinfos;
+ *users = talloc_move(mem_ctx, &state->users.userinfos);
+ return NT_STATUS_OK;
+}
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index f07931dbe7..f430b16451 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -195,3 +195,16 @@ NTSTATUS _wbint_LookupGroupMembers(pipes_struct *p,
return NT_STATUS_OK;
}
+
+NTSTATUS _wbint_QueryUserList(pipes_struct *p, struct wbint_QueryUserList *r)
+{
+ struct winbindd_domain *domain = wb_child_domain();
+
+ if (domain == NULL) {
+ return NT_STATUS_REQUEST_NOT_ACCEPTED;
+ }
+
+ return domain->methods->query_user_list(
+ domain, p->mem_ctx, &r->out.users->num_userinfos,
+ &r->out.users->userinfos);
+}
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index aeb841edd1..3a9ac4f20f 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -849,4 +849,11 @@ struct tevent_req *winbindd_getusersids_send(TALLOC_CTX *mem_ctx,
NTSTATUS winbindd_getusersids_recv(struct tevent_req *req,
struct winbindd_response *response);
+struct tevent_req *wb_query_user_list_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_domain *domain);
+NTSTATUS wb_query_user_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ int *num_users,
+ struct wbint_userinfo **users);
+
#endif /* _WINBINDD_PROTO_H_ */