All changes related to rpcclient...
[samba.git] / source / include / rpc_misc.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 #include "ntdomain.h"
25 #include "rpc_dce.h"
26
27 #ifndef _RPC_MISC_H /* _RPC_MISC_H */
28 #define _RPC_MISC_H 
29
30
31
32 /* well-known RIDs - Relative IDs */
33
34 /* RIDs - Well-known users ... */
35 #define DOMAIN_USER_RID_ADMIN          (0x000001F4L)
36 #define DOMAIN_USER_RID_GUEST          (0x000001F5L)
37
38 /* RIDs - well-known groups ... */
39 #define DOMAIN_GROUP_RID_ADMINS        (0x00000200L)
40 #define DOMAIN_GROUP_RID_USERS         (0x00000201L)
41 #define DOMAIN_GROUP_RID_GUESTS        (0x00000202L)
42
43 /* RIDs - well-known aliases ... */
44 #define BUILTIN_ALIAS_RID_ADMINS        (0x00000220L)
45 #define BUILTIN_ALIAS_RID_USERS         (0x00000221L)
46 #define BUILTIN_ALIAS_RID_GUESTS        (0x00000222L)
47 #define BUILTIN_ALIAS_RID_POWER_USERS   (0x00000223L)
48
49 #define BUILTIN_ALIAS_RID_ACCOUNT_OPS   (0x00000224L)
50 #define BUILTIN_ALIAS_RID_SYSTEM_OPS    (0x00000225L)
51 #define BUILTIN_ALIAS_RID_PRINT_OPS     (0x00000226L)
52 #define BUILTIN_ALIAS_RID_BACKUP_OPS    (0x00000227L)
53
54 #define BUILTIN_ALIAS_RID_REPLICATOR    (0x00000228L)
55
56 /*
57  * Masks for mappings between unix uid and gid types and
58  * NT RIDS.
59  */
60
61 /* Take the bottom bit. */
62 #define RID_TYPE_MASK 1
63 #define RID_MULTIPLIER 2
64
65 /* The two common types. */
66 #define USER_RID_TYPE 0
67 #define GROUP_RID_TYPE 1
68
69 /* ENUM_HND */
70 typedef struct enum_hnd_info
71 {
72         uint32 ptr_hnd;          /* pointer to enumeration handle */
73         uint32 handle;           /* enumeration handle */
74
75 } ENUM_HND;
76
77 /* LOOKUP_LEVEL - switch value */
78 typedef struct lookup_level_info
79 {
80   uint16 value;
81
82 } LOOKUP_LEVEL;
83
84 /* DOM_SID2 - security id */
85 typedef struct sid_info_2
86 {
87         uint32 num_auths; /* length, bytes, including length of len :-) */
88
89         DOM_SID sid;
90
91 } DOM_SID2;
92
93 /* STRHDR - string header */
94 typedef struct header_info
95 {
96   uint16 str_str_len;
97   uint16 str_max_len;
98   uint32 buffer; /* non-zero */
99
100 } STRHDR;
101
102 /* UNIHDR - unicode string header */
103 typedef struct unihdr_info
104 {
105   uint16 uni_str_len;
106   uint16 uni_max_len;
107   uint32 buffer; /* usually has a value of 4 */
108
109 } UNIHDR;
110
111 /* UNIHDR2 - unicode string header and undocumented buffer */
112 typedef struct unihdr2_info
113 {
114   UNIHDR unihdr;
115   uint32 buffer; /* 32 bit buffer pointer */
116
117 } UNIHDR2;
118
119 /* clueless as to what maximum length should be */
120 #define MAX_UNISTRLEN 256
121 #define MAX_STRINGLEN 256
122 #define MAX_BUFFERLEN 512
123
124 /* UNISTR - unicode string size and buffer */
125 typedef struct unistr_info
126 {
127   /* unicode characters. ***MUST*** be little-endian. ***MUST*** be null-terminated */
128   uint16 *buffer;
129 } UNISTR;
130
131 /* BUFHDR - buffer header */
132 typedef struct bufhdr_info
133 {
134   uint32 buf_max_len;
135   uint32 buf_len;
136
137 } BUFHDR;
138
139 /* BUFFER2 - unicode string, size (in uint8 ascii chars) and buffer */
140 /* pathetic.  some stupid team of \PIPE\winreg writers got the concept */
141 /* of a unicode string different from the other \PIPE\ writers */
142 typedef struct buffer2_info
143 {
144   uint32 buf_max_len;
145   uint32 undoc;
146   uint32 buf_len;
147   /* unicode characters. ***MUST*** be little-endian. **NOT** necessarily null-terminated */
148   uint16 *buffer;
149
150 } BUFFER2;
151
152 /* BUFFER3 */
153 typedef struct buffer3_info
154 {
155   uint32 buf_max_len;
156   uint8  *buffer; /* Data */
157   uint32 buf_len;
158
159 } BUFFER3;
160
161 /* BUFFER5 */
162 typedef struct buffer5_info
163 {
164   uint32 buf_len;
165   uint16 *buffer; /* data */
166 } BUFFER5;
167
168 /* UNISTR2 - unicode string size (in uint16 unicode chars) and buffer */
169 typedef struct unistr2_info
170 {
171   uint32 uni_max_len;
172   uint32 undoc;
173   uint32 uni_str_len;
174   /* unicode characters. ***MUST*** be little-endian. 
175      **must** be null-terminated and the uni_str_len should include
176      the NULL character */
177   uint16 *buffer;
178
179 } UNISTR2;
180
181 /* STRING2 - string size (in uint8 chars) and buffer */
182 typedef struct string2_info
183 {
184   uint32 str_max_len;
185   uint32 undoc;
186   uint32 str_str_len;
187   uint8  *buffer; /* uint8 characters. **NOT** necessarily null-terminated */
188
189 } STRING2;
190
191 /* UNISTR3 - XXXX not sure about this structure */
192 typedef struct unistr3_info
193 {
194         uint32 uni_str_len;
195         UNISTR str;
196
197 } UNISTR3;
198
199
200 /* DOM_RID2 - domain RID structure for ntlsa pipe */
201 typedef struct domrid2_info
202 {
203         uint8 type; /* value is SID_NAME_USE enum */
204         uint32 rid;
205         uint32 rid_idx; /* referenced domain index */
206
207 } DOM_RID2;
208
209 /* DOM_RID3 - domain RID structure for samr pipe */
210 typedef struct domrid3_info
211 {
212         uint32 rid;        /* domain-relative (to a SID) id */
213         uint32 type1;      /* value is 0x1 */
214         uint32 ptr_type;   /* undocumented pointer */
215         uint32 type2;      /* value is 0x1 */
216         uint32 unk; /* value is 0x2 */
217
218 } DOM_RID3;
219
220 /* DOM_RID4 - rid + user attributes */
221 typedef struct domrid4_info
222 {
223   uint32 unknown;
224   uint16 attr;
225   uint32 rid;  /* user RID */
226
227 } DOM_RID4;
228
229 /* DOM_CLNT_SRV - client / server names */
230 typedef struct clnt_srv_info
231 {
232   uint32  undoc_buffer; /* undocumented 32 bit buffer pointer */
233   UNISTR2 uni_logon_srv; /* logon server name */
234   uint32  undoc_buffer2; /* undocumented 32 bit buffer pointer */
235   UNISTR2 uni_comp_name; /* client machine name */
236
237 } DOM_CLNT_SRV;
238
239 /* DOM_LOG_INFO - login info */
240 typedef struct log_info
241 {
242   uint32  undoc_buffer; /* undocumented 32 bit buffer pointer */
243   UNISTR2 uni_logon_srv; /* logon server name */
244   UNISTR2 uni_acct_name; /* account name */
245   uint16  sec_chan;      /* secure channel type */
246   UNISTR2 uni_comp_name; /* client machine name */
247
248 } DOM_LOG_INFO;
249
250 /* DOM_CLNT_INFO - client info */
251 typedef struct clnt_info
252 {
253   DOM_LOG_INFO login;
254   DOM_CRED     cred;
255
256 } DOM_CLNT_INFO;
257
258 /* DOM_CLNT_INFO2 - client info */
259 typedef struct clnt_info2
260 {
261   DOM_CLNT_SRV login;
262   uint32        ptr_cred;
263   DOM_CRED      cred;
264
265 } DOM_CLNT_INFO2;
266
267 /* DOM_LOGON_ID - logon id */
268 typedef struct logon_info
269 {
270   uint32 low;
271   uint32 high;
272
273 } DOM_LOGON_ID;
274
275 /* OWF INFO */
276 typedef struct owf_info
277 {
278   uint8 data[16];
279
280 } OWF_INFO;
281
282
283 /* DOM_GID - group id + user attributes */
284 typedef struct gid_info
285 {
286   uint32 g_rid;  /* a group RID */
287   uint32 attr;
288
289 } DOM_GID;
290
291 #define POL_HND_SIZE 20
292
293 /* POLICY_HND */
294 typedef struct lsa_policy_info
295 {
296   uint8 data[POL_HND_SIZE]; /* policy handle */
297
298 } POLICY_HND;
299
300
301 /*
302  * A client connection's state, pipe name, 
303  * user credentials, etc...
304  */
305 typedef struct _cli_auth_fns cli_auth_fns;
306 struct user_creds;
307 struct cli_connection {
308
309         char                    *srv_name;
310         char                    *pipe_name;
311         struct user_creds       usr_creds;
312
313         struct cli_state        *pCli_state;
314
315         cli_auth_fns            *auth;
316
317         void                    *auth_info;
318         void                    *auth_creds;
319 };
320
321
322 /* 
323  * Associate a POLICY_HND with a cli_connection
324  */
325 typedef struct rpc_hnd_node {
326
327         POLICY_HND              hnd;
328         struct cli_connection   *cli;
329
330 } RPC_HND_NODE;
331
332 typedef struct uint64_s
333 {
334         uint32 low;
335         uint32 high;
336 } UINT64_S;
337
338 #endif /* _RPC_MISC_H */