2 Unix SMB/CIFS implementation.
4 Async helpers for blocking functions
6 Copyright (C) Volker Lendecke 2005
7 Copyright (C) Gerald Carter 2006
9 The helpers always consist of three functions:
11 * A request setup function that takes the necessary parameters together
12 with a continuation function that is to be called upon completion
14 * A private continuation function that is internal only. This is to be
15 called by the lower-level functions in do_async(). Its only task is to
16 properly call the continuation function named above.
18 * A worker function that is called inside the appropriate child process.
20 This program is free software; you can redistribute it and/or modify
21 it under the terms of the GNU General Public License as published by
22 the Free Software Foundation; either version 3 of the License, or
23 (at your option) any later version.
25 This program is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
30 You should have received a copy of the GNU General Public License
31 along with this program. If not, see <http://www.gnu.org/licenses/>.
38 #define DBGC_CLASS DBGC_WINBIND
40 struct do_async_state {
42 struct winbindd_request request;
43 struct winbindd_response response;
44 void (*cont)(TALLOC_CTX *mem_ctx,
46 struct winbindd_response *response,
47 void *c, void *private_data);
48 void *c, *private_data;
51 static void do_async_recv(void *private_data, bool success)
53 struct do_async_state *state =
54 talloc_get_type_abort(private_data, struct do_async_state);
56 state->cont(state->mem_ctx, success, &state->response,
57 state->c, state->private_data);
60 void do_async(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
61 const struct winbindd_request *request,
62 void (*cont)(TALLOC_CTX *mem_ctx, bool success,
63 struct winbindd_response *response,
64 void *c, void *private_data),
65 void *c, void *private_data)
67 struct do_async_state *state;
69 state = TALLOC_ZERO_P(mem_ctx, struct do_async_state);
71 DEBUG(0, ("talloc failed\n"));
72 cont(mem_ctx, False, NULL, c, private_data);
76 state->mem_ctx = mem_ctx;
77 state->request = *request;
78 state->request.length = sizeof(state->request);
81 state->private_data = private_data;
83 async_request(mem_ctx, child, &state->request,
84 &state->response, do_async_recv, state);
87 void do_async_domain(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
88 const struct winbindd_request *request,
89 void (*cont)(TALLOC_CTX *mem_ctx, bool success,
90 struct winbindd_response *response,
91 void *c, void *private_data),
92 void *c, void *private_data)
94 struct do_async_state *state;
96 state = TALLOC_ZERO_P(mem_ctx, struct do_async_state);
98 DEBUG(0, ("talloc failed\n"));
99 cont(mem_ctx, False, NULL, c, private_data);
103 state->mem_ctx = mem_ctx;
104 state->request = *request;
105 state->request.length = sizeof(state->request);
108 state->private_data = private_data;
110 async_domain_request(mem_ctx, domain, &state->request,
111 &state->response, do_async_recv, state);
114 struct lookupsid_state {
116 void *caller_private_data;
120 static void lookupsid_recv2(TALLOC_CTX *mem_ctx, bool success,
121 struct winbindd_response *response,
122 void *c, void *private_data)
124 void (*cont)(void *priv, bool succ, const char *dom_name,
125 const char *name, enum lsa_SidType type) =
126 (void (*)(void *, bool, const char *, const char *,
128 struct lookupsid_state *s = talloc_get_type_abort(private_data,
129 struct lookupsid_state);
132 DEBUG(5, ("Could not trigger lookupsid\n"));
133 cont(s->caller_private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
137 if (response->result != WINBINDD_OK) {
138 DEBUG(5, ("lookupsid (forest root) returned an error\n"));
139 cont(s->caller_private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
143 cont(s->caller_private_data, True, response->data.name.dom_name,
144 response->data.name.name,
145 (enum lsa_SidType)response->data.name.type);
148 static void lookupsid_recv(TALLOC_CTX *mem_ctx, bool success,
149 struct winbindd_response *response,
150 void *c, void *private_data)
152 void (*cont)(void *priv, bool succ, const char *dom_name,
153 const char *name, enum lsa_SidType type) =
154 (void (*)(void *, bool, const char *, const char *,
156 struct lookupsid_state *s = talloc_get_type_abort(private_data,
157 struct lookupsid_state);
160 DEBUG(5, ("Could not trigger lookupsid\n"));
161 cont(s->caller_private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
165 if (response->result != WINBINDD_OK) {
166 /* Try again using the forest root */
167 struct winbindd_domain *root_domain = find_root_domain();
168 struct winbindd_request request;
170 if ( !root_domain ) {
171 DEBUG(5,("lookupsid_recv: unable to determine forest root\n"));
172 cont(s->caller_private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
176 ZERO_STRUCT(request);
177 request.cmd = WINBINDD_LOOKUPSID;
178 sid_to_string(request.data.sid, &s->sid);
180 do_async_domain(mem_ctx, root_domain, &request, lookupsid_recv2,
186 cont(s->caller_private_data, True, response->data.name.dom_name,
187 response->data.name.name,
188 (enum lsa_SidType)response->data.name.type);
191 void winbindd_lookupsid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
192 void (*cont)(void *private_data, bool success,
193 const char *dom_name,
195 enum lsa_SidType type),
198 struct winbindd_domain *domain;
199 struct winbindd_request request;
200 struct lookupsid_state *s;
202 domain = find_lookup_domain_from_sid(sid);
203 if (domain == NULL) {
204 DEBUG(5, ("Could not find domain for sid %s\n",
205 sid_string_dbg(sid)));
206 cont(private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
210 ZERO_STRUCT(request);
211 request.cmd = WINBINDD_LOOKUPSID;
212 sid_to_string(request.data.sid, sid);
214 if ( (s = TALLOC_ZERO_P(mem_ctx, struct lookupsid_state)) == NULL ) {
215 DEBUG(0, ("winbindd_lookupsid_async: talloc failed\n"));
216 cont(private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
220 sid_copy( &s->sid, sid );
221 s->caller_private_data = private_data;
223 do_async_domain(mem_ctx, domain, &request, lookupsid_recv,
227 enum winbindd_result winbindd_dual_lookupsid(struct winbindd_domain *domain,
228 struct winbindd_cli_state *state)
230 enum lsa_SidType type;
235 /* Ensure null termination */
236 state->request.data.sid[sizeof(state->request.data.sid)-1]='\0';
238 DEBUG(3, ("[%5lu]: lookupsid %s\n", (unsigned long)state->pid,
239 state->request.data.sid));
241 /* Lookup sid from PDC using lsa_lookup_sids() */
243 if (!string_to_sid(&sid, state->request.data.sid)) {
244 DEBUG(5, ("%s not a SID\n", state->request.data.sid));
245 return WINBINDD_ERROR;
250 if (!winbindd_lookup_name_by_sid(state->mem_ctx, domain, &sid,
251 &dom_name, &name, &type))
253 TALLOC_FREE(dom_name);
255 return WINBINDD_ERROR;
258 fstrcpy(state->response.data.name.dom_name, dom_name);
259 fstrcpy(state->response.data.name.name, name);
260 state->response.data.name.type = type;
262 TALLOC_FREE(dom_name);
267 /********************************************************************
268 This is the second callback after contacting the forest root
269 ********************************************************************/
271 struct lookupname_state {
274 void *caller_private_data;
278 static void lookupname_recv2(TALLOC_CTX *mem_ctx, bool success,
279 struct winbindd_response *response,
280 void *c, void *private_data)
282 void (*cont)(void *priv, bool succ, const DOM_SID *sid,
283 enum lsa_SidType type) =
284 (void (*)(void *, bool, const DOM_SID *, enum lsa_SidType))c;
286 struct lookupname_state *s = talloc_get_type_abort( private_data,
287 struct lookupname_state );
291 DEBUG(5, ("Could not trigger lookup_name\n"));
292 cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
296 if (response->result != WINBINDD_OK) {
297 DEBUG(5, ("lookup_name returned an error\n"));
298 cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
302 if (!string_to_sid(&sid, response->data.sid.sid)) {
303 DEBUG(0, ("Could not convert string %s to sid\n",
304 response->data.sid.sid));
305 cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
309 cont(s->caller_private_data, True, &sid,
310 (enum lsa_SidType)response->data.sid.type);
313 /********************************************************************
314 This is the first callback after contacting our own domain
315 ********************************************************************/
317 static void lookupname_recv(TALLOC_CTX *mem_ctx, bool success,
318 struct winbindd_response *response,
319 void *c, void *private_data)
321 void (*cont)(void *priv, bool succ, const DOM_SID *sid,
322 enum lsa_SidType type) =
323 (void (*)(void *, bool, const DOM_SID *, enum lsa_SidType))c;
325 struct lookupname_state *s = talloc_get_type_abort( private_data,
326 struct lookupname_state );
329 DEBUG(5, ("lookupname_recv: lookup_name() failed!\n"));
330 cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
334 if (response->result != WINBINDD_OK) {
335 /* Try again using the forest root */
336 struct winbindd_domain *root_domain = find_root_domain();
337 struct winbindd_request request;
339 if ( !root_domain ) {
340 DEBUG(5,("lookupname_recv: unable to determine forest root\n"));
341 cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
345 ZERO_STRUCT(request);
346 request.cmd = WINBINDD_LOOKUPNAME;
348 fstrcpy( request.data.name.dom_name, s->dom_name );
349 fstrcpy( request.data.name.name, s->name );
351 do_async_domain(mem_ctx, root_domain, &request, lookupname_recv2,
357 if (!string_to_sid(&sid, response->data.sid.sid)) {
358 DEBUG(0, ("Could not convert string %s to sid\n",
359 response->data.sid.sid));
360 cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
364 cont(s->caller_private_data, True, &sid,
365 (enum lsa_SidType)response->data.sid.type);
368 /********************************************************************
369 The lookup name call first contacts a DC in its own domain
370 and fallbacks to contact a DC in the forest in our domain doesn't
372 ********************************************************************/
374 void winbindd_lookupname_async(TALLOC_CTX *mem_ctx,
375 const char *dom_name, const char *name,
376 void (*cont)(void *private_data, bool success,
378 enum lsa_SidType type),
379 enum winbindd_cmd orig_cmd,
382 struct winbindd_request request;
383 struct winbindd_domain *domain;
384 struct lookupname_state *s;
386 if ( (domain = find_lookup_domain_from_name(dom_name)) == NULL ) {
387 DEBUG(5, ("Could not find domain for name '%s'\n", dom_name));
388 cont(private_data, False, NULL, SID_NAME_UNKNOWN);
392 ZERO_STRUCT(request);
393 request.cmd = WINBINDD_LOOKUPNAME;
394 request.original_cmd = orig_cmd;
395 fstrcpy(request.data.name.dom_name, dom_name);
396 fstrcpy(request.data.name.name, name);
398 if ( (s = TALLOC_ZERO_P(mem_ctx, struct lookupname_state)) == NULL ) {
399 DEBUG(0, ("winbindd_lookupname_async: talloc failed\n"));
400 cont(private_data, False, NULL, SID_NAME_UNKNOWN);
404 s->dom_name = talloc_strdup( s, dom_name );
405 s->name = talloc_strdup( s, name );
406 s->caller_private_data = private_data;
408 do_async_domain(mem_ctx, domain, &request, lookupname_recv,
412 enum winbindd_result winbindd_dual_lookupname(struct winbindd_domain *domain,
413 struct winbindd_cli_state *state)
415 enum lsa_SidType type;
416 char *name_domain, *name_user;
420 /* Ensure null termination */
421 state->request.data.name.dom_name[sizeof(state->request.data.name.dom_name)-1]='\0';
423 /* Ensure null termination */
424 state->request.data.name.name[sizeof(state->request.data.name.name)-1]='\0';
426 /* cope with the name being a fully qualified name */
427 p = strstr(state->request.data.name.name, lp_winbind_separator());
430 name_domain = state->request.data.name.name;
433 name_domain = state->request.data.name.dom_name;
434 name_user = state->request.data.name.name;
437 DEBUG(3, ("[%5lu]: lookupname %s%s%s\n", (unsigned long)state->pid,
438 name_domain, lp_winbind_separator(), name_user));
440 /* Lookup name from DC using lsa_lookup_names() */
441 if (!winbindd_lookup_sid_by_name(state->mem_ctx, state->request.original_cmd, domain, name_domain,
442 name_user, &sid, &type)) {
443 return WINBINDD_ERROR;
446 sid_to_string(state->response.data.sid.sid, &sid);
447 state->response.data.sid.type = type;
452 bool print_sidlist(TALLOC_CTX *mem_ctx, const DOM_SID *sids,
453 size_t num_sids, char **result, ssize_t *len)
460 for (i=0; i<num_sids; i++) {
462 sprintf_append(mem_ctx, result, len, &buflen,
463 "%s\n", sid_to_string(tmp, &sids[i]));
466 if ((num_sids != 0) && (*result == NULL)) {
473 static bool parse_sidlist(TALLOC_CTX *mem_ctx, char *sidstr,
474 DOM_SID **sids, size_t *num_sids)
482 while (p[0] != '\0') {
486 DEBUG(0, ("Got invalid sidstr: %s\n", p));
491 if (!string_to_sid(&sid, p)) {
492 DEBUG(0, ("Could not parse sid %s\n", p));
495 if (!add_sid_to_array(mem_ctx, &sid, sids, num_sids)) {
503 static bool parse_ridlist(TALLOC_CTX *mem_ctx, char *ridstr,
504 uint32 **rids, size_t *num_rids)
512 while (p[0] != '\0') {
515 rid = strtoul(p, &q, 10);
517 DEBUG(0, ("Got invalid ridstr: %s\n", p));
521 ADD_TO_ARRAY(mem_ctx, uint32, rid, rids, num_rids);
526 enum winbindd_result winbindd_dual_lookuprids(struct winbindd_domain *domain,
527 struct winbindd_cli_state *state)
530 size_t i, buflen, num_rids = 0;
535 enum lsa_SidType *types;
539 DEBUG(10, ("Looking up RIDs for domain %s (%s)\n",
540 state->request.domain_name,
541 state->request.data.sid));
543 if (!parse_ridlist(state->mem_ctx, state->request.extra_data.data,
545 DEBUG(5, ("Could not parse ridlist\n"));
546 return WINBINDD_ERROR;
549 if (!string_to_sid(&domain_sid, state->request.data.sid)) {
550 DEBUG(5, ("Could not parse domain sid %s\n",
551 state->request.data.sid));
552 return WINBINDD_ERROR;
555 status = domain->methods->rids_to_names(domain, state->mem_ctx,
556 &domain_sid, rids, num_rids,
560 if (!NT_STATUS_IS_OK(status) &&
561 !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
562 return WINBINDD_ERROR;
569 for (i=0; i<num_rids; i++) {
570 sprintf_append(state->mem_ctx, &result, &len, &buflen,
571 "%d %s\n", types[i], names[i]);
574 fstrcpy(state->response.data.domain_name, domain_name);
576 if (result != NULL) {
577 state->response.extra_data.data = SMB_STRDUP(result);
578 if (!state->response.extra_data.data) {
579 return WINBINDD_ERROR;
581 state->response.length += len+1;
587 static void getsidaliases_recv(TALLOC_CTX *mem_ctx, bool success,
588 struct winbindd_response *response,
589 void *c, void *private_data)
591 void (*cont)(void *priv, bool succ,
592 DOM_SID *aliases, size_t num_aliases) =
593 (void (*)(void *, bool, DOM_SID *, size_t))c;
595 DOM_SID *sids = NULL;
599 DEBUG(5, ("Could not trigger getsidaliases\n"));
600 cont(private_data, success, NULL, 0);
604 if (response->result != WINBINDD_OK) {
605 DEBUG(5, ("getsidaliases returned an error\n"));
606 cont(private_data, False, NULL, 0);
610 aliases_str = (char *)response->extra_data.data;
612 if (aliases_str == NULL) {
613 DEBUG(10, ("getsidaliases return 0 SIDs\n"));
614 cont(private_data, True, NULL, 0);
618 if (!parse_sidlist(mem_ctx, aliases_str, &sids, &num_sids)) {
619 DEBUG(0, ("Could not parse sids\n"));
620 cont(private_data, False, NULL, 0);
624 SAFE_FREE(response->extra_data.data);
626 cont(private_data, True, sids, num_sids);
629 void winbindd_getsidaliases_async(struct winbindd_domain *domain,
631 const DOM_SID *sids, size_t num_sids,
632 void (*cont)(void *private_data,
634 const DOM_SID *aliases,
638 struct winbindd_request request;
643 cont(private_data, True, NULL, 0);
647 if (!print_sidlist(mem_ctx, sids, num_sids, &sidstr, &len)) {
648 cont(private_data, False, NULL, 0);
652 ZERO_STRUCT(request);
653 request.cmd = WINBINDD_DUAL_GETSIDALIASES;
654 request.extra_len = len;
655 request.extra_data.data = sidstr;
657 do_async_domain(mem_ctx, domain, &request, getsidaliases_recv,
658 (void *)cont, private_data);
661 enum winbindd_result winbindd_dual_getsidaliases(struct winbindd_domain *domain,
662 struct winbindd_cli_state *state)
664 DOM_SID *sids = NULL;
673 DEBUG(3, ("[%5lu]: getsidaliases\n", (unsigned long)state->pid));
675 sidstr = state->request.extra_data.data;
676 if (sidstr == NULL) {
677 sidstr = talloc_strdup(state->mem_ctx, "\n"); /* No SID */
679 DEBUG(0, ("Out of memory\n"));
680 return WINBINDD_ERROR;
684 DEBUG(10, ("Sidlist: %s\n", sidstr));
686 if (!parse_sidlist(state->mem_ctx, sidstr, &sids, &num_sids)) {
687 DEBUG(0, ("Could not parse SID list: %s\n", sidstr));
688 return WINBINDD_ERROR;
694 result = domain->methods->lookup_useraliases(domain,
700 if (!NT_STATUS_IS_OK(result)) {
701 DEBUG(3, ("Could not lookup_useraliases: %s\n",
703 return WINBINDD_ERROR;
710 DEBUG(10, ("Got %d aliases\n", num_aliases));
712 for (i=0; i<num_aliases; i++) {
714 DEBUGADD(10, (" rid %d\n", alias_rids[i]));
715 sid_copy(&sid, &domain->sid);
716 sid_append_rid(&sid, alias_rids[i]);
717 if (!add_sid_to_array(state->mem_ctx, &sid, &sids, &num_sids)) {
718 return WINBINDD_ERROR;
723 if (!print_sidlist(state->mem_ctx, sids, num_sids, &sidstr, &len)) {
724 DEBUG(0, ("Could not print_sidlist\n"));
725 state->response.extra_data.data = NULL;
726 return WINBINDD_ERROR;
729 state->response.extra_data.data = NULL;
732 state->response.extra_data.data = SMB_STRDUP(sidstr);
733 if (!state->response.extra_data.data) {
734 DEBUG(0, ("Out of memory\n"));
735 return WINBINDD_ERROR;
737 DEBUG(10, ("aliases_list: %s\n",
738 (char *)state->response.extra_data.data));
739 state->response.length += len+1;
745 struct gettoken_state {
748 struct winbindd_domain *alias_domain;
749 struct winbindd_domain *local_alias_domain;
750 struct winbindd_domain *builtin_domain;
753 void (*cont)(void *private_data, bool success, DOM_SID *sids, size_t num_sids);
757 static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success,
758 struct winbindd_response *response,
759 void *c, void *private_data);
760 static void gettoken_recvaliases(void *private_data, bool success,
761 const DOM_SID *aliases,
765 void winbindd_gettoken_async(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid,
766 void (*cont)(void *private_data, bool success,
767 DOM_SID *sids, size_t num_sids),
770 struct winbindd_domain *domain;
771 struct winbindd_request request;
772 struct gettoken_state *state;
774 state = TALLOC_ZERO_P(mem_ctx, struct gettoken_state);
776 DEBUG(0, ("talloc failed\n"));
777 cont(private_data, False, NULL, 0);
781 state->mem_ctx = mem_ctx;
782 sid_copy(&state->user_sid, user_sid);
783 state->alias_domain = find_our_domain();
784 state->local_alias_domain = find_domain_from_name( get_global_sam_name() );
785 state->builtin_domain = find_builtin_domain();
787 state->private_data = private_data;
789 domain = find_domain_from_sid_noinit(user_sid);
790 if (domain == NULL) {
791 DEBUG(5, ("Could not find domain from SID %s\n",
792 sid_string_dbg(user_sid)));
793 cont(private_data, False, NULL, 0);
797 ZERO_STRUCT(request);
798 request.cmd = WINBINDD_GETUSERDOMGROUPS;
799 sid_to_string(request.data.sid, user_sid);
801 do_async_domain(mem_ctx, domain, &request, gettoken_recvdomgroups,
805 static void gettoken_recvdomgroups(TALLOC_CTX *mem_ctx, bool success,
806 struct winbindd_response *response,
807 void *c, void *private_data)
809 struct gettoken_state *state =
810 talloc_get_type_abort(private_data, struct gettoken_state);
814 DEBUG(10, ("Could not get domain groups\n"));
815 state->cont(state->private_data, False, NULL, 0);
819 sids_str = (char *)response->extra_data.data;
821 if (sids_str == NULL) {
822 /* This could be normal if we are dealing with a
823 local user and local groups */
825 if ( !sid_check_is_in_our_domain( &state->user_sid ) ) {
826 DEBUG(10, ("Received no domain groups\n"));
827 state->cont(state->private_data, True, NULL, 0);
835 if (!add_sid_to_array(mem_ctx, &state->user_sid, &state->sids,
837 DEBUG(0, ("Out of memory\n"));
838 state->cont(state->private_data, False, NULL, 0);
842 if (sids_str && !parse_sidlist(mem_ctx, sids_str, &state->sids,
844 DEBUG(0, ("Could not parse sids\n"));
845 state->cont(state->private_data, False, NULL, 0);
849 SAFE_FREE(response->extra_data.data);
851 if (state->alias_domain == NULL) {
852 DEBUG(10, ("Don't expand domain local groups\n"));
853 state->cont(state->private_data, True, state->sids,
858 winbindd_getsidaliases_async(state->alias_domain, mem_ctx,
859 state->sids, state->num_sids,
860 gettoken_recvaliases, state);
863 static void gettoken_recvaliases(void *private_data, bool success,
864 const DOM_SID *aliases,
867 struct gettoken_state *state = (struct gettoken_state *)private_data;
871 DEBUG(10, ("Could not receive domain local groups\n"));
872 state->cont(state->private_data, False, NULL, 0);
876 for (i=0; i<num_aliases; i++) {
877 if (!add_sid_to_array(state->mem_ctx, &aliases[i],
878 &state->sids, &state->num_sids)) {
879 DEBUG(0, ("Out of memory\n"));
880 state->cont(state->private_data, False, NULL, 0);
885 if (state->local_alias_domain != NULL) {
886 struct winbindd_domain *local_domain = state->local_alias_domain;
887 DEBUG(10, ("Expanding our own local groups\n"));
888 state->local_alias_domain = NULL;
889 winbindd_getsidaliases_async(local_domain, state->mem_ctx,
890 state->sids, state->num_sids,
891 gettoken_recvaliases, state);
895 if (state->builtin_domain != NULL) {
896 struct winbindd_domain *builtin_domain = state->builtin_domain;
897 DEBUG(10, ("Expanding our own BUILTIN groups\n"));
898 state->builtin_domain = NULL;
899 winbindd_getsidaliases_async(builtin_domain, state->mem_ctx,
900 state->sids, state->num_sids,
901 gettoken_recvaliases, state);
905 state->cont(state->private_data, True, state->sids, state->num_sids);
908 static void query_user_recv(TALLOC_CTX *mem_ctx, bool success,
909 struct winbindd_response *response,
910 void *c, void *private_data)
912 void (*cont)(void *priv, bool succ, const char *acct_name,
913 const char *full_name, const char *homedir,
914 const char *shell, uint32 gid, uint32 group_rid) =
915 (void (*)(void *, bool, const char *, const char *,
916 const char *, const char *, uint32, uint32))c;
919 DEBUG(5, ("Could not trigger query_user\n"));
920 cont(private_data, False, NULL, NULL, NULL, NULL, -1, -1);
924 if (response->result != WINBINDD_OK) {
925 DEBUG(5, ("query_user returned an error\n"));
926 cont(private_data, False, NULL, NULL, NULL, NULL, -1, -1);
930 cont(private_data, True, response->data.user_info.acct_name,
931 response->data.user_info.full_name,
932 response->data.user_info.homedir,
933 response->data.user_info.shell,
934 response->data.user_info.primary_gid,
935 response->data.user_info.group_rid);
938 void query_user_async(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
940 void (*cont)(void *private_data, bool success,
941 const char *acct_name,
942 const char *full_name,
949 struct winbindd_request request;
950 ZERO_STRUCT(request);
951 request.cmd = WINBINDD_DUAL_USERINFO;
952 sid_to_string(request.data.sid, sid);
953 do_async_domain(mem_ctx, domain, &request, query_user_recv,
954 (void *)cont, private_data);