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