0e61b7b2d94bbb8bd1082f65c20aa28b8d6c2936
[samba.git] / source3 / include / rpc_lsa.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Andrew Tridgell               1992-1997
5    Copyright (C) Luke Kenneth Casson Leighton  1996-1997
6    Copyright (C) Paul Ashton                   1997
7    Copyright (C) Gerald (Jerry) Carter         2005
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 3 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, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef _RPC_LSA_H /* _RPC_LSA_H */
24 #define _RPC_LSA_H 
25
26 /* Opcodes available on PIPE_LSARPC */
27
28 #define LSA_CLOSE              0x00
29 #define LSA_DELETE             0x01
30 #define LSA_ENUM_PRIVS         0x02
31 #define LSA_QUERYSECOBJ        0x03
32 #define LSA_SETSECOBJ          0x04
33 #define LSA_CHANGEPASSWORD     0x05
34 #define LSA_OPENPOLICY         0x06
35 #define LSA_QUERYINFOPOLICY    0x07
36 #define LSA_SETINFOPOLICY      0x08
37 #define LSA_CLEARAUDITLOG      0x09
38 #define LSA_CREATEACCOUNT      0x0a
39 #define LSA_ENUM_ACCOUNTS      0x0b
40 #define LSA_CREATETRUSTDOM     0x0c     /* TODO: implement this one  -- jerry */
41 #define LSA_ENUMTRUSTDOM       0x0d
42 #define LSA_LOOKUPNAMES        0x0e
43 #define LSA_LOOKUPSIDS         0x0f
44 #define LSA_CREATESECRET       0x10     /* TODO: implement this one  -- jerry */
45 #define LSA_OPENACCOUNT        0x11
46 #define LSA_ENUMPRIVSACCOUNT   0x12
47 #define LSA_ADDPRIVS           0x13
48 #define LSA_REMOVEPRIVS        0x14
49 #define LSA_GETQUOTAS          0x15
50 #define LSA_SETQUOTAS          0x16
51 #define LSA_GETSYSTEMACCOUNT   0x17
52 #define LSA_SETSYSTEMACCOUNT   0x18
53 #define LSA_OPENTRUSTDOM       0x19
54 #define LSA_QUERYTRUSTDOMINFO  0x1a
55 #define LSA_SETINFOTRUSTDOM    0x1b
56 #define LSA_OPENSECRET         0x1c     /* TODO: implement this one  -- jerry */
57 #define LSA_SETSECRET          0x1d     /* TODO: implement this one  -- jerry */
58 #define LSA_QUERYSECRET        0x1e
59 #define LSA_LOOKUPPRIVVALUE    0x1f
60 #define LSA_LOOKUPPRIVNAME     0x20
61 #define LSA_PRIV_GET_DISPNAME  0x21
62 #define LSA_DELETEOBJECT       0x22     /* TODO: implement this one  -- jerry */
63 #define LSA_ENUMACCTWITHRIGHT  0x23     /* TODO: implement this one  -- jerry */
64 #define LSA_ENUMACCTRIGHTS     0x24
65 #define LSA_ADDACCTRIGHTS      0x25
66 #define LSA_REMOVEACCTRIGHTS   0x26
67 #define LSA_QUERYTRUSTDOMINFOBYSID  0x27
68 #define LSA_SETTRUSTDOMINFO    0x28
69 #define LSA_DELETETRUSTDOM     0x29
70 #define LSA_STOREPRIVDATA      0x2a
71 #define LSA_RETRPRIVDATA       0x2b
72 #define LSA_OPENPOLICY2        0x2c
73 #define LSA_UNK_GET_CONNUSER   0x2d /* LsaGetConnectedCredentials ? */
74 #define LSA_QUERYINFO2         0x2e
75 #define LSA_QUERYTRUSTDOMINFOBYNAME 0x30
76 #define LSA_QUERYDOMINFOPOL    0x35
77 #define LSA_OPENTRUSTDOMBYNAME 0x37
78
79 #define LSA_LOOKUPSIDS2        0x39
80 #define LSA_LOOKUPNAMES2       0x3a
81 #define LSA_LOOKUPNAMES3       0x44
82 #define LSA_LOOKUPSIDS3        0x4c
83 #define LSA_LOOKUPNAMES4       0x4d
84
85 /* XXXX these are here to get a compile! */
86 #define LSA_LOOKUPRIDS      0xFD
87
88 #define LSA_AUDIT_NUM_CATEGORIES_NT4    7
89 #define LSA_AUDIT_NUM_CATEGORIES_WIN2K  9
90 #define LSA_AUDIT_NUM_CATEGORIES LSA_AUDIT_NUM_CATEGORIES_NT4
91
92 #define POLICY_VIEW_LOCAL_INFORMATION    0x00000001
93 #define POLICY_VIEW_AUDIT_INFORMATION    0x00000002
94 #define POLICY_GET_PRIVATE_INFORMATION   0x00000004
95 #define POLICY_TRUST_ADMIN               0x00000008
96 #define POLICY_CREATE_ACCOUNT            0x00000010
97 #define POLICY_CREATE_SECRET             0x00000020
98 #define POLICY_CREATE_PRIVILEGE          0x00000040
99 #define POLICY_SET_DEFAULT_QUOTA_LIMITS  0x00000080
100 #define POLICY_SET_AUDIT_REQUIREMENTS    0x00000100
101 #define POLICY_AUDIT_LOG_ADMIN           0x00000200
102 #define POLICY_SERVER_ADMIN              0x00000400
103 #define POLICY_LOOKUP_NAMES              0x00000800
104
105 #define POLICY_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED_ACCESS  |\
106                             POLICY_VIEW_LOCAL_INFORMATION    |\
107                             POLICY_VIEW_AUDIT_INFORMATION    |\
108                             POLICY_GET_PRIVATE_INFORMATION   |\
109                             POLICY_TRUST_ADMIN               |\
110                             POLICY_CREATE_ACCOUNT            |\
111                             POLICY_CREATE_SECRET             |\
112                             POLICY_CREATE_PRIVILEGE          |\
113                             POLICY_SET_DEFAULT_QUOTA_LIMITS  |\
114                             POLICY_SET_AUDIT_REQUIREMENTS    |\
115                             POLICY_AUDIT_LOG_ADMIN           |\
116                             POLICY_SERVER_ADMIN              |\
117                             POLICY_LOOKUP_NAMES )
118
119
120 #define POLICY_READ       ( STANDARD_RIGHTS_READ_ACCESS      |\
121                             POLICY_VIEW_AUDIT_INFORMATION    |\
122                             POLICY_GET_PRIVATE_INFORMATION)
123
124 #define POLICY_WRITE      ( STD_RIGHT_READ_CONTROL_ACCESS     |\
125                             POLICY_TRUST_ADMIN               |\
126                             POLICY_CREATE_ACCOUNT            |\
127                             POLICY_CREATE_SECRET             |\
128                             POLICY_CREATE_PRIVILEGE          |\
129                             POLICY_SET_DEFAULT_QUOTA_LIMITS  |\
130                             POLICY_SET_AUDIT_REQUIREMENTS    |\
131                             POLICY_AUDIT_LOG_ADMIN           |\
132                             POLICY_SERVER_ADMIN)
133
134 #define POLICY_EXECUTE    ( STANDARD_RIGHTS_EXECUTE_ACCESS   |\
135                             POLICY_VIEW_LOCAL_INFORMATION    |\
136                             POLICY_LOOKUP_NAMES )
137
138 /*******************************************************/
139
140 /*******************************************************/
141
142 #define MAX_REF_DOMAINS 32
143
144 /* DOM_TRUST_HDR */
145 typedef struct dom_trust_hdr
146 {
147         UNIHDR hdr_dom_name; /* referenced domain unicode string headers */
148         uint32 ptr_dom_sid;
149
150 } DOM_TRUST_HDR;
151         
152 /* DOM_TRUST_INFO */
153 typedef struct dom_trust_info
154 {
155         UNISTR2  uni_dom_name; /* domain name unicode string */
156         DOM_SID2 ref_dom     ; /* referenced domain SID */
157
158 } DOM_TRUST_INFO;
159         
160 /* DOM_R_REF */
161 typedef struct dom_ref_info
162 {
163         uint32 num_ref_doms_1; /* num referenced domains */
164         uint32 ptr_ref_dom; /* pointer to referenced domains */
165         uint32 max_entries; /* 32 - max number of entries */
166         uint32 num_ref_doms_2; /* num referenced domains */
167
168         DOM_TRUST_HDR  hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domains */
169         DOM_TRUST_INFO ref_dom    [MAX_REF_DOMAINS]; /* referenced domains */
170
171 } DOM_R_REF;
172
173 /* the domain_idx points to a SID associated with the name */
174
175 /* LSA_TRANS_NAME - translated name */
176 typedef struct lsa_trans_name_info
177 {
178         uint16 sid_name_use; /* value is 5 for a well-known group; 2 for a domain group; 1 for a user... */
179         UNIHDR hdr_name; 
180         uint32 domain_idx; /* index into DOM_R_REF array of SIDs */
181
182 } LSA_TRANS_NAME;
183
184 /* LSA_TRANS_NAME2 - translated name */
185 typedef struct lsa_trans_name_info2
186 {
187         uint16 sid_name_use; /* value is 5 for a well-known group; 2 for a domain group; 1 for a user... */
188         UNIHDR hdr_name; 
189         uint32 domain_idx; /* index into DOM_R_REF array of SIDs */
190         uint32 unknown;
191
192 } LSA_TRANS_NAME2;
193
194 /* This number is based on Win2k and later maximum response allowed */
195 #define MAX_LOOKUP_SIDS 20480   /* 0x5000 */
196
197 /* LSA_TRANS_NAME_ENUM - LSA Translated Name Enumeration container */
198 typedef struct lsa_trans_name_enum_info
199 {
200         uint32 num_entries;
201         uint32 ptr_trans_names;
202         uint32 num_entries2;
203         
204         LSA_TRANS_NAME *name; /* translated names  */
205         UNISTR2 *uni_name;
206
207 } LSA_TRANS_NAME_ENUM;
208
209 /* LSA_TRANS_NAME_ENUM2 - LSA Translated Name Enumeration container 2 */
210 typedef struct lsa_trans_name_enum_info2
211 {
212         uint32 num_entries;
213         uint32 ptr_trans_names;
214         uint32 num_entries2;
215         
216         LSA_TRANS_NAME2 *name; /* translated names  */
217         UNISTR2 *uni_name;
218
219 } LSA_TRANS_NAME_ENUM2;
220
221 /* LSA_SID_ENUM - LSA SID enumeration container */
222 typedef struct lsa_sid_enum_info
223 {
224         uint32 num_entries;
225         uint32 ptr_sid_enum;
226         uint32 num_entries2;
227         
228         uint32 *ptr_sid; /* domain SID pointers to be looked up. */
229         DOM_SID2 *sid; /* domain SIDs to be looked up. */
230
231 } LSA_SID_ENUM;
232
233 /* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
234 typedef struct lsa_q_lookup_sids
235 {
236         POLICY_HND          pol; /* policy handle */
237         LSA_SID_ENUM        sids;
238         LSA_TRANS_NAME_ENUM names;
239         uint16              level;
240         uint32              mapped_count;
241
242 } LSA_Q_LOOKUP_SIDS;
243
244 /* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */
245 typedef struct lsa_r_lookup_sids
246 {
247         uint32              ptr_dom_ref;
248         DOM_R_REF           *dom_ref; /* domain reference info */
249
250         LSA_TRANS_NAME_ENUM names;
251         uint32              mapped_count;
252
253         NTSTATUS            status; /* return code */
254
255 } LSA_R_LOOKUP_SIDS;
256
257 /* LSA_Q_LOOKUP_SIDS2 - LSA Lookup SIDs 2*/
258 typedef struct lsa_q_lookup_sids2
259 {
260         POLICY_HND          pol; /* policy handle */
261         LSA_SID_ENUM        sids;
262         LSA_TRANS_NAME_ENUM2 names;
263         uint16              level;
264         uint32              mapped_count;
265         uint32              unknown1;
266         uint32              unknown2;
267
268 } LSA_Q_LOOKUP_SIDS2;
269
270 /* LSA_R_LOOKUP_SIDS2 - response to LSA Lookup SIDs 2*/
271 typedef struct lsa_r_lookup_sids2
272 {
273         uint32              ptr_dom_ref;
274         DOM_R_REF           *dom_ref; /* domain reference info */
275
276         LSA_TRANS_NAME_ENUM2 names;
277         uint32              mapped_count;
278
279         NTSTATUS            status; /* return code */
280
281 } LSA_R_LOOKUP_SIDS2;
282
283 /* LSA_Q_LOOKUP_SIDS3 - LSA Lookup SIDs 3 */
284 typedef struct lsa_q_lookup_sids3
285 {
286         LSA_SID_ENUM        sids;
287         LSA_TRANS_NAME_ENUM2 names;
288         uint16              level;
289         uint32              mapped_count;
290         uint32              unknown1;
291         uint32              unknown2;
292
293 } LSA_Q_LOOKUP_SIDS3;
294
295 /* LSA_R_LOOKUP_SIDS3 - response to LSA Lookup SIDs 3 */
296 typedef struct lsa_r_lookup_sids3
297 {
298         uint32              ptr_dom_ref;
299         DOM_R_REF           *dom_ref; /* domain reference info */
300
301         LSA_TRANS_NAME_ENUM2 names;
302         uint32              mapped_count;
303
304         NTSTATUS            status; /* return code */
305
306 } LSA_R_LOOKUP_SIDS3;
307
308 /* LSA_Q_LOOKUP_NAMES - LSA Lookup NAMEs */
309 typedef struct lsa_q_lookup_names
310 {
311         POLICY_HND pol; /* policy handle */
312         uint32 num_entries;
313         uint32 num_entries2;
314         UNIHDR  *hdr_name; /* name buffer pointers */
315         UNISTR2 *uni_name; /* names to be looked up */
316
317         uint32 num_trans_entries;
318         uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */
319         uint16 lookup_level;
320         uint32 mapped_count;
321
322 } LSA_Q_LOOKUP_NAMES;
323
324 /* LSA_R_LOOKUP_NAMES - response to LSA Lookup NAMEs by name */
325 typedef struct lsa_r_lookup_names
326 {
327         uint32 ptr_dom_ref;
328         DOM_R_REF *dom_ref; /* domain reference info */
329
330         uint32 num_entries;
331         uint32 ptr_entries;
332         uint32 num_entries2;
333         DOM_RID *dom_rid; /* domain RIDs being looked up */
334
335         uint32 mapped_count;
336
337         NTSTATUS status; /* return code */
338 } LSA_R_LOOKUP_NAMES;
339
340 /* LSA_Q_LOOKUP_NAMES2 - LSA Lookup NAMEs 2*/
341 typedef struct lsa_q_lookup_names2
342 {
343         POLICY_HND pol; /* policy handle */
344         uint32 num_entries;
345         uint32 num_entries2;
346         UNIHDR  *hdr_name; /* name buffer pointers */
347         UNISTR2 *uni_name; /* names to be looked up */
348
349         uint32 num_trans_entries;
350         uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */
351         uint16 lookup_level;
352         uint32 mapped_count;
353         uint32 unknown1;
354         uint32 unknown2;
355
356 } LSA_Q_LOOKUP_NAMES2;
357
358 /* LSA_R_LOOKUP_NAMES2 - response to LSA Lookup NAMEs by name 2 */
359 typedef struct lsa_r_lookup_names2
360 {
361         uint32 ptr_dom_ref;
362         DOM_R_REF *dom_ref; /* domain reference info */
363
364         uint32 num_entries;
365         uint32 ptr_entries;
366         uint32 num_entries2;
367         DOM_RID2 *dom_rid; /* domain RIDs being looked up */
368
369         uint32 mapped_count;
370
371         NTSTATUS status; /* return code */
372 } LSA_R_LOOKUP_NAMES2;
373
374 /* LSA_Q_LOOKUP_NAMES3 - LSA Lookup NAMEs 3 */
375 typedef struct lsa_q_lookup_names3
376 {
377         POLICY_HND pol; /* policy handle */
378         uint32 num_entries;
379         uint32 num_entries2;
380         UNIHDR  *hdr_name; /* name buffer pointers */
381         UNISTR2 *uni_name; /* names to be looked up */
382
383         uint32 num_trans_entries;
384         uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */
385         uint16 lookup_level;
386         uint32 mapped_count;
387         uint32 unknown1;
388         uint32 unknown2;
389
390 } LSA_Q_LOOKUP_NAMES3;
391
392 /* Sid type used in lookupnames3 and lookupnames4. */
393 typedef struct lsa_translatedsid3 {
394         uint8 sid_type;
395         DOM_SID2 *sid2;
396         uint32 sid_idx;
397         uint32 unknown;
398 } LSA_TRANSLATED_SID3;
399
400 /* LSA_R_LOOKUP_NAMES3 - response to LSA Lookup NAMEs by name 3 */
401 typedef struct lsa_r_lookup_names3
402 {
403         uint32 ptr_dom_ref;
404         DOM_R_REF *dom_ref; /* domain reference info */
405
406         uint32 num_entries;
407         uint32 ptr_entries;
408         uint32 num_entries2;
409         LSA_TRANSLATED_SID3 *trans_sids;
410
411         uint32 mapped_count;
412
413         NTSTATUS status; /* return code */
414 } LSA_R_LOOKUP_NAMES3;
415
416 /* LSA_Q_LOOKUP_NAMES4 - LSA Lookup NAMEs 4 */
417 typedef struct lsa_q_lookup_names4
418 {
419         uint32 num_entries;
420         uint32 num_entries2;
421         UNIHDR  *hdr_name; /* name buffer pointers */
422         UNISTR2 *uni_name; /* names to be looked up */
423
424         uint32 num_trans_entries;
425         uint32 ptr_trans_sids; /* undocumented domain SID buffer pointer */
426         uint16 lookup_level;
427         uint32 mapped_count;
428         uint32 unknown1;
429         uint32 unknown2;
430
431 } LSA_Q_LOOKUP_NAMES4;
432
433 /* LSA_R_LOOKUP_NAMES3 - response to LSA Lookup NAMEs by name 4 */
434 typedef struct lsa_r_lookup_names4
435 {
436         uint32 ptr_dom_ref;
437         DOM_R_REF *dom_ref; /* domain reference info */
438
439         uint32 num_entries;
440         uint32 ptr_entries;
441         uint32 num_entries2;
442         LSA_TRANSLATED_SID3 *trans_sids;
443
444         uint32 mapped_count;
445
446         NTSTATUS status; /* return code */
447 } LSA_R_LOOKUP_NAMES4;
448
449 /* LSA_Q_ENUM_ACCT_RIGHTS - LSA enum account rights */
450 typedef struct
451 {
452         POLICY_HND pol; /* policy handle */
453         DOM_SID2 sid;
454 } LSA_Q_ENUM_ACCT_RIGHTS;
455
456 /* LSA_R_ENUM_ACCT_RIGHTS - LSA enum account rights */
457 typedef struct
458 {
459         uint32 count;
460         UNISTR4_ARRAY *rights;
461         NTSTATUS status;
462 } LSA_R_ENUM_ACCT_RIGHTS;
463
464
465 /* LSA_Q_ADD_ACCT_RIGHTS - LSA add account rights */
466 typedef struct
467 {
468         POLICY_HND pol; /* policy handle */
469         DOM_SID2 sid;
470         uint32 count;
471         UNISTR4_ARRAY *rights;
472 } LSA_Q_ADD_ACCT_RIGHTS;
473
474 /* LSA_R_ADD_ACCT_RIGHTS - LSA add account rights */
475 typedef struct
476 {
477         NTSTATUS status;
478 } LSA_R_ADD_ACCT_RIGHTS;
479
480
481 /* LSA_Q_REMOVE_ACCT_RIGHTS - LSA remove account rights */
482 typedef struct
483 {
484         POLICY_HND pol; /* policy handle */
485         DOM_SID2 sid;
486         uint32 removeall;
487         uint32 count;
488         UNISTR4_ARRAY *rights;
489 } LSA_Q_REMOVE_ACCT_RIGHTS;
490
491 /* LSA_R_REMOVE_ACCT_RIGHTS - LSA remove account rights */
492 typedef struct
493 {
494         NTSTATUS status;
495 } LSA_R_REMOVE_ACCT_RIGHTS;
496
497
498 typedef struct {
499         UNIHDR hdr;
500         UNISTR2 unistring;
501 } LSA_STRING;
502
503 typedef struct {
504         POLICY_HND pol; /* policy handle */
505         LSA_STRING privname;
506 } LSA_Q_LOOKUP_PRIV_VALUE;
507
508 typedef struct {
509         LUID luid;
510         NTSTATUS status;
511 } LSA_R_LOOKUP_PRIV_VALUE;
512
513 typedef struct lsa_q_addprivs
514 {
515         POLICY_HND pol; /* policy handle */
516         uint32 count;
517         PRIVILEGE_SET set;
518 } LSA_Q_ADDPRIVS;
519
520 typedef struct lsa_r_addprivs
521 {
522         NTSTATUS status;
523 } LSA_R_ADDPRIVS;
524
525
526 typedef struct lsa_q_removeprivs
527 {
528         POLICY_HND pol; /* policy handle */
529         uint32 allrights;
530         uint32 ptr;
531         uint32 count;
532         PRIVILEGE_SET set;
533 } LSA_Q_REMOVEPRIVS;
534
535 typedef struct lsa_r_removeprivs
536 {
537         NTSTATUS status;
538 } LSA_R_REMOVEPRIVS;
539
540 #endif /* _RPC_LSA_H */