summaryrefslogtreecommitdiffstats
path: root/source4/winbind/wb_irpc.c
blob: 7a4ca69baa840f2ad7ca9a9858f8be4a9d30e90c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* 
   Unix SMB/CIFS implementation.
   Main winbindd irpc handlers

   Copyright (C) Stefan Metzmacher	2006
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "includes.h"
#include "winbind/wb_server.h"
#include "lib/messaging/irpc.h"
#include "libcli/composite/composite.h"
#include "librpc/gen_ndr/ndr_winbind.h"
#include "smbd/service_task.h"

struct wb_irpc_SamLogon_state {
	struct irpc_message *msg;
	struct winbind_SamLogon *req;
};

static void wb_irpc_SamLogon_callback(struct tevent_req *subreq);

static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg, 
				 struct winbind_SamLogon *req)
{
	struct wbsrv_service *service = talloc_get_type(msg->private_data,
					struct wbsrv_service);
	struct wb_irpc_SamLogon_state *s;
	struct tevent_req *subreq;

	DEBUG(5, ("wb_irpc_SamLogon called\n"));

	s = talloc(msg, struct wb_irpc_SamLogon_state);
	NT_STATUS_HAVE_NO_MEMORY(s);

	s->msg = msg;
	s->req = req;

	subreq = wb_sam_logon_send(s,
				   service->task->event_ctx,
				   service, req);
	NT_STATUS_HAVE_NO_MEMORY(subreq);

	tevent_req_set_callback(subreq, wb_irpc_SamLogon_callback, s);

	msg->defer_reply = true;
	return NT_STATUS_OK;
}

static void wb_irpc_SamLogon_callback(struct tevent_req *subreq)
{
	struct wb_irpc_SamLogon_state *s =
		tevent_req_callback_data(subreq,
		struct wb_irpc_SamLogon_state);
	NTSTATUS status;

	DEBUG(5, ("wb_irpc_SamLogon_callback called\n"));

	status = wb_sam_logon_recv(subreq, s, s->req);
	TALLOC_FREE(subreq);

	irpc_send_reply(s->msg, status);
}

struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state {
	struct irpc_message *msg;
	struct winbind_DsrUpdateReadOnlyServerDnsRecords *req;
};

static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req *subreq);

static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *msg,
				 struct winbind_DsrUpdateReadOnlyServerDnsRecords *req)
{
	struct wbsrv_service *service = talloc_get_type(msg->private_data,
					struct wbsrv_service);
	struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s;
	struct tevent_req *subreq;

	DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords called\n"));

	s = talloc(msg, struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state);
	NT_STATUS_HAVE_NO_MEMORY(s);

	s->msg = msg;
	s->req = req;

	subreq = wb_update_rodc_dns_send(s,
					 service->task->event_ctx,
					 service, req);
	NT_STATUS_HAVE_NO_MEMORY(subreq);

	tevent_req_set_callback(subreq,
				wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback,
				s);

	msg->defer_reply = true;
	return NT_STATUS_OK;
}

static void wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback(struct tevent_req *subreq)
{
	struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state *s =
		tevent_req_callback_data(subreq,
		struct wb_irpc_DsrUpdateReadOnlyServerDnsRecords_state);
	NTSTATUS status;

	DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords_callback called\n"));

	status = wb_update_rodc_dns_recv(subreq, s, s->req);
	TALLOC_FREE(subreq);

	irpc_send_reply(s->msg, status);
}

NTSTATUS wbsrv_init_irpc(struct wbsrv_service *service)
{
	NTSTATUS status;

	irpc_add_name(service->task->msg_ctx, "winbind_server");

	status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_SAMLOGON,
			       wb_irpc_SamLogon, service);
	NT_STATUS_NOT_OK_RETURN(status);

	status = IRPC_REGISTER(service->task->msg_ctx, winbind, WINBIND_DSRUPDATEREADONLYSERVERDNSRECORDS,
			       wb_irpc_DsrUpdateReadOnlyServerDnsRecords, service);
	NT_STATUS_NOT_OK_RETURN(status);

	return NT_STATUS_OK;
}