mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
s3:winbind: Add async query_user_list
This commit is contained in:
parent
9ef2c70963
commit
c325ba89cf
@ -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 \
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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__ */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
);
|
||||
}
|
92
source3/winbindd/wb_query_user_list.c
Normal file
92
source3/winbindd/wb_query_user_list.c
Normal file
@ -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;
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user