source: branches/samba-3.0/source/rpc_parse/parse_ds.c

Last change on this file was 26, checked in by Paul Smedley, 18 years ago

Updated source to 3.0.25rc1

File size: 8.2 KB
Line 
1/*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4
5 * Copyright (C) Gerald Carter 2002-2003
6 *
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 2 of the License, or
10 * (at your option) any later version.
11 *
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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include "includes.h"
23
24/************************************************************************
25************************************************************************/
26
27static BOOL ds_io_dominfobasic(const char *desc, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **basic, prs_struct *ps, int depth)
28{
29 DSROLE_PRIMARY_DOMAIN_INFO_BASIC *p = *basic;
30
31 if ( UNMARSHALLING(ps) ) {
32 p = *basic = PRS_ALLOC_MEM(ps, DSROLE_PRIMARY_DOMAIN_INFO_BASIC, 1);
33 }
34
35 if ( !p )
36 return False;
37
38 if ( !prs_uint16("machine_role", ps, depth, &p->machine_role) )
39 return False;
40 if ( !prs_align(ps) )
41 return False;
42
43 if ( !prs_uint32("flags", ps, depth, &p->flags) )
44 return False;
45
46 if ( !prs_uint32("netbios_ptr", ps, depth, &p->netbios_ptr) )
47 return False;
48 if ( !prs_uint32("dnsname_ptr", ps, depth, &p->dnsname_ptr) )
49 return False;
50 if ( !prs_uint32("forestname_ptr", ps, depth, &p->forestname_ptr) )
51 return False;
52
53 if ( !smb_io_uuid("domain_guid", &p->domain_guid, ps, depth) )
54 return False;
55
56 if ( !smb_io_unistr2( "netbios_domain", &p->netbios_domain, p->netbios_ptr, ps, depth) )
57 return False;
58 if ( !prs_align(ps) )
59 return False;
60
61 if ( !smb_io_unistr2( "dns_domain", &p->dns_domain, p->dnsname_ptr, ps, depth) )
62 return False;
63 if ( !prs_align(ps) )
64 return False;
65
66 if ( !smb_io_unistr2( "forest_domain", &p->forest_domain, p->forestname_ptr, ps, depth) )
67 return False;
68 if ( !prs_align(ps) )
69 return False;
70
71
72 return True;
73
74}
75
76/************************************************************************
77************************************************************************/
78
79BOOL ds_io_q_getprimdominfo( const char *desc, DS_Q_GETPRIMDOMINFO *q_u, prs_struct *ps, int depth)
80{
81 prs_debug(ps, depth, desc, "ds_io_q_getprimdominfo");
82 depth++;
83
84 if(!prs_align(ps))
85 return False;
86
87 if ( !prs_uint16( "level", ps, depth, &q_u->level ) )
88 return False;
89
90 return True;
91}
92
93/************************************************************************
94************************************************************************/
95
96BOOL ds_io_r_getprimdominfo( const char *desc, DS_R_GETPRIMDOMINFO *r_u, prs_struct *ps, int depth)
97{
98 prs_debug(ps, depth, desc, "ds_io_r_getprimdominfo");
99 depth++;
100
101 if(!prs_align(ps))
102 return False;
103
104 if ( !prs_uint32( "ptr", ps, depth, &r_u->ptr ) )
105 return False;
106
107 if ( r_u->ptr )
108 {
109 if ( !prs_uint16( "level", ps, depth, &r_u->level ) )
110 return False;
111
112 if ( !prs_uint16( "unknown0", ps, depth, &r_u->unknown0 ) )
113 return False;
114
115 switch ( r_u->level )
116 {
117 case DsRolePrimaryDomainInfoBasic:
118 if ( !ds_io_dominfobasic( "dominfobasic", &r_u->info.basic, ps, depth) )
119 return False;
120 break;
121 default:
122 return False;
123 }
124 }
125
126 if ( !prs_align(ps) )
127 return False;
128
129 if ( !prs_ntstatus("status", ps, depth, &r_u->status ) )
130 return False;
131
132 return True;
133}
134
135/************************************************************************
136 initialize a DS_ENUM_DOM_TRUSTS structure
137************************************************************************/
138
139BOOL init_q_ds_enum_domain_trusts( DS_Q_ENUM_DOM_TRUSTS *q, const char *server, uint32 flags )
140{
141 q->flags = flags;
142
143 if ( server && *server )
144 q->server_ptr = 1;
145 else
146 q->server_ptr = 0;
147
148 init_unistr2( &q->server, server, UNI_STR_TERMINATE);
149
150 return True;
151}
152
153/************************************************************************
154************************************************************************/
155
156static BOOL ds_io_domain_trusts( const char *desc, DS_DOMAIN_TRUSTS *trust, prs_struct *ps, int depth)
157{
158 prs_debug(ps, depth, desc, "ds_io_dom_trusts_ctr");
159 depth++;
160
161 if ( !prs_uint32( "netbios_ptr", ps, depth, &trust->netbios_ptr ) )
162 return False;
163
164 if ( !prs_uint32( "dns_ptr", ps, depth, &trust->dns_ptr ) )
165 return False;
166
167 if ( !prs_uint32( "flags", ps, depth, &trust->flags ) )
168 return False;
169
170 if ( !prs_uint32( "parent_index", ps, depth, &trust->parent_index ) )
171 return False;
172
173 if ( !prs_uint32( "trust_type", ps, depth, &trust->trust_type ) )
174 return False;
175
176 if ( !prs_uint32( "trust_attributes", ps, depth, &trust->trust_attributes ) )
177 return False;
178
179 if ( !prs_uint32( "sid_ptr", ps, depth, &trust->sid_ptr ) )
180 return False;
181
182 if ( !smb_io_uuid("guid", &trust->guid, ps, depth) )
183 return False;
184
185 return True;
186}
187
188/************************************************************************
189************************************************************************/
190
191static BOOL ds_io_dom_trusts_ctr( const char *desc, DS_DOMAIN_TRUSTS_CTR *ctr, prs_struct *ps, int depth)
192{
193 int i;
194
195 prs_debug(ps, depth, desc, "ds_io_dom_trusts_ctr");
196 depth++;
197
198 if ( !prs_uint32( "ptr", ps, depth, &ctr->ptr ) )
199 return False;
200
201 if ( !prs_uint32( "max_count", ps, depth, &ctr->max_count ) )
202 return False;
203
204 /* are we done? */
205
206 if ( ctr->max_count == 0 )
207 return True;
208
209 /* allocate the domain trusts array are parse it */
210
211 ctr->trusts = TALLOC_ARRAY(ps->mem_ctx, DS_DOMAIN_TRUSTS, ctr->max_count);
212
213 if ( !ctr->trusts )
214 return False;
215
216 /* this stinks; the static portion o fthe structure is read here and then
217 we need another loop to read the UNISTR2's and SID's */
218
219 for ( i=0; i<ctr->max_count;i++ ) {
220 if ( !ds_io_domain_trusts("domain_trusts", &ctr->trusts[i], ps, depth) )
221 return False;
222 }
223
224 for ( i=0; i<ctr->max_count; i++ ) {
225
226 if ( !smb_io_unistr2("netbios_domain", &ctr->trusts[i].netbios_domain, ctr->trusts[i].netbios_ptr, ps, depth) )
227 return False;
228
229 if(!prs_align(ps))
230 return False;
231
232 if ( !smb_io_unistr2("dns_domain", &ctr->trusts[i].dns_domain, ctr->trusts[i].dns_ptr, ps, depth) )
233 return False;
234
235 if(!prs_align(ps))
236 return False;
237
238 if ( ctr->trusts[i].sid_ptr ) {
239 if ( !smb_io_dom_sid2("sid", &ctr->trusts[i].sid, ps, depth ) )
240 return False;
241 }
242 }
243
244 return True;
245}
246
247/************************************************************************
248 initialize a DS_ENUM_DOM_TRUSTS request
249************************************************************************/
250
251BOOL ds_io_q_enum_domain_trusts( const char *desc, DS_Q_ENUM_DOM_TRUSTS *q_u, prs_struct *ps, int depth)
252{
253 prs_debug(ps, depth, desc, "ds_io_q_enum_domain_trusts");
254 depth++;
255
256 if ( !prs_align(ps) )
257 return False;
258
259 if ( !prs_uint32( "server_ptr", ps, depth, &q_u->server_ptr ) )
260 return False;
261
262 if ( !smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth) )
263 return False;
264
265 if ( !prs_align(ps) )
266 return False;
267
268 if ( !prs_uint32( "flags", ps, depth, &q_u->flags ) )
269 return False;
270
271 return True;
272}
273
274/************************************************************************
275************************************************************************/
276
277BOOL ds_io_r_enum_domain_trusts( const char *desc, DS_R_ENUM_DOM_TRUSTS *r_u, prs_struct *ps, int depth)
278{
279 prs_debug(ps, depth, desc, "ds_io_r_enum_domain_trusts");
280 depth++;
281
282 if(!prs_align(ps))
283 return False;
284
285 if ( !prs_uint32( "num_domains", ps, depth, &r_u->num_domains ) )
286 return False;
287
288 if ( r_u->num_domains ) {
289 if ( !ds_io_dom_trusts_ctr("domains", &r_u->domains, ps, depth) )
290 return False;
291 }
292
293 if(!prs_align(ps))
294 return False;
295
296 if ( !prs_ntstatus("status", ps, depth, &r_u->status ) )
297 return False;
298
299 return True;
300}
Note: See TracBrowser for help on using the repository browser.