Document default of the printing config variable.
[Samba/nascimento.git] / source4 / winbind / wb_irpc.c
blob0535045adb200ebf7c9e6d8b57b9d189bf9a37d7
1 /*
2 Unix SMB/CIFS implementation.
3 Main winbindd irpc handlers
5 Copyright (C) Stefan Metzmacher 2006
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "winbind/wb_server.h"
23 #include "lib/messaging/irpc.h"
24 #include "libcli/composite/composite.h"
25 #include "libcli/security/proto.h"
26 #include "librpc/gen_ndr/ndr_winbind.h"
27 #include "smbd/service_task.h"
29 struct wb_irpc_SamLogon_state {
30 struct irpc_message *msg;
31 struct winbind_SamLogon *req;
34 static void wb_irpc_SamLogon_callback(struct composite_context *ctx);
36 static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg,
37 struct winbind_SamLogon *req)
39 struct wbsrv_service *service = talloc_get_type(msg->private,
40 struct wbsrv_service);
41 struct wb_irpc_SamLogon_state *s;
42 struct composite_context *ctx;
44 DEBUG(5, ("wb_irpc_SamLogon called\n"));
46 s = talloc(msg, struct wb_irpc_SamLogon_state);
47 NT_STATUS_HAVE_NO_MEMORY(s);
49 s->msg = msg;
50 s->req = req;
52 ctx = wb_sam_logon_send(msg, service, req);
53 NT_STATUS_HAVE_NO_MEMORY(ctx);
55 ctx->async.fn = wb_irpc_SamLogon_callback;
56 ctx->async.private_data = s;
58 msg->defer_reply = true;
59 return NT_STATUS_OK;
62 static void wb_irpc_SamLogon_callback(struct composite_context *ctx)
64 struct wb_irpc_SamLogon_state *s = talloc_get_type(ctx->async.private_data,
65 struct wb_irpc_SamLogon_state);
66 NTSTATUS status;
68 DEBUG(5, ("wb_irpc_SamLogon_callback called\n"));
70 status = wb_sam_logon_recv(ctx, s, s->req);
72 irpc_send_reply(s->msg, status);
75 struct wb_irpc_get_idmap_state {
76 struct irpc_message *msg;
77 struct winbind_get_idmap *req;
78 int level;
81 static void wb_irpc_get_idmap_callback(struct composite_context *ctx);
83 static NTSTATUS wb_irpc_get_idmap(struct irpc_message *msg,
84 struct winbind_get_idmap *req)
86 struct wbsrv_service *service = talloc_get_type(msg->private,
87 struct wbsrv_service);
88 struct wb_irpc_get_idmap_state *s;
89 struct composite_context *ctx;
91 DEBUG(5, ("wb_irpc_get_idmap called\n"));
93 s = talloc(msg, struct wb_irpc_get_idmap_state);
94 NT_STATUS_HAVE_NO_MEMORY(s);
96 s->msg = msg;
97 s->req = req;
98 s->level = req->in.level;
100 switch(s->level) {
101 case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
102 ctx = wb_sids2xids_send(msg, service, req->in.count,
103 req->in.ids);
104 break;
105 case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
106 ctx = wb_xids2sids_send(msg, service, req->in.count,
107 req->in.ids);
108 break;
110 NT_STATUS_HAVE_NO_MEMORY(ctx);
112 composite_continue(ctx, ctx, wb_irpc_get_idmap_callback, s);
113 msg->defer_reply = true;
115 return NT_STATUS_OK;
118 static void wb_irpc_get_idmap_callback(struct composite_context *ctx)
120 struct wb_irpc_get_idmap_state *s;
121 NTSTATUS status;
123 DEBUG(5, ("wb_irpc_get_idmap_callback called\n"));
125 s = talloc_get_type(ctx->async.private_data,
126 struct wb_irpc_get_idmap_state);
128 switch(s->level) {
129 case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
130 status = wb_sids2xids_recv(ctx, &s->req->out.ids);
131 break;
132 case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
133 status = wb_xids2sids_recv(ctx, &s->req->out.ids);
134 break;
137 irpc_send_reply(s->msg, status);
140 NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
142 NTSTATUS status;
144 irpc_add_name(service->task->msg_ctx, "winbind_server");
146 status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_SAMLOGON,
147 wb_irpc_SamLogon, service);
148 NT_STATUS_NOT_OK_RETURN(status);
150 status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_GET_IDMAP,
151 wb_irpc_get_idmap, service);
152 NT_STATUS_NOT_OK_RETURN(status);
154 return NT_STATUS_OK;