90c5786a386ee191af57790afdd900d443012140
[samba.git] / source3 / 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_USER    = 1, /* user */
32         SID_NAME_DOM_GRP = 2, /* domain group */
33         SID_NAME_DOMAIN  = 3, /* domain: don't know what this is */
34         SID_NAME_ALIAS   = 4, /* local group */
35         SID_NAME_WKN_GRP = 5, /* well-known group */
36         SID_NAME_DELETED = 6, /* deleted account: needed for c2 rating */
37         SID_NAME_INVALID = 7, /* invalid account */
38         SID_NAME_UNKNOWN = 8  /* oops. */
39 };
40
41 /* ntlsa pipe */
42 #define LSA_CLOSE              0x00
43 #define LSA_QUERYINFOPOLICY    0x07
44 #define LSA_ENUMTRUSTDOM       0x0d
45 #define LSA_LOOKUPNAMES        0x0e
46 #define LSA_LOOKUPSIDS         0x0f
47 #define LSA_OPENPOLICY         0x06
48 #define LSA_OPENPOLICY2        0x2c
49 #define LSA_OPENSECRET         0x1C
50
51 /* XXXX these are here to get a compile! */
52 #define LSA_LOOKUPRIDS      0xFD
53
54 #define LSA_MAX_GROUPS 96
55 #define LSA_MAX_SIDS 128
56
57 /* DOM_QUERY - info class 3 and 5 LSA Query response */
58 typedef struct dom_query_info
59 {
60   uint16 uni_dom_max_len; /* domain name string length * 2 */
61   uint16 uni_dom_str_len; /* domain name string length * 2 */
62   uint32 buffer_dom_name; /* undocumented domain name string buffer pointer */
63   uint32 buffer_dom_sid; /* undocumented domain SID string buffer pointer */
64   UNISTR2 uni_domain_name; /* domain name (unicode string) */
65   DOM_SID2 dom_sid; /* domain SID */
66
67 } DOM_QUERY;
68
69 /* level 5 is same as level 3.  we hope. */
70 typedef DOM_QUERY DOM_QUERY_3;
71 typedef DOM_QUERY DOM_QUERY_5;
72
73 typedef struct seq_qos_info
74 {
75         uint32 len; /* 12 */
76         uint16 sec_imp_level; /* 0x02 - impersonation level */
77         uint8  sec_ctxt_mode; /* 0x01 - context tracking mode */
78         uint8  effective_only; /* 0x00 - effective only */
79         uint32 unknown;        /* 0x2000 0000 - not known */
80
81 } LSA_SEC_QOS;
82
83 typedef struct obj_attr_info
84 {
85         uint32 len;          /* 0x18 - length (in bytes) inc. the length field. */
86         uint32 ptr_root_dir; /* 0 - root directory (pointer) */
87         uint32 ptr_obj_name; /* 0 - object name (pointer) */
88         uint32 attributes;   /* 0 - attributes (undocumented) */
89         uint32 ptr_sec_desc; /* 0 - security descriptior (pointer) */
90         uint32 ptr_sec_qos;  /* security quality of service */
91         LSA_SEC_QOS *sec_qos;
92
93 } LSA_OBJ_ATTR;
94
95 /* LSA_Q_OPEN_POL - LSA Query Open Policy */
96 typedef struct lsa_q_open_pol_info
97 {
98         uint32 ptr;         /* undocumented buffer pointer */
99         uint16 system_name; /* 0x5c - system name */
100         LSA_OBJ_ATTR attr ; /* object attributes */
101
102         uint32 des_access; /* desired access attributes */
103
104 } LSA_Q_OPEN_POL;
105
106 /* LSA_R_OPEN_POL - response to LSA Open Policy */
107 typedef struct lsa_r_open_pol_info
108 {
109         POLICY_HND pol; /* policy handle */
110         uint32 status; /* return code */
111
112 } LSA_R_OPEN_POL;
113
114 /* LSA_Q_OPEN_POL2 - LSA Query Open Policy */
115 typedef struct lsa_q_open_pol2_info
116 {
117         uint32       ptr;             /* undocumented buffer pointer */
118         UNISTR2      uni_server_name; /* server name, starting with two '\'s */
119         LSA_OBJ_ATTR attr           ; /* object attributes */
120
121         uint32 des_access; /* desired access attributes */
122
123 } LSA_Q_OPEN_POL2;
124
125 /* LSA_R_OPEN_POL2 - response to LSA Open Policy */
126 typedef struct lsa_r_open_pol2_info
127 {
128         POLICY_HND pol; /* policy handle */
129         uint32 status; /* return code */
130
131 } LSA_R_OPEN_POL2;
132
133 /* LSA_Q_QUERY_SEC_OBJ - LSA query security */
134 typedef struct lsa_query_sec_obj_info
135 {
136         POLICY_HND pol; /* policy handle */
137         uint32 sec_info;
138
139 } LSA_Q_QUERY_SEC_OBJ;
140
141 /* LSA_R_QUERY_SEC_OBJ - probably an open */
142 typedef struct r_lsa_query_sec_obj_info
143 {
144         uint32 ptr;
145         SEC_DESC_BUF *buf;
146
147         uint32 status;         /* return status */
148
149 } LSA_R_QUERY_SEC_OBJ;
150
151 /* LSA_Q_QUERY_INFO - LSA query info policy */
152 typedef struct lsa_query_info
153 {
154         POLICY_HND pol; /* policy handle */
155     uint16 info_class; /* info class */
156
157 } LSA_Q_QUERY_INFO;
158
159 /* LSA_R_QUERY_INFO - response to LSA query info policy */
160 typedef struct lsa_r_query_info
161 {
162     uint32 undoc_buffer; /* undocumented buffer pointer */
163     uint16 info_class; /* info class (same as info class in request) */
164     
165         union
166     {
167         DOM_QUERY_3 id3;
168                 DOM_QUERY_5 id5;
169
170     } dom;
171
172         uint32 status; /* return code */
173
174 } LSA_R_QUERY_INFO;
175
176 /* LSA_Q_ENUM_TRUST_DOM - LSA enumerate trusted domains */
177 typedef struct lsa_enum_trust_dom_info
178 {
179         POLICY_HND pol; /* policy handle */
180     uint32 enum_context; /* enumeration context handle */
181     uint32 preferred_len; /* preferred maximum length */
182
183 } LSA_Q_ENUM_TRUST_DOM;
184
185 /* LSA_R_ENUM_TRUST_DOM - response to LSA enumerate trusted domains */
186 typedef struct lsa_r_enum_trust_dom_info
187 {
188         uint32 enum_context; /* enumeration context handle */
189         uint32 num_domains; /* number of domains */
190         uint32 ptr_enum_domains; /* buffer pointer to num domains */
191
192         /* this lot is only added if ptr_enum_domains is non-NULL */
193         uint32 num_domains2; /* number of domains */
194         UNIHDR2 *hdr_domain_name;
195         UNISTR2 *uni_domain_name;
196         DOM_SID2 *domain_sid;
197
198         uint32 status; /* return code */
199
200 } LSA_R_ENUM_TRUST_DOM;
201
202 /* LSA_Q_CLOSE */
203 typedef struct lsa_q_close_info
204 {
205         POLICY_HND pol; /* policy handle */
206
207 } LSA_Q_CLOSE;
208
209 /* LSA_R_CLOSE */
210 typedef struct lsa_r_close_info
211 {
212         POLICY_HND pol; /* policy handle.  should be all zeros. */
213
214         uint32 status; /* return code */
215
216 } LSA_R_CLOSE;
217
218
219 #define MAX_REF_DOMAINS 32
220
221 /* DOM_TRUST_HDR */
222 typedef struct dom_trust_hdr
223 {
224         UNIHDR hdr_dom_name; /* referenced domain unicode string headers */
225         uint32 ptr_dom_sid;
226
227 } DOM_TRUST_HDR;
228         
229 /* DOM_TRUST_INFO */
230 typedef struct dom_trust_info
231 {
232         UNISTR2  uni_dom_name; /* domain name unicode string */
233         DOM_SID2 ref_dom     ; /* referenced domain SID */
234
235 } DOM_TRUST_INFO;
236         
237 /* DOM_R_REF */
238 typedef struct dom_ref_info
239 {
240     uint32 num_ref_doms_1; /* num referenced domains */
241     uint32 ptr_ref_dom; /* pointer to referenced domains */
242     uint32 max_entries; /* 32 - max number of entries */
243     uint32 num_ref_doms_2; /* num referenced domains */
244
245     DOM_TRUST_HDR  hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domains */
246     DOM_TRUST_INFO ref_dom    [MAX_REF_DOMAINS]; /* referenced domains */
247
248 } DOM_R_REF;
249
250 /* the domain_idx points to a SID associated with the name */
251
252 /* LSA_TRANS_NAME - translated name */
253 typedef struct lsa_trans_name_info
254 {
255         uint16 sid_name_use; /* value is 5 for a well-known group; 2 for a domain group; 1 for a user... */
256         UNIHDR hdr_name; 
257         uint32 domain_idx; /* index into DOM_R_REF array of SIDs */
258
259 } LSA_TRANS_NAME;
260
261 #define MAX_LOOKUP_SIDS 30
262
263 /* LSA_TRANS_NAME_ENUM - LSA Translated Name Enumeration container */
264 typedef struct lsa_trans_name_enum_info
265 {
266         uint32 num_entries;
267         uint32 ptr_trans_names;
268         uint32 num_entries2;
269         
270         LSA_TRANS_NAME *name; /* translated names  */
271         UNISTR2 *uni_name;
272
273 } LSA_TRANS_NAME_ENUM;
274
275 /* LSA_SID_ENUM - LSA SID enumeration container */
276 typedef struct lsa_sid_enum_info
277 {
278         uint32 num_entries;
279         uint32 ptr_sid_enum;
280         uint32 num_entries2;
281         
282         uint32 *ptr_sid; /* domain SID pointers to be looked up. */
283         DOM_SID2 *sid; /* domain SIDs to be looked up. */
284
285 } LSA_SID_ENUM;
286
287 /* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
288 typedef struct lsa_q_lookup_sids
289 {
290         POLICY_HND          pol; /* policy handle */
291         LSA_SID_ENUM        sids;
292         LSA_TRANS_NAME_ENUM names;
293         LOOKUP_LEVEL        level;
294         uint32              mapped_count;
295
296 } LSA_Q_LOOKUP_SIDS;
297
298 /* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */
299 typedef struct lsa_r_lookup_sids
300 {
301         uint32              ptr_dom_ref;
302         DOM_R_REF           *dom_ref; /* domain reference info */
303
304         LSA_TRANS_NAME_ENUM *names;
305         uint32              mapped_count;
306
307         uint32              status; /* return code */
308
309 } LSA_R_LOOKUP_SIDS;
310
311 /* LSA_Q_LOOKUP_NAMES - LSA Lookup NAMEs */
312 typedef struct lsa_q_lookup_names
313 {
314         POLICY_HND pol; /* policy handle */
315         uint32 num_entries;
316         uint32 num_entries2;
317         UNIHDR  *hdr_name; /* name buffer pointers */
318         UNISTR2 *uni_name; /* names to be looked up */
319
320         uint32 num_trans_entries;
321         uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */
322         uint32 lookup_level;
323         uint32 mapped_count;
324
325 } LSA_Q_LOOKUP_NAMES;
326
327 /* LSA_R_LOOKUP_NAMES - response to LSA Lookup NAMEs by name */
328 typedef struct lsa_r_lookup_names
329 {
330         uint32 ptr_dom_ref;
331         DOM_R_REF *dom_ref; /* domain reference info */
332
333         uint32 num_entries;
334         uint32 ptr_entries;
335         uint32 num_entries2;
336         DOM_RID2 *dom_rid; /* domain RIDs being looked up */
337
338         uint32 mapped_count;
339
340         uint32 status; /* return code */
341
342 } LSA_R_LOOKUP_NAMES;
343
344 #endif /* _RPC_LSA_H */