r11068: Fix pam_auth_crap, remove the sync code. I don't know what it was when I
[ira/wip.git] / source / winbind / wb_async_helpers.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    Copyright (C) Volker Lendecke 2005
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 /*
21   a composite API for finding a DC and its name
22 */
23
24 #include "includes.h"
25 #include "libcli/composite/composite.h"
26 #include "libcli/smb_composite/smb_composite.h"
27 #include "winbind/wb_async_helpers.h"
28 #include "winbind/wb_server.h"
29 #include "smbd/service_stream.h"
30
31 #include "librpc/gen_ndr/nbt.h"
32 #include "librpc/gen_ndr/samr.h"
33 #include "lib/messaging/irpc.h"
34 #include "librpc/gen_ndr/irpc.h"
35 #include "librpc/gen_ndr/ndr_irpc.h"
36 #include "libcli/raw/libcliraw.h"
37 #include "librpc/gen_ndr/ndr_netlogon.h"
38 #include "librpc/gen_ndr/ndr_lsa.h"
39 #include "libcli/auth/credentials.h"
40
41 struct finddcs_state {
42         struct composite_context *ctx;
43         struct messaging_context *msg_ctx;
44
45         const char *domain_name;
46         const struct dom_sid *domain_sid;
47
48         struct nbtd_getdcname r;
49
50         int num_dcs;
51         struct nbt_dc_name *dcs;
52 };
53
54 static void finddcs_resolve(struct composite_context *ctx);
55 static void finddcs_getdc(struct irpc_request *ireq);
56
57 struct composite_context *wb_finddcs_send(const char *domain_name,
58                                           const struct dom_sid *domain_sid,
59                                           struct event_context *event_ctx,
60                                           struct messaging_context *msg_ctx)
61 {
62         struct composite_context *result, *ctx;
63         struct finddcs_state *state;
64         struct nbt_name name;
65
66         result = talloc_zero(NULL, struct composite_context);
67         if (result == NULL) goto failed;
68         result->state = COMPOSITE_STATE_IN_PROGRESS;
69         result->event_ctx = event_ctx;
70
71         state = talloc(result, struct finddcs_state);
72         if (state == NULL) goto failed;
73         state->ctx = result;
74         result->private_data = state;
75
76         state->domain_name = talloc_strdup(state, domain_name);
77         if (state->domain_name == NULL) goto failed;
78         state->domain_sid = dom_sid_dup(state, domain_sid);
79         if (state->domain_sid == NULL) goto failed;
80         state->msg_ctx = msg_ctx;
81
82         make_nbt_name(&name, state->domain_name, 0x1c);
83         ctx = resolve_name_send(&name, result->event_ctx,
84                                 lp_name_resolve_order());
85
86         if (ctx == NULL) goto failed;
87         ctx->async.fn = finddcs_resolve;
88         ctx->async.private_data = state;
89
90         return result;
91
92 failed:
93         talloc_free(result);
94         return NULL;
95 }
96
97 static void finddcs_resolve(struct composite_context *ctx)
98 {
99         struct finddcs_state *state =
100                 talloc_get_type(ctx->async.private_data, struct finddcs_state);
101         struct irpc_request *ireq;
102         uint32_t *nbt_servers;
103         const char *address;
104
105         state->ctx->status = resolve_name_recv(ctx, state, &address);
106         if (!composite_is_ok(state->ctx)) return;
107
108         state->num_dcs = 1;
109         state->dcs = talloc_array(state, struct nbt_dc_name, state->num_dcs);
110         if (composite_nomem(state->dcs, state->ctx)) return;
111
112         state->dcs[0].address = talloc_steal(state->dcs, address);
113
114         nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
115         if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
116                 composite_error(state->ctx, NT_STATUS_NO_LOGON_SERVERS);
117                 return;
118         }
119
120         state->r.in.domainname = state->domain_name;
121         state->r.in.ip_address = state->dcs[0].address;
122         state->r.in.my_computername = lp_netbios_name();
123         state->r.in.my_accountname = talloc_asprintf(state, "%s$",
124                                                      lp_netbios_name());
125         if (composite_nomem(state->r.in.my_accountname, state->ctx)) return;
126         state->r.in.account_control = ACB_WSTRUST;
127         state->r.in.domain_sid = dom_sid_dup(state, state->domain_sid);
128         if (composite_nomem(state->r.in.domain_sid, state->ctx)) return;
129
130         ireq = irpc_call_send(state->msg_ctx, nbt_servers[0],
131                               &dcerpc_table_irpc, DCERPC_NBTD_GETDCNAME,
132                               &state->r, state);
133         composite_continue_irpc(state->ctx, ireq, finddcs_getdc, state);
134 }
135
136 static void finddcs_getdc(struct irpc_request *ireq)
137 {
138         struct finddcs_state *state =
139                 talloc_get_type(ireq->async.private, struct finddcs_state);
140
141         state->ctx->status = irpc_call_recv(ireq);
142         if (!composite_is_ok(state->ctx)) return;
143
144         state->dcs[0].name = talloc_steal(state->dcs, state->r.out.dcname);
145         composite_done(state->ctx);
146 }
147
148 NTSTATUS wb_finddcs_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
149                          int *num_dcs, struct nbt_dc_name **dcs)
150 {
151         NTSTATUS status =composite_wait(c);
152         if (NT_STATUS_IS_OK(status)) {
153                 struct finddcs_state *state =
154                         talloc_get_type(c->private_data, struct finddcs_state);
155                 *num_dcs = state->num_dcs;
156                 *dcs = talloc_steal(mem_ctx, state->dcs);
157         }
158         talloc_free(c);
159         return status;
160 }
161
162 NTSTATUS wb_finddcs(const char *domain_name, const struct dom_sid *domain_sid,
163                     struct event_context *event_ctx,
164                     struct messaging_context *msg_ctx,
165                     TALLOC_CTX *mem_ctx,
166                     int *num_dcs, struct nbt_dc_name **dcs)
167 {
168         struct composite_context *c = wb_finddcs_send(domain_name, domain_sid,
169                                                       event_ctx, msg_ctx);
170         return wb_finddcs_recv(c, mem_ctx, num_dcs, dcs);
171 }
172
173 struct get_schannel_creds_state {
174         struct composite_context *ctx;
175         struct cli_credentials *wks_creds;
176         struct dcerpc_pipe *p;
177         struct netr_ServerReqChallenge r;
178
179         struct creds_CredentialState *creds_state;
180         struct netr_Credential netr_cred;
181         uint32_t negotiate_flags;
182         struct netr_ServerAuthenticate2 a;
183 };
184
185 static void get_schannel_creds_recv_auth(struct rpc_request *req);
186 static void get_schannel_creds_recv_chal(struct rpc_request *req);
187 static void get_schannel_creds_recv_pipe(struct composite_context *ctx);
188
189 struct composite_context *wb_get_schannel_creds_send(struct cli_credentials *wks_creds,
190                                                      struct smbcli_tree *tree,
191                                                      struct event_context *ev)
192 {
193         struct composite_context *result, *ctx;
194         struct get_schannel_creds_state *state;
195
196         result = talloc_zero(NULL, struct composite_context);
197         if (result == NULL) goto failed;
198         result->state = COMPOSITE_STATE_IN_PROGRESS;
199         result->event_ctx = ev;
200
201         state = talloc(result, struct get_schannel_creds_state);
202         if (state == NULL) goto failed;
203         result->private_data = state;
204         state->ctx = result;
205
206         state->wks_creds = wks_creds;
207
208         state->p = dcerpc_pipe_init(state, ev);
209         if (state->p == NULL) goto failed;
210
211         ctx = dcerpc_pipe_open_smb_send(state->p->conn, tree, "\\netlogon");
212         if (ctx == NULL) goto failed;
213
214         ctx->async.fn = get_schannel_creds_recv_pipe;
215         ctx->async.private_data = state;
216         return result;
217
218  failed:
219         talloc_free(result);
220         return NULL;
221 }
222
223 static void get_schannel_creds_recv_pipe(struct composite_context *ctx)
224 {
225         struct get_schannel_creds_state *state =
226                 talloc_get_type(ctx->async.private_data,
227                                 struct get_schannel_creds_state);
228         struct rpc_request *req;
229
230         state->ctx->status = dcerpc_pipe_open_smb_recv(ctx);
231         if (!composite_is_ok(state->ctx)) return;
232
233         state->ctx->status = dcerpc_bind_auth_none(state->p,
234                                                    DCERPC_NETLOGON_UUID,
235                                                    DCERPC_NETLOGON_VERSION);
236         if (!composite_is_ok(state->ctx)) return;
237
238         state->r.in.computer_name =
239                 cli_credentials_get_workstation(state->wks_creds);
240         state->r.in.server_name =
241                 talloc_asprintf(state, "\\\\%s",
242                                 dcerpc_server_name(state->p));
243         if (composite_nomem(state->r.in.server_name, state->ctx)) return;
244
245         state->r.in.credentials = talloc(state, struct netr_Credential);
246         if (composite_nomem(state->r.in.credentials, state->ctx)) return;
247
248         state->r.out.credentials = talloc(state, struct netr_Credential);
249         if (composite_nomem(state->r.out.credentials, state->ctx)) return;
250
251         generate_random_buffer(state->r.in.credentials->data,
252                                sizeof(state->r.in.credentials->data));
253
254         req = dcerpc_netr_ServerReqChallenge_send(state->p, state, &state->r);
255         composite_continue_rpc(state->ctx, req,
256                                get_schannel_creds_recv_chal, state);
257 }
258
259 static void get_schannel_creds_recv_chal(struct rpc_request *req)
260 {
261         struct get_schannel_creds_state *state =
262                 talloc_get_type(req->async.private,
263                                 struct get_schannel_creds_state);
264         const struct samr_Password *mach_pwd;
265
266         state->ctx->status = dcerpc_ndr_request_recv(req);
267         if (!composite_is_ok(state->ctx)) return;
268         state->ctx->status = state->r.out.result;
269         if (!composite_is_ok(state->ctx)) return;
270
271         state->creds_state = talloc(state, struct creds_CredentialState);
272         if (composite_nomem(state->creds_state, state->ctx)) return;
273
274         mach_pwd = cli_credentials_get_nt_hash(state->wks_creds, state);
275         if (composite_nomem(mach_pwd, state->ctx)) return;
276
277         state->negotiate_flags = NETLOGON_NEG_AUTH2_FLAGS;
278
279         creds_client_init(state->creds_state, state->r.in.credentials,
280                           state->r.out.credentials, mach_pwd,
281                           &state->netr_cred, state->negotiate_flags);
282
283         state->a.in.server_name =
284                 talloc_reference(state, state->r.in.server_name);
285         state->a.in.account_name =
286                 cli_credentials_get_username(state->wks_creds);
287         state->a.in.secure_channel_type =
288                 cli_credentials_get_secure_channel_type(state->wks_creds);
289         state->a.in.computer_name =
290                 cli_credentials_get_workstation(state->wks_creds);
291         state->a.in.negotiate_flags = &state->negotiate_flags;
292         state->a.out.negotiate_flags = &state->negotiate_flags;
293         state->a.in.credentials = &state->netr_cred;
294         state->a.out.credentials = &state->netr_cred;
295
296         req = dcerpc_netr_ServerAuthenticate2_send(state->p, state, &state->a);
297         composite_continue_rpc(state->ctx, req,
298                                get_schannel_creds_recv_auth, state);
299 }
300
301 static void get_schannel_creds_recv_auth(struct rpc_request *req)
302 {
303         struct get_schannel_creds_state *state =
304                 talloc_get_type(req->async.private,
305                                 struct get_schannel_creds_state);
306
307         state->ctx->status = dcerpc_ndr_request_recv(req);
308         if (!NT_STATUS_IS_OK(state->ctx->status)) goto done;
309         state->ctx->status = state->a.out.result;
310         if (!NT_STATUS_IS_OK(state->ctx->status)) goto done;
311
312         if (!creds_client_check(state->creds_state,
313                                 state->a.out.credentials)) {
314                 DEBUG(5, ("Server got us invalid creds\n"));
315                 state->ctx->status = NT_STATUS_UNSUCCESSFUL;
316                 goto done;
317         }
318
319         cli_credentials_set_netlogon_creds(state->wks_creds,
320                                            state->creds_state);
321
322         state->ctx->state = COMPOSITE_STATE_DONE;
323
324  done:
325         if (!NT_STATUS_IS_OK(state->ctx->status)) {
326                 state->ctx->state = COMPOSITE_STATE_ERROR;
327         }
328         if ((state->ctx->state >= COMPOSITE_STATE_DONE) &&
329             (state->ctx->async.fn != NULL)) {
330                 state->ctx->async.fn(state->ctx);
331         }
332 }
333
334 NTSTATUS wb_get_schannel_creds_recv(struct composite_context *c,
335                                     TALLOC_CTX *mem_ctx,
336                                     struct dcerpc_pipe **netlogon_pipe)
337 {
338         NTSTATUS status = composite_wait(c);
339         if (NT_STATUS_IS_OK(status)) {
340                 struct get_schannel_creds_state *state =
341                         talloc_get_type(c->private_data,
342                                         struct get_schannel_creds_state);
343                 *netlogon_pipe = talloc_steal(mem_ctx, state->p);
344         }
345         talloc_free(c);
346         return status;
347 }
348
349 NTSTATUS wb_get_schannel_creds(struct cli_credentials *wks_creds,
350                                struct smbcli_tree *tree,
351                                struct event_context *event_ctx,
352                                TALLOC_CTX *mem_ctx,
353                                struct dcerpc_pipe **netlogon_pipe)
354 {
355         struct composite_context *c =
356                 wb_get_schannel_creds_send(wks_creds, tree, event_ctx);
357         return wb_get_schannel_creds_recv(c, mem_ctx, netlogon_pipe);
358 }
359
360 struct lsa_lookupnames_state {
361         struct composite_context *ctx;
362         uint32_t num_names;
363         struct lsa_LookupNames r;
364         struct lsa_TransSidArray sids;
365         uint32_t count;
366         struct wb_sid_object **result;
367 };
368
369 static void lsa_lookupnames_recv_sids(struct rpc_request *req);
370
371 struct composite_context *wb_lsa_lookupnames_send(struct dcerpc_pipe *lsa_pipe,
372                                                   struct policy_handle *handle,
373                                                   int num_names,
374                                                   const char **names)
375 {
376         struct composite_context *result;
377         struct rpc_request *req;
378         struct lsa_lookupnames_state *state;
379
380         struct lsa_String *lsa_names;
381         int i;
382
383         result = talloc_zero(NULL, struct composite_context);
384         if (result == NULL) goto failed;
385         result->state = COMPOSITE_STATE_IN_PROGRESS;
386         result->event_ctx = lsa_pipe->conn->event_ctx;
387
388         state = talloc(result, struct lsa_lookupnames_state);
389         if (state == NULL) goto failed;
390         result->private_data = state;
391         state->ctx = result;
392
393         state->sids.count = 0;
394         state->sids.sids = NULL;
395         state->num_names = num_names;
396         state->count = 0;
397
398         lsa_names = talloc_array(state, struct lsa_String, num_names);
399         if (lsa_names == NULL) goto failed;
400
401         for (i=0; i<num_names; i++) {
402                 lsa_names[i].string = names[i];
403         }
404
405         state->r.in.handle = handle;
406         state->r.in.num_names = num_names;
407         state->r.in.names = lsa_names;
408         state->r.in.sids = &state->sids;
409         state->r.in.level = 1;
410         state->r.in.count = &state->count;
411         state->r.out.count = &state->count;
412         state->r.out.sids = &state->sids;
413
414         req = dcerpc_lsa_LookupNames_send(lsa_pipe, state, &state->r);
415         if (req == NULL) goto failed;
416
417         req->async.callback = lsa_lookupnames_recv_sids;
418         req->async.private = state;
419         return result;
420
421  failed:
422         talloc_free(result);
423         return NULL;
424 }
425
426 static void lsa_lookupnames_recv_sids(struct rpc_request *req)
427 {
428         struct lsa_lookupnames_state *state =
429                 talloc_get_type(req->async.private,
430                                 struct lsa_lookupnames_state);
431         int i;
432
433         state->ctx->status = dcerpc_ndr_request_recv(req);
434         if (!composite_is_ok(state->ctx)) return;
435         state->ctx->status = state->r.out.result;
436         if (!NT_STATUS_IS_OK(state->ctx->status) &&
437             !NT_STATUS_EQUAL(state->ctx->status, STATUS_SOME_UNMAPPED)) {
438                 composite_error(state->ctx, state->ctx->status);
439                 return;
440         }
441
442         state->result = talloc_array(state, struct wb_sid_object *,
443                                      state->num_names);
444         if (composite_nomem(state->result, state->ctx)) return;
445
446         for (i=0; i<state->num_names; i++) {
447                 struct lsa_TranslatedSid *sid = &state->r.out.sids->sids[i];
448                 struct lsa_TrustInformation *dom;
449
450                 state->result[i] = talloc_zero(state->result,
451                                                struct wb_sid_object);
452                 if (composite_nomem(state->result[i], state->ctx)) return;
453
454                 state->result[i]->type = sid->sid_type;
455                 if (state->result[i]->type == SID_NAME_UNKNOWN) {
456                         continue;
457                 }
458
459                 if (sid->sid_index >= state->r.out.domains->count) {
460                         composite_error(state->ctx,
461                                         NT_STATUS_INVALID_PARAMETER);
462                         return;
463                 }
464
465                 dom = &state->r.out.domains->domains[sid->sid_index];
466
467                 state->result[i]->sid = dom_sid_add_rid(state->result[i],
468                                                         dom->sid, sid->rid);
469         }
470
471         composite_done(state->ctx);
472 }
473
474 NTSTATUS wb_lsa_lookupnames_recv(struct composite_context *c,
475                                  TALLOC_CTX *mem_ctx,
476                                  struct wb_sid_object ***sids)
477 {
478         NTSTATUS status = composite_wait(c);
479         if (NT_STATUS_IS_OK(status)) {
480                 struct lsa_lookupnames_state *state =
481                         talloc_get_type(c->private_data,
482                                         struct lsa_lookupnames_state);
483                 *sids = talloc_steal(mem_ctx, state->result);
484         }
485         talloc_free(c);
486         return status;
487 }
488
489 NTSTATUS wb_lsa_lookupnames(struct dcerpc_pipe *lsa_pipe, 
490                             struct policy_handle *handle,
491                             int num_names, const char **names,
492                             TALLOC_CTX *mem_ctx,
493                             struct wb_sid_object ***sids)
494 {
495         struct composite_context *c =
496                 wb_lsa_lookupnames_send(lsa_pipe, handle, num_names, names);
497         return wb_lsa_lookupnames_recv(c, mem_ctx, sids);
498 }
499
500 struct cmd_lookupname_state {
501         struct composite_context *ctx;
502         struct wbsrv_call *call;
503         struct wbsrv_domain *domain;
504         const char *name;
505         struct wb_sid_object *result;
506 };
507
508 static void cmd_lookupname_recv_init(struct composite_context *ctx);
509 static void cmd_lookupname_recv_sid(struct composite_context *ctx);
510
511 struct composite_context *wb_cmd_lookupname_send(struct wbsrv_call *call,
512                                                  const char *name)
513 {
514         struct composite_context *result, *ctx;
515         struct cmd_lookupname_state *state;
516         struct wbsrv_service *service = call->wbconn->listen_socket->service;
517
518         result = talloc_zero(call, struct composite_context);
519         if (result == NULL) goto failed;
520         result->state = COMPOSITE_STATE_IN_PROGRESS;
521         result->event_ctx = call->event_ctx;
522
523         state = talloc(result, struct cmd_lookupname_state);
524         if (state == NULL) goto failed;
525         state->ctx = result;
526         result->private_data = state;
527
528         state->call = call;
529         state->name = talloc_strdup(state, name);
530
531         state->domain = service->domains;
532
533         if (state->domain->initialized) {
534                 ctx = wb_lsa_lookupnames_send(state->domain->lsa_pipe,
535                                               state->domain->lsa_policy,
536                                               1, &state->name);
537                 if (ctx == NULL) goto failed;
538                 ctx->async.fn = cmd_lookupname_recv_sid;
539                 ctx->async.private_data = state;
540                 return result;
541         }
542
543         ctx = wb_init_domain_send(state->domain,
544                                   result->event_ctx, 
545                                   call->wbconn->conn->msg_ctx);
546         if (ctx == NULL) goto failed;
547         ctx->async.fn = cmd_lookupname_recv_init;
548         ctx->async.private_data = state;
549         return result;
550
551  failed:
552         talloc_free(result);
553         return NULL;
554 }
555
556 static void cmd_lookupname_recv_init(struct composite_context *ctx)
557 {
558         struct cmd_lookupname_state *state =
559                 talloc_get_type(ctx->async.private_data,
560                                 struct cmd_lookupname_state);
561
562         state->ctx->status = wb_init_domain_recv(ctx);
563         if (!composite_is_ok(state->ctx)) return;
564
565         ctx = wb_lsa_lookupnames_send(state->domain->lsa_pipe,
566                                       state->domain->lsa_policy,
567                                       1, &state->name);
568         composite_continue(state->ctx, ctx, cmd_lookupname_recv_sid, state);
569 }
570
571 static void cmd_lookupname_recv_sid(struct composite_context *ctx)
572 {
573         struct cmd_lookupname_state *state =
574                 talloc_get_type(ctx->async.private_data,
575                                 struct cmd_lookupname_state);
576         struct wb_sid_object **sids;
577
578         state->ctx->status = wb_lsa_lookupnames_recv(ctx, state, &sids);
579         if (!composite_is_ok(state->ctx)) return;
580         state->result = sids[0];
581         composite_done(state->ctx);
582 }
583
584 NTSTATUS wb_cmd_lookupname_recv(struct composite_context *c,
585                                 TALLOC_CTX *mem_ctx,
586                                 struct wb_sid_object **sid)
587 {
588         NTSTATUS status = composite_wait(c);
589         if (NT_STATUS_IS_OK(status)) {
590                 struct cmd_lookupname_state *state =
591                         talloc_get_type(c->private_data,
592                                         struct cmd_lookupname_state);
593                 *sid = talloc_steal(mem_ctx, state->result);
594         }
595         talloc_free(c);
596         return status;
597 }
598
599 NTSTATUS wb_cmd_lookupname(struct wbsrv_call *call, const char *name,
600                            TALLOC_CTX *mem_ctx, struct wb_sid_object **sid)
601 {
602         struct composite_context *c =
603                 wb_cmd_lookupname_send(call, name);
604         return wb_cmd_lookupname_recv(c, mem_ctx, sid);
605 }
606
607 struct cmd_checkmachacc_state {
608         struct composite_context *ctx;
609         struct wbsrv_call *call;
610         struct wbsrv_domain *domain;
611 };
612
613 static void cmd_checkmachacc_recv_init(struct composite_context *ctx);
614
615 struct composite_context *wb_cmd_checkmachacc_send(struct wbsrv_call *call)
616 {
617         struct composite_context *result, *ctx;
618         struct cmd_checkmachacc_state *state;
619         struct wbsrv_service *service = call->wbconn->listen_socket->service;
620
621         result = talloc(call, struct composite_context);
622         if (result == NULL) goto failed;
623         result->state = COMPOSITE_STATE_IN_PROGRESS;
624         result->event_ctx = call->event_ctx;
625
626         state = talloc(result, struct cmd_checkmachacc_state);
627         if (state == NULL) goto failed;
628         state->ctx = result;
629         result->private_data = state;
630         state->call = call;
631
632         state->domain = service->domains;
633
634         ctx = wb_init_domain_send(state->domain, result->event_ctx, 
635                                   call->wbconn->conn->msg_ctx);
636         if (ctx == NULL) goto failed;
637         ctx->async.fn = cmd_checkmachacc_recv_init;
638         ctx->async.private_data = state;
639
640         return result;
641
642  failed:
643         talloc_free(result);
644         return NULL;
645 }
646
647 static void cmd_checkmachacc_recv_init(struct composite_context *ctx)
648 {
649         struct cmd_checkmachacc_state *state =
650                 talloc_get_type(ctx->async.private_data,
651                                 struct cmd_checkmachacc_state);
652
653         state->ctx->status = wb_init_domain_recv(ctx);
654         if (!composite_is_ok(state->ctx)) return;
655
656         composite_done(state->ctx);
657 }
658
659 NTSTATUS wb_cmd_checkmachacc_recv(struct composite_context *c)
660 {
661         NTSTATUS status = composite_wait(c);
662         talloc_free(c);
663         return status;
664 }
665
666 NTSTATUS wb_cmd_checkmachacc(struct wbsrv_call *call)
667 {
668         struct composite_context *c = wb_cmd_checkmachacc_send(call);
669         return wb_cmd_checkmachacc_recv(c);
670 }