Use pidl for _samr_QueryUserInfo.
[ira/wip.git] / source3 / rpc_client / init_samr.c
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Guenther Deschner                  2008.
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include "includes.h"
21
22 /*******************************************************************
23  inits a structure.
24 ********************************************************************/
25
26 static void init_lsa_String(struct lsa_String *name, const char *s)
27 {
28         name->string = s;
29 }
30
31 /*******************************************************************
32  inits a structure.
33 ********************************************************************/
34
35 void init_samr_DomInfo1(struct samr_DomInfo1 *r,
36                         uint16_t min_password_length,
37                         uint16_t password_history_length,
38                         uint32_t password_properties,
39                         int64_t max_password_age,
40                         int64_t min_password_age)
41 {
42         r->min_password_length = min_password_length;
43         r->password_history_length = password_history_length;
44         r->password_properties = password_properties;
45         r->max_password_age = max_password_age;
46         r->min_password_age = min_password_age;
47 }
48
49 /*******************************************************************
50  inits a structure.
51 ********************************************************************/
52
53 void init_samr_DomInfo2(struct samr_DomInfo2 *r,
54                         NTTIME force_logoff_time,
55                         const char *comment,
56                         const char *domain_name,
57                         const char *primary,
58                         uint64_t sequence_num,
59                         uint32_t unknown2,
60                         enum samr_Role role,
61                         uint32_t unknown3,
62                         uint32_t num_users,
63                         uint32_t num_groups,
64                         uint32_t num_aliases)
65 {
66         r->force_logoff_time = force_logoff_time;
67         init_lsa_String(&r->comment, comment);
68         init_lsa_String(&r->domain_name, domain_name);
69         init_lsa_String(&r->primary, primary);
70         r->sequence_num = sequence_num;
71         r->unknown2 = unknown2;
72         r->role = role;
73         r->unknown3 = unknown3;
74         r->num_users = num_users;
75         r->num_groups = num_groups;
76         r->num_aliases = num_aliases;
77 }
78
79 /*******************************************************************
80  inits a structure.
81 ********************************************************************/
82
83 void init_samr_DomInfo3(struct samr_DomInfo3 *r,
84                         NTTIME force_logoff_time)
85 {
86         r->force_logoff_time = force_logoff_time;
87 }
88
89 /*******************************************************************
90  inits a structure.
91 ********************************************************************/
92
93 void init_samr_DomInfo4(struct samr_DomInfo4 *r,
94                         const char *comment)
95 {
96         init_lsa_String(&r->comment, comment);
97 }
98
99 /*******************************************************************
100  inits a structure.
101 ********************************************************************/
102
103 void init_samr_DomInfo5(struct samr_DomInfo5 *r,
104                         const char *domain_name)
105 {
106         init_lsa_String(&r->domain_name, domain_name);
107 }
108
109 /*******************************************************************
110  inits a structure.
111 ********************************************************************/
112
113 void init_samr_DomInfo6(struct samr_DomInfo6 *r,
114                         const char *primary)
115 {
116         init_lsa_String(&r->primary, primary);
117 }
118
119 /*******************************************************************
120  inits a structure.
121 ********************************************************************/
122
123 void init_samr_DomInfo7(struct samr_DomInfo7 *r,
124                         enum samr_Role role)
125 {
126         r->role = role;
127 }
128
129 /*******************************************************************
130  inits a structure.
131 ********************************************************************/
132
133 void init_samr_DomInfo8(struct samr_DomInfo8 *r,
134                         uint64_t sequence_num,
135                         NTTIME domain_create_time)
136 {
137         r->sequence_num = sequence_num;
138         r->domain_create_time = domain_create_time;
139 }
140
141 /*******************************************************************
142  inits a structure.
143 ********************************************************************/
144
145 void init_samr_DomInfo9(struct samr_DomInfo9 *r,
146                         uint32_t unknown)
147 {
148         r->unknown = unknown;
149 }
150
151 /*******************************************************************
152  inits a structure.
153 ********************************************************************/
154
155 void init_samr_DomInfo12(struct samr_DomInfo12 *r,
156                          uint64_t lockout_duration,
157                          uint64_t lockout_window,
158                          uint16_t lockout_threshold)
159 {
160         r->lockout_duration = lockout_duration;
161         r->lockout_window = lockout_window;
162         r->lockout_threshold = lockout_threshold;
163 }
164
165 /*******************************************************************
166  inits a samr_GroupInfoAll structure.
167 ********************************************************************/
168
169 void init_samr_group_info1(struct samr_GroupInfoAll *r,
170                            const char *name,
171                            uint32_t attributes,
172                            uint32_t num_members,
173                            const char *description)
174 {
175         DEBUG(5, ("init_samr_group_info1\n"));
176
177         init_lsa_String(&r->name, name);
178         r->attributes = attributes;
179         r->num_members = num_members;
180         init_lsa_String(&r->description, description);
181 }
182
183 /*******************************************************************
184  inits a lsa_String structure
185 ********************************************************************/
186
187 void init_samr_group_info2(struct lsa_String *r, const char *group_name)
188 {
189         DEBUG(5, ("init_samr_group_info2\n"));
190
191         init_lsa_String(r, group_name);
192 }
193
194 /*******************************************************************
195  inits a samr_GroupInfoAttributes structure.
196 ********************************************************************/
197
198 void init_samr_group_info3(struct samr_GroupInfoAttributes *r,
199                            uint32_t attributes)
200 {
201         DEBUG(5, ("init_samr_group_info3\n"));
202
203         r->attributes = attributes;
204 }
205
206 /*******************************************************************
207  inits a lsa_String structure
208 ********************************************************************/
209
210 void init_samr_group_info4(struct lsa_String *r, const char *description)
211 {
212         DEBUG(5, ("init_samr_group_info4\n"));
213
214         init_lsa_String(r, description);
215 }
216
217 /*******************************************************************
218  inits a samr_GroupInfoAll structure.
219 ********************************************************************/
220
221 void init_samr_group_info5(struct samr_GroupInfoAll *r,
222                            const char *name,
223                            uint32_t attributes,
224                            uint32_t num_members,
225                            const char *description)
226 {
227         DEBUG(5, ("init_samr_group_info5\n"));
228
229         init_lsa_String(&r->name, name);
230         r->attributes = attributes;
231         r->num_members = num_members;
232         init_lsa_String(&r->description, description);
233 }
234
235 /*******************************************************************
236  inits a samr_AliasInfoAll structure.
237 ********************************************************************/
238
239 void init_samr_alias_info1(struct samr_AliasInfoAll *r,
240                            const char *name,
241                            uint32_t num_members,
242                            const char *description)
243 {
244         DEBUG(5, ("init_samr_alias_info1\n"));
245
246         init_lsa_String(&r->name, name);
247         r->num_members = num_members;
248         init_lsa_String(&r->description, description);
249 }
250
251 /*******************************************************************
252 inits a lsa_String structure.
253 ********************************************************************/
254
255 void init_samr_alias_info3(struct lsa_String *r,
256                            const char *description)
257 {
258         DEBUG(5, ("init_samr_alias_info3\n"));
259
260         init_lsa_String(r, description);
261 }
262
263 /*******************************************************************
264  inits a samr_UserInfo7 structure.
265 ********************************************************************/
266
267 void init_samr_user_info7(struct samr_UserInfo7 *r,
268                           const char *account_name)
269 {
270         DEBUG(5, ("init_samr_user_info7\n"));
271
272         init_lsa_String(&r->account_name, account_name);
273 }
274
275 /*******************************************************************
276  inits a samr_UserInfo9 structure.
277 ********************************************************************/
278
279 void init_samr_user_info9(struct samr_UserInfo9 *r,
280                           uint32_t primary_gid)
281 {
282         DEBUG(5, ("init_samr_user_info9\n"));
283
284         r->primary_gid = primary_gid;
285 }
286
287 /*******************************************************************
288  inits a SAM_USER_INFO_16 structure.
289 ********************************************************************/
290
291 void init_samr_user_info16(struct samr_UserInfo16 *r,
292                            uint32_t acct_flags)
293 {
294         DEBUG(5, ("init_samr_user_info16\n"));
295
296         r->acct_flags = acct_flags;
297 }
298
299 /*******************************************************************
300  inits a samr_UserInfo18 structure.
301 ********************************************************************/
302
303 void init_samr_user_info18(struct samr_UserInfo18 *r,
304                            const uint8 lm_pwd[16],
305                            const uint8 nt_pwd[16])
306 {
307         DEBUG(5, ("init_samr_user_info18\n"));
308
309         r->lm_pwd_active =
310                 memcpy(r->lm_pwd.hash, lm_pwd, sizeof(r->lm_pwd.hash)) ? true : false;
311         r->nt_pwd_active =
312                 memcpy(r->nt_pwd.hash, nt_pwd, sizeof(r->nt_pwd.hash)) ? true : false;
313 }
314
315 /*******************************************************************
316  inits a samr_UserInfo20 structure.
317 ********************************************************************/
318
319 void init_samr_user_info20(struct samr_UserInfo20 *r,
320                            const char *munged_dial)
321 {
322         init_lsa_String(&r->parameters, munged_dial);
323 }
324
325 /*************************************************************************
326  inits a samr_UserInfo21 structure
327  *************************************************************************/
328
329 void init_samr_user_info21(struct samr_UserInfo21 *r,
330                            NTTIME last_logon,
331                            NTTIME last_logoff,
332                            NTTIME last_password_change,
333                            NTTIME acct_expiry,
334                            NTTIME allow_password_change,
335                            NTTIME force_password_change,
336                            const char *account_name,
337                            const char *full_name,
338                            const char *home_directory,
339                            const char *home_drive,
340                            const char *logon_script,
341                            const char *profile_path,
342                            const char *description,
343                            const char *workstations,
344                            const char *comment,
345                            const char *parameters,
346                            uint32_t rid,
347                            uint32_t primary_gid,
348                            uint32_t acct_flags,
349                            uint32_t fields_present,
350                            struct samr_LogonHours logon_hours,
351                            uint16_t bad_password_count,
352                            uint16_t logon_count,
353                            uint16_t country_code,
354                            uint16_t code_page,
355                            uint8_t nt_password_set,
356                            uint8_t lm_password_set,
357                            uint8_t password_expired)
358 {
359         r->last_logon = last_logon;
360         r->last_logoff = last_logoff;
361         r->last_password_change = last_password_change;
362         r->acct_expiry = acct_expiry;
363         r->allow_password_change = allow_password_change;
364         r->force_password_change = force_password_change;
365         init_lsa_String(&r->account_name, account_name);
366         init_lsa_String(&r->full_name, full_name);
367         init_lsa_String(&r->home_directory, home_directory);
368         init_lsa_String(&r->home_drive, home_drive);
369         init_lsa_String(&r->logon_script, logon_script);
370         init_lsa_String(&r->profile_path, profile_path);
371         init_lsa_String(&r->description, description);
372         init_lsa_String(&r->workstations, workstations);
373         init_lsa_String(&r->comment, comment);
374         init_lsa_String(&r->parameters, parameters);
375         r->rid = rid;
376         r->primary_gid = primary_gid;
377         r->acct_flags = acct_flags;
378         r->fields_present = fields_present;
379         r->logon_hours = logon_hours;
380         r->bad_password_count = bad_password_count;
381         r->logon_count = logon_count;
382         r->country_code = country_code;
383         r->code_page = code_page;
384         r->nt_password_set = nt_password_set;
385         r->lm_password_set = lm_password_set;
386         r->password_expired = password_expired;
387 }