dsdb-acl: ask for the objectClass attribute if it's not in the scope of the clients...
[Samba/gebeck_regimport.git] / source4 / winbind / wb_irpc.c
blob628114e404ee927b6ad31f681f28fe2c1c57e516
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 "librpc/gen_ndr/ndr_winbind.h"
26 #include "smbd/service_task.h"
28 struct wb_irpc_SamLogon_state {
29 struct irpc_message *msg;
30 struct winbind_SamLogon *req;
33 static void wb_irpc_SamLogon_callback(struct tevent_req *subreq);
35 static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg,
36 struct winbind_SamLogon *req)
38 struct wbsrv_service *service = talloc_get_type(msg->private_data,
39 struct wbsrv_service);
40 struct wb_irpc_SamLogon_state *s;
41 struct tevent_req *subreq;
43 DEBUG(5, ("wb_irpc_SamLogon called\n"));
45 s = talloc(msg, struct wb_irpc_SamLogon_state);
46 NT_STATUS_HAVE_NO_MEMORY(s);
48 s->msg = msg;
49 s->req = req;
51 subreq = wb_sam_logon_send(s,
52 service->task->event_ctx,
53 service, req);
54 NT_STATUS_HAVE_NO_MEMORY(subreq);
56 tevent_req_set_callback(subreq, wb_irpc_SamLogon_callback, s);
58 msg->defer_reply = true;
59 return NT_STATUS_OK;
62 static void wb_irpc_SamLogon_callback(struct tevent_req *subreq)
64 struct wb_irpc_SamLogon_state *s =
65 tevent_req_callback_data(subreq,
66 struct wb_irpc_SamLogon_state);
67 NTSTATUS status;
69 DEBUG(5, ("wb_irpc_SamLogon_callback called\n"));
71 status = wb_sam_logon_recv(subreq, s, s->req);
72 TALLOC_FREE(subreq);
74 irpc_send_reply(s->msg, status);
77 struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state {
78 struct irpc_message *msg;
79 struct winbind_DsrUpdateReadOnlyServerDnsRecords *req;
82 static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req *subreq);
84 static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *msg,
85 struct winbind_DsrUpdateReadOnlyServerDnsRecords *req)
87 struct wbsrv_service *service = talloc_get_type(msg->private_data,
88 struct wbsrv_service);
89 struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s;
90 struct tevent_req *subreq;
92 DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords called\n"));
94 s = talloc(msg, struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state);
95 NT_STATUS_HAVE_NO_MEMORY(s);
97 s->msg = msg;
98 s->req = req;
100 subreq = wb_update_rodc_dns_send(s,
101 service->task->event_ctx,
102 service, req);
103 NT_STATUS_HAVE_NO_MEMORY(subreq);
105 tevent_req_set_callback(subreq,
106 wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback,
109 msg->defer_reply = true;
110 return NT_STATUS_OK;
113 static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req *subreq)
115 struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s =
116 tevent_req_callback_data(subreq,
117 struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state);
118 NTSTATUS status;
120 DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback called\n"));
122 status = wb_update_rodc_dns_recv(subreq, s, s->req);
123 TALLOC_FREE(subreq);
125 irpc_send_reply(s->msg, status);
128 struct wb_irpc_get_idmap_state {
129 struct irpc_message *msg;
130 struct winbind_get_idmap *req;
131 int level;
134 static void wb_irpc_get_idmap_callback(struct composite_context *ctx);
136 static NTSTATUS wb_irpc_get_idmap(struct irpc_message *msg,
137 struct winbind_get_idmap *req)
139 struct wbsrv_service *service = talloc_get_type(msg->private_data,
140 struct wbsrv_service);
141 struct wb_irpc_get_idmap_state *s;
142 struct composite_context *ctx = NULL;
144 DEBUG(5, ("wb_irpc_get_idmap called\n"));
146 s = talloc(msg, struct wb_irpc_get_idmap_state);
147 NT_STATUS_HAVE_NO_MEMORY(s);
149 s->msg = msg;
150 s->req = req;
151 s->level = req->in.level;
153 switch(s->level) {
154 case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
155 ctx = wb_sids2xids_send(msg, service, req->in.count,
156 req->in.ids);
157 break;
158 case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
159 ctx = wb_xids2sids_send(msg, service, req->in.count,
160 req->in.ids);
161 break;
163 NT_STATUS_HAVE_NO_MEMORY(ctx);
165 composite_continue(ctx, ctx, wb_irpc_get_idmap_callback, s);
166 msg->defer_reply = true;
168 return NT_STATUS_OK;
171 static void wb_irpc_get_idmap_callback(struct composite_context *ctx)
173 struct wb_irpc_get_idmap_state *s;
174 NTSTATUS status;
176 DEBUG(5, ("wb_irpc_get_idmap_callback called\n"));
178 s = talloc_get_type(ctx->async.private_data,
179 struct wb_irpc_get_idmap_state);
181 switch(s->level) {
182 case WINBIND_IDMAP_LEVEL_SIDS_TO_XIDS:
183 status = wb_sids2xids_recv(ctx, &s->req->out.ids, NULL);
184 break;
185 case WINBIND_IDMAP_LEVEL_XIDS_TO_SIDS:
186 status = wb_xids2sids_recv(ctx, &s->req->out.ids);
187 break;
188 default:
189 status = NT_STATUS_INTERNAL_ERROR;
190 break;
193 irpc_send_reply(s->msg, status);
196 NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
198 NTSTATUS status;
200 irpc_add_name(service->task->msg_ctx, "winbind_server");
202 status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_SAMLOGON,
203 wb_irpc_SamLogon, service);
204 NT_STATUS_NOT_OK_RETURN(status);
206 status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_DSRUPDATEREADONLYSERVERDNSRECORDS,
207 wb_irpc_DsrUpdateReadOnlyServerDnsRecords, service);
208 NT_STATUS_NOT_OK_RETURN(status);
210 status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_GET_IDMAP,
211 wb_irpc_get_idmap, service);
212 NT_STATUS_NOT_OK_RETURN(status);
214 return NT_STATUS_OK;