make proto
[Samba/gbeck.git] / source / rpc_server / srv_lsa.c
blobb6a8c745a45867e06f1fbd3c8714882cc1203777
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7 * Copyright (C) Paul Ashton 1997.
8 * Copyright (C) Jeremy Allison 2001.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* This is the interface to the lsa server code. */
27 #include "includes.h"
29 extern int DEBUGLEVEL;
31 /***************************************************************************
32 api_lsa_open_policy2
33 ***************************************************************************/
35 static BOOL api_lsa_open_policy2(pipes_struct *p)
37 LSA_Q_OPEN_POL2 q_u;
38 LSA_R_OPEN_POL2 r_u;
39 prs_struct *data = &p->in_data.data;
40 prs_struct *rdata = &p->out_data.rdata;
42 ZERO_STRUCT(q_u);
43 ZERO_STRUCT(r_u);
45 /* grab the server, object attributes and desired access flag...*/
46 if(!lsa_io_q_open_pol2("", &q_u, data, 0)) {
47 DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n"));
48 return False;
51 r_u.status = _lsa_open_policy2(p, &q_u, &r_u);
53 /* store the response in the SMB stream */
54 if(!lsa_io_r_open_pol2("", &r_u, rdata, 0)) {
55 DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n"));
56 return False;
59 return True;
62 /***************************************************************************
63 api_lsa_open_policy
64 ***************************************************************************/
66 static BOOL api_lsa_open_policy(pipes_struct *p)
68 LSA_Q_OPEN_POL q_u;
69 LSA_R_OPEN_POL r_u;
70 prs_struct *data = &p->in_data.data;
71 prs_struct *rdata = &p->out_data.rdata;
73 ZERO_STRUCT(q_u);
74 ZERO_STRUCT(r_u);
76 /* grab the server, object attributes and desired access flag...*/
77 if(!lsa_io_q_open_pol("", &q_u, data, 0)) {
78 DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n"));
79 return False;
82 r_u.status = _lsa_open_policy(p, &q_u, &r_u);
84 /* store the response in the SMB stream */
85 if(!lsa_io_r_open_pol("", &r_u, rdata, 0)) {
86 DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n"));
87 return False;
90 return True;
93 /***************************************************************************
94 api_lsa_enum_trust_dom
95 ***************************************************************************/
97 static BOOL api_lsa_enum_trust_dom(pipes_struct *p)
99 LSA_Q_ENUM_TRUST_DOM q_u;
100 LSA_R_ENUM_TRUST_DOM r_u;
101 prs_struct *data = &p->in_data.data;
102 prs_struct *rdata = &p->out_data.rdata;
104 ZERO_STRUCT(q_u);
105 ZERO_STRUCT(r_u);
107 /* grab the enum trust domain context etc. */
108 if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0))
109 return False;
111 r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u);
113 if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0))
114 return False;
116 return True;
119 /***************************************************************************
120 api_lsa_query_info
121 ***************************************************************************/
123 static BOOL api_lsa_query_info(pipes_struct *p)
125 LSA_Q_QUERY_INFO q_u;
126 LSA_R_QUERY_INFO r_u;
127 prs_struct *data = &p->in_data.data;
128 prs_struct *rdata = &p->out_data.rdata;
130 ZERO_STRUCT(q_u);
131 ZERO_STRUCT(r_u);
133 /* grab the info class and policy handle */
134 if(!lsa_io_q_query("", &q_u, data, 0)) {
135 DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n"));
136 return False;
139 r_u.status = _lsa_query_info(p, &q_u, &r_u);
141 /* store the response in the SMB stream */
142 if(!lsa_io_r_query("", &r_u, rdata, 0)) {
143 DEBUG(0,("api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO.\n"));
144 return False;
147 return True;
150 /***************************************************************************
151 api_lsa_lookup_sids
152 ***************************************************************************/
154 static BOOL api_lsa_lookup_sids(pipes_struct *p)
156 LSA_Q_LOOKUP_SIDS q_u;
157 LSA_R_LOOKUP_SIDS r_u;
158 prs_struct *data = &p->in_data.data;
159 prs_struct *rdata = &p->out_data.rdata;
161 ZERO_STRUCT(q_u);
162 ZERO_STRUCT(r_u);
164 /* grab the info class and policy handle */
165 if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) {
166 DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n"));
167 return False;
170 r_u.status = _lsa_lookup_sids(p, &q_u, &r_u);
172 if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) {
173 DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n"));
174 return False;
177 return True;
180 /***************************************************************************
181 api_lsa_lookup_names
182 ***************************************************************************/
184 static BOOL api_lsa_lookup_names(pipes_struct *p)
186 LSA_Q_LOOKUP_NAMES q_u;
187 LSA_R_LOOKUP_NAMES r_u;
188 prs_struct *data = &p->in_data.data;
189 prs_struct *rdata = &p->out_data.rdata;
191 ZERO_STRUCT(q_u);
192 ZERO_STRUCT(r_u);
194 /* grab the info class and policy handle */
195 if(!lsa_io_q_lookup_names("", &q_u, data, 0)) {
196 DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n"));
197 return False;
200 r_u.status = _lsa_lookup_names(p, &q_u, &r_u);
202 /* store the response in the SMB stream */
203 if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) {
204 DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n"));
205 return False;
208 return True;
211 /***************************************************************************
212 api_lsa_close.
213 ***************************************************************************/
215 static BOOL api_lsa_close(pipes_struct *p)
217 LSA_Q_CLOSE q_u;
218 LSA_R_CLOSE r_u;
219 prs_struct *data = &p->in_data.data;
220 prs_struct *rdata = &p->out_data.rdata;
222 ZERO_STRUCT(q_u);
223 ZERO_STRUCT(r_u);
225 if (!lsa_io_q_close("", &q_u, data, 0)) {
226 DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n"));
227 return False;
230 r_u.status = _lsa_close(p, &q_u, &r_u);
232 /* store the response in the SMB stream */
233 if (!lsa_io_r_close("", &r_u, rdata, 0)) {
234 DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n"));
235 return False;
238 return True;
241 /***************************************************************************
242 api_lsa_open_secret.
243 ***************************************************************************/
245 static BOOL api_lsa_open_secret(pipes_struct *p)
247 LSA_Q_OPEN_SECRET q_u;
248 LSA_R_OPEN_SECRET r_u;
249 prs_struct *data = &p->in_data.data;
250 prs_struct *rdata = &p->out_data.rdata;
252 ZERO_STRUCT(q_u);
253 ZERO_STRUCT(r_u);
255 if(!lsa_io_q_open_secret("", &q_u, data, 0)) {
256 DEBUG(0,("api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET.\n"));
257 return False;
260 r_u.status = _lsa_open_secret(p, &q_u, &r_u);
262 /* store the response in the SMB stream */
263 if(!lsa_io_r_open_secret("", &r_u, rdata, 0)) {
264 DEBUG(0,("api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET.\n"));
265 return False;
268 return True;
271 /***************************************************************************
272 \PIPE\ntlsa commands
273 ***************************************************************************/
275 static struct api_struct api_lsa_cmds[] =
277 { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 },
278 { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy },
279 { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info },
280 { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom },
281 { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close },
282 { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret },
283 { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids },
284 { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names },
285 { NULL , 0 , NULL }
288 /***************************************************************************
289 api_ntLsarpcTNP
290 ***************************************************************************/
291 BOOL api_ntlsa_rpc(pipes_struct *p)
293 return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds);