the next stage in the NTSTATUS/WERROR change. smbd and nmbd now compile, but the...
[bbaumbach/samba-autobuild/.git] / source / include / rpc_lsa.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB parameters and setup
5    Copyright (C) Andrew Tridgell 1992-1997
6    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
7    Copyright (C) Paul Ashton 1997
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef _RPC_LSA_H /* _RPC_LSA_H */
25 #define _RPC_LSA_H 
26
27 #include "rpc_misc.h"
28
29 enum SID_NAME_USE
30 {
31         SID_NAME_USE_NONE = 0,/* NOTUSED */
32         SID_NAME_USER    = 1, /* user */
33         SID_NAME_DOM_GRP = 2, /* domain group */
34         SID_NAME_DOMAIN  = 3, /* domain: don't know what this is */
35         SID_NAME_ALIAS   = 4, /* local group */
36         SID_NAME_WKN_GRP = 5, /* well-known group */
37         SID_NAME_DELETED = 6, /* deleted account: needed for c2 rating */
38         SID_NAME_INVALID = 7, /* invalid account */
39         SID_NAME_UNKNOWN = 8  /* oops. */
40 };
41
42 /* ntlsa pipe */
43 #define LSA_CLOSE              0x00
44 #define LSA_ENUM_PRIVS         0x02
45 #define LSA_OPENPOLICY         0x06
46 #define LSA_QUERYINFOPOLICY    0x07
47 #define LSA_ENUM_ACCOUNTS      0x0b
48 #define LSA_ENUMTRUSTDOM       0x0d
49 #define LSA_LOOKUPNAMES        0x0e
50 #define LSA_LOOKUPSIDS         0x0f
51 #define LSA_OPENACCOUNT         0x11
52 #define LSA_ENUMPRIVSACCOUNT    0x12
53 #define LSA_GETSYSTEMACCOUNT    0x17
54 #define LSA_OPENSECRET         0x1C
55 #define LSA_PRIV_GET_DISPNAME  0x21
56 #define LSA_OPENPOLICY2        0x2c
57 #define LSA_UNK_GET_CONNUSER   0x2d /* LsaGetConnectedCredentials ? */
58
59 /* XXXX these are here to get a compile! */
60 #define LSA_LOOKUPRIDS      0xFD
61
62 #define LSA_MAX_GROUPS 96
63 #define LSA_MAX_SIDS 128
64
65 /* DOM_QUERY - info class 3 and 5 LSA Query response */
66 typedef struct dom_query_info
67 {
68   uint16 uni_dom_max_len; /* domain name string length * 2 */
69   uint16 uni_dom_str_len; /* domain name string length * 2 */
70   uint32 buffer_dom_name; /* undocumented domain name string buffer pointer */
71   uint32 buffer_dom_sid; /* undocumented domain SID string buffer pointer */
72   UNISTR2 uni_domain_name; /* domain name (unicode string) */
73   DOM_SID2 dom_sid; /* domain SID */
74
75 } DOM_QUERY;
76
77 /* level 5 is same as level 3.  we hope. */
78 typedef DOM_QUERY DOM_QUERY_3;
79 typedef DOM_QUERY DOM_QUERY_5;
80
81 /* level 2 is auditing settings */
82 typedef struct dom_query_2
83 {
84         uint32 auditing_enabled;
85         uint32 count1; /* usualy 7, at least on nt4sp4 */
86         uint32 count2; /* the same */
87         uint32 *auditsettings;
88 } DOM_QUERY_2;
89
90 /* level 6 is server role information */
91 typedef struct dom_query_6
92 {
93         uint16 server_role; /* 2=backup, 3=primary */
94 } DOM_QUERY_6;
95
96 typedef struct seq_qos_info
97 {
98         uint32 len; /* 12 */
99         uint16 sec_imp_level; /* 0x02 - impersonation level */
100         uint8  sec_ctxt_mode; /* 0x01 - context tracking mode */
101         uint8  effective_only; /* 0x00 - effective only */
102         uint32 unknown;        /* 0x2000 0000 - not known */
103
104 } LSA_SEC_QOS;
105
106 typedef struct obj_attr_info
107 {
108         uint32 len;          /* 0x18 - length (in bytes) inc. the length field. */
109         uint32 ptr_root_dir; /* 0 - root directory (pointer) */
110         uint32 ptr_obj_name; /* 0 - object name (pointer) */
111         uint32 attributes;   /* 0 - attributes (undocumented) */
112         uint32 ptr_sec_desc; /* 0 - security descriptior (pointer) */
113         uint32 ptr_sec_qos;  /* security quality of service */
114         LSA_SEC_QOS *sec_qos;
115
116 } LSA_OBJ_ATTR;
117
118 /* LSA_Q_OPEN_POL - LSA Query Open Policy */
119 typedef struct lsa_q_open_pol_info
120 {
121         uint32 ptr;         /* undocumented buffer pointer */
122         uint16 system_name; /* 0x5c - system name */
123         LSA_OBJ_ATTR attr ; /* object attributes */
124
125         uint32 des_access; /* desired access attributes */
126
127 } LSA_Q_OPEN_POL;
128
129 /* LSA_R_OPEN_POL - response to LSA Open Policy */
130 typedef struct lsa_r_open_pol_info
131 {
132         POLICY_HND pol; /* policy handle */
133         NTSTATUS status; /* return code */
134
135 } LSA_R_OPEN_POL;
136
137 /* LSA_Q_OPEN_POL2 - LSA Query Open Policy */
138 typedef struct lsa_q_open_pol2_info
139 {
140         uint32       ptr;             /* undocumented buffer pointer */
141         UNISTR2      uni_server_name; /* server name, starting with two '\'s */
142         LSA_OBJ_ATTR attr           ; /* object attributes */
143
144         uint32 des_access; /* desired access attributes */
145
146 } LSA_Q_OPEN_POL2;
147
148 /* LSA_R_OPEN_POL2 - response to LSA Open Policy */
149 typedef struct lsa_r_open_pol2_info
150 {
151         POLICY_HND pol; /* policy handle */
152         NTSTATUS status; /* return code */
153
154 } LSA_R_OPEN_POL2;
155
156 /* LSA_Q_QUERY_SEC_OBJ - LSA query security */
157 typedef struct lsa_query_sec_obj_info
158 {
159         POLICY_HND pol; /* policy handle */
160         uint32 sec_info;
161
162 } LSA_Q_QUERY_SEC_OBJ;
163
164 /* LSA_R_QUERY_SEC_OBJ - probably an open */
165 typedef struct r_lsa_query_sec_obj_info
166 {
167         uint32 ptr;
168         SEC_DESC_BUF *buf;
169
170         NTSTATUS status;         /* return status */
171
172 } LSA_R_QUERY_SEC_OBJ;
173
174 /* LSA_Q_QUERY_INFO - LSA query info policy */
175 typedef struct lsa_query_info
176 {
177         POLICY_HND pol; /* policy handle */
178     uint16 info_class; /* info class */
179
180 } LSA_Q_QUERY_INFO;
181
182 /* LSA_INFO_UNION */
183 typedef union lsa_info_union
184 {
185         DOM_QUERY_2 id2;
186         DOM_QUERY_3 id3;
187         DOM_QUERY_5 id5;
188         DOM_QUERY_6 id6;
189 } LSA_INFO_UNION;
190
191 /* LSA_R_QUERY_INFO - response to LSA query info policy */
192 typedef struct lsa_r_query_info
193 {
194     uint32 undoc_buffer; /* undocumented buffer pointer */
195     uint16 info_class; /* info class (same as info class in request) */
196    
197         LSA_INFO_UNION dom; 
198
199         NTSTATUS status; /* return code */
200
201 } LSA_R_QUERY_INFO;
202
203 /* LSA_Q_ENUM_TRUST_DOM - LSA enumerate trusted domains */
204 typedef struct lsa_enum_trust_dom_info
205 {
206         POLICY_HND pol; /* policy handle */
207     uint32 enum_context; /* enumeration context handle */
208     uint32 preferred_len; /* preferred maximum length */
209
210 } LSA_Q_ENUM_TRUST_DOM;
211
212 /* LSA_R_ENUM_TRUST_DOM - response to LSA enumerate trusted domains */
213 typedef struct lsa_r_enum_trust_dom_info
214 {
215         uint32 enum_context; /* enumeration context handle */
216         uint32 num_domains; /* number of domains */
217         uint32 ptr_enum_domains; /* buffer pointer to num domains */
218
219         /* this lot is only added if ptr_enum_domains is non-NULL */
220         uint32 num_domains2; /* number of domains */
221         UNIHDR2 *hdr_domain_name;
222         UNISTR2 *uni_domain_name;
223         DOM_SID2 *domain_sid;
224
225         NTSTATUS status; /* return code */
226
227 } LSA_R_ENUM_TRUST_DOM;
228
229 /* LSA_Q_CLOSE */
230 typedef struct lsa_q_close_info
231 {
232         POLICY_HND pol; /* policy handle */
233
234 } LSA_Q_CLOSE;
235
236 /* LSA_R_CLOSE */
237 typedef struct lsa_r_close_info
238 {
239         POLICY_HND pol; /* policy handle.  should be all zeros. */
240
241         NTSTATUS status; /* return code */
242
243 } LSA_R_CLOSE;
244
245
246 #define MAX_REF_DOMAINS 32
247
248 /* DOM_TRUST_HDR */
249 typedef struct dom_trust_hdr
250 {
251         UNIHDR hdr_dom_name; /* referenced domain unicode string headers */
252         uint32 ptr_dom_sid;
253
254 } DOM_TRUST_HDR;
255         
256 /* DOM_TRUST_INFO */
257 typedef struct dom_trust_info
258 {
259         UNISTR2  uni_dom_name; /* domain name unicode string */
260         DOM_SID2 ref_dom     ; /* referenced domain SID */
261
262 } DOM_TRUST_INFO;
263         
264 /* DOM_R_REF */
265 typedef struct dom_ref_info
266 {
267     uint32 num_ref_doms_1; /* num referenced domains */
268     uint32 ptr_ref_dom; /* pointer to referenced domains */
269     uint32 max_entries; /* 32 - max number of entries */
270     uint32 num_ref_doms_2; /* num referenced domains */
271
272     DOM_TRUST_HDR  hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domains */
273     DOM_TRUST_INFO ref_dom    [MAX_REF_DOMAINS]; /* referenced domains */
274
275 } DOM_R_REF;
276
277 /* the domain_idx points to a SID associated with the name */
278
279 /* LSA_TRANS_NAME - translated name */
280 typedef struct lsa_trans_name_info
281 {
282         uint16 sid_name_use; /* value is 5 for a well-known group; 2 for a domain group; 1 for a user... */
283         UNIHDR hdr_name; 
284         uint32 domain_idx; /* index into DOM_R_REF array of SIDs */
285
286 } LSA_TRANS_NAME;
287
288 #define MAX_LOOKUP_SIDS 30
289
290 /* LSA_TRANS_NAME_ENUM - LSA Translated Name Enumeration container */
291 typedef struct lsa_trans_name_enum_info
292 {
293         uint32 num_entries;
294         uint32 ptr_trans_names;
295         uint32 num_entries2;
296         
297         LSA_TRANS_NAME *name; /* translated names  */
298         UNISTR2 *uni_name;
299
300 } LSA_TRANS_NAME_ENUM;
301
302 /* LSA_SID_ENUM - LSA SID enumeration container */
303 typedef struct lsa_sid_enum_info
304 {
305         uint32 num_entries;
306         uint32 ptr_sid_enum;
307         uint32 num_entries2;
308         
309         uint32 *ptr_sid; /* domain SID pointers to be looked up. */
310         DOM_SID2 *sid; /* domain SIDs to be looked up. */
311
312 } LSA_SID_ENUM;
313
314 /* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
315 typedef struct lsa_q_lookup_sids
316 {
317         POLICY_HND          pol; /* policy handle */
318         LSA_SID_ENUM        sids;
319         LSA_TRANS_NAME_ENUM names;
320         LOOKUP_LEVEL        level;
321         uint32              mapped_count;
322
323 } LSA_Q_LOOKUP_SIDS;
324
325 /* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */
326 typedef struct lsa_r_lookup_sids
327 {
328         uint32              ptr_dom_ref;
329         DOM_R_REF           *dom_ref; /* domain reference info */
330
331         LSA_TRANS_NAME_ENUM *names;
332         uint32              mapped_count;
333
334         NTSTATUS            status; /* return code */
335
336 } LSA_R_LOOKUP_SIDS;
337
338 /* LSA_Q_LOOKUP_NAMES - LSA Lookup NAMEs */
339 typedef struct lsa_q_lookup_names
340 {
341         POLICY_HND pol; /* policy handle */
342         uint32 num_entries;
343         uint32 num_entries2;
344         UNIHDR  *hdr_name; /* name buffer pointers */
345         UNISTR2 *uni_name; /* names to be looked up */
346
347         uint32 num_trans_entries;
348         uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */
349         uint32 lookup_level;
350         uint32 mapped_count;
351
352 } LSA_Q_LOOKUP_NAMES;
353
354 /* LSA_R_LOOKUP_NAMES - response to LSA Lookup NAMEs by name */
355 typedef struct lsa_r_lookup_names
356 {
357         uint32 ptr_dom_ref;
358         DOM_R_REF *dom_ref; /* domain reference info */
359
360         uint32 num_entries;
361         uint32 ptr_entries;
362         uint32 num_entries2;
363         DOM_RID2 *dom_rid; /* domain RIDs being looked up */
364
365         uint32 mapped_count;
366
367         NTSTATUS status; /* return code */
368 } LSA_R_LOOKUP_NAMES;
369
370 /* This is probably a policy handle but at the moment we
371    never read it - so use a dummy struct. */
372
373 typedef struct lsa_q_open_secret
374 {
375         uint32 dummy;
376 } LSA_Q_OPEN_SECRET;
377
378 /* We always return "not found" at present - so just marshal the minimum. */
379
380 typedef struct lsa_r_open_secret
381 {
382         uint32 dummy1;
383         uint32 dummy2;
384         uint32 dummy3;
385         uint32 dummy4;
386         NTSTATUS status;
387 } LSA_R_OPEN_SECRET;
388
389 typedef struct lsa_enum_priv_entry
390 {
391         UNIHDR hdr_name;
392         uint32 luid_low;
393         uint32 luid_high;
394         UNISTR2 name;
395         
396 } LSA_PRIV_ENTRY;
397
398 /* LSA_Q_ENUM_PRIVS - LSA enum privileges */
399 typedef struct lsa_q_enum_privs
400 {
401         POLICY_HND pol; /* policy handle */
402         uint32 enum_context;
403         uint32 pref_max_length;
404 } LSA_Q_ENUM_PRIVS;
405
406 typedef struct lsa_r_enum_privs
407 {
408         uint32 enum_context;
409         uint32 count;
410         uint32 ptr;
411         uint32 count1;
412
413         LSA_PRIV_ENTRY *privs;
414
415         NTSTATUS status;
416 } LSA_R_ENUM_PRIVS;
417
418 /* LSA_Q_PRIV_GET_DISPNAME - LSA get privilege display name */
419 typedef struct lsa_q_priv_get_dispname
420 {
421         POLICY_HND pol; /* policy handle */
422         UNIHDR hdr_name;
423         UNISTR2 name;
424         uint16 lang_id;
425         uint16 lang_id_sys;
426 } LSA_Q_PRIV_GET_DISPNAME;
427
428 typedef struct lsa_r_priv_get_dispname
429 {
430         uint32 ptr_info;
431         UNIHDR hdr_desc;
432         UNISTR2 desc;
433         /* Don't align ! */
434         uint16 lang_id;
435         /* align */
436         NTSTATUS status;
437 } LSA_R_PRIV_GET_DISPNAME;
438
439 /* LSA_Q_ENUM_ACCOUNTS */
440 typedef struct lsa_q_enum_accounts
441 {
442         POLICY_HND pol; /* policy handle */
443         uint32 enum_context;
444         uint32 pref_max_length;
445 } LSA_Q_ENUM_ACCOUNTS;
446
447 /* LSA_R_ENUM_ACCOUNTS */
448 typedef struct lsa_r_enum_accounts
449 {
450         uint32 enum_context;
451         LSA_SID_ENUM sids;
452         NTSTATUS status;
453 } LSA_R_ENUM_ACCOUNTS;
454
455 /* LSA_Q_UNK_GET_CONNUSER - gets username\domain of connected user
456                   called when "Take Ownership" is clicked -SK */
457 typedef struct lsa_q_unk_get_connuser
458 {
459   uint32 ptr_srvname;
460   UNISTR2 uni2_srvname;
461   uint32 unk1; /* 3 unknown uint32's are seen right after uni2_srvname */
462   uint32 unk2; /* unk2 appears to be a ptr, unk1 = unk3 = 0 usually */
463   uint32 unk3; 
464 } LSA_Q_UNK_GET_CONNUSER;
465
466 /* LSA_R_UNK_GET_CONNUSER */
467 typedef struct lsa_r_unk_get_connuser
468 {
469   uint32 ptr_user_name;
470   UNIHDR hdr_user_name;
471   UNISTR2 uni2_user_name;
472   
473   uint32 unk1;
474   
475   uint32 ptr_dom_name;
476   UNIHDR hdr_dom_name;
477   UNISTR2 uni2_dom_name;
478
479   NTSTATUS status;
480 } LSA_R_UNK_GET_CONNUSER;
481
482
483 typedef struct lsa_q_openaccount
484 {
485         POLICY_HND pol; /* policy handle */
486         DOM_SID2 sid;
487         uint32 access; /* desired access */
488 } LSA_Q_OPENACCOUNT;
489
490 typedef struct lsa_r_openaccount
491 {
492         POLICY_HND pol; /* policy handle */
493         NTSTATUS status;
494 } LSA_R_OPENACCOUNT;
495
496 typedef struct lsa_q_enumprivsaccount
497 {
498         POLICY_HND pol; /* policy handle */
499 } LSA_Q_ENUMPRIVSACCOUNT;
500
501
502 typedef struct LUID
503 {
504         uint32 low;
505         uint32 high;
506 } LUID;
507
508 typedef struct LUID_ATTR
509 {
510         LUID luid;
511         uint32 attr;
512 } LUID_ATTR ;
513
514 typedef struct privilege_set
515 {
516         uint32 count;
517         uint32 control;
518         LUID_ATTR *set;
519 } PRIVILEGE_SET;
520
521 typedef struct lsa_r_enumprivsaccount
522 {
523         uint32 ptr;
524         uint32 count;
525         PRIVILEGE_SET set;
526         NTSTATUS status;
527 } LSA_R_ENUMPRIVSACCOUNT;
528
529 typedef struct lsa_q_getsystemaccount
530 {
531         POLICY_HND pol; /* policy handle */
532 } LSA_Q_GETSYSTEMACCOUNT;
533
534 typedef struct lsa_r_getsystemaccount
535 {
536         uint32 access;
537         NTSTATUS status;
538 } LSA_R_GETSYSTEMACCOUNT;
539
540
541 #endif /* _RPC_LSA_H */
542 /*
543
544 opnum 11: opensid: query: handle du domaine, sid du user
545 reply: handle, status
546
547 opnum 12: getlistofprivs: query: handle du user
548 reply: ptr, nombre, nombre, tableau de 3 uint32: flag+priv.low+priv.high
549 uint32 0, status 
550
551 opnum 17: ?? query: handle
552 reply: uint32 + status
553
554
555 */
556
557
558