2 Unix SMB/CIFS implementation.
4 Command backend for wbinfo -n
6 Copyright (C) Volker Lendecke 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "libcli/composite/composite.h"
25 #include "winbind/wb_server.h"
26 #include "smbd/service_stream.h"
28 struct cmd_lookupname_state {
29 struct composite_context *ctx;
30 struct wbsrv_call *call;
31 struct wbsrv_domain *domain;
33 struct wb_sid_object *result;
36 static struct composite_context *lookupname_send_req(void *p);
37 static NTSTATUS lookupname_recv_req(struct composite_context *ctx, void *p);
39 struct composite_context *wb_cmd_lookupname_send(struct wbsrv_call *call,
42 struct cmd_lookupname_state *state;
43 struct wbsrv_service *service = call->wbconn->listen_socket->service;
45 state = talloc(NULL, struct cmd_lookupname_state);
46 state->domain = service->domains;
48 state->name = talloc_strdup(state, name);
49 state->ctx = wb_queue_domain_send(state, state->domain,
51 call->wbconn->conn->msg_ctx,
55 if (state->ctx == NULL) {
59 state->ctx->private_data = state;
63 static struct composite_context *lookupname_send_req(void *p)
65 struct cmd_lookupname_state *state =
66 talloc_get_type(p, struct cmd_lookupname_state);
68 return wb_lsa_lookupnames_send(state->domain->lsa_pipe,
69 state->domain->lsa_policy,
73 static NTSTATUS lookupname_recv_req(struct composite_context *ctx, void *p)
75 struct cmd_lookupname_state *state =
76 talloc_get_type(p, struct cmd_lookupname_state);
77 struct wb_sid_object **sids;
80 status = wb_lsa_lookupnames_recv(ctx, state, &sids);
81 if (NT_STATUS_IS_OK(status)) {
82 state->result = sids[0];
87 NTSTATUS wb_cmd_lookupname_recv(struct composite_context *c,
89 struct wb_sid_object **sid)
91 struct cmd_lookupname_state *state =
92 talloc_get_type(c->private_data, struct cmd_lookupname_state);
93 NTSTATUS status = composite_wait(c);
94 if (NT_STATUS_IS_OK(status)) {
95 *sid = talloc_steal(mem_ctx, state->result);
101 NTSTATUS wb_cmd_lookupname(struct wbsrv_call *call, const char *name,
102 TALLOC_CTX *mem_ctx, struct wb_sid_object **sid)
104 struct composite_context *c =
105 wb_cmd_lookupname_send(call, name);
106 return wb_cmd_lookupname_recv(c, mem_ctx, sid);