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 | void init_samr_DomInfo1(struct samr_DomInfo1 *r,
|
---|
27 | uint16_t min_password_length,
|
---|
28 | uint16_t password_history_length,
|
---|
29 | uint32_t password_properties,
|
---|
30 | int64_t max_password_age,
|
---|
31 | int64_t min_password_age)
|
---|
32 | {
|
---|
33 | r->min_password_length = min_password_length;
|
---|
34 | r->password_history_length = password_history_length;
|
---|
35 | r->password_properties = password_properties;
|
---|
36 | r->max_password_age = max_password_age;
|
---|
37 | r->min_password_age = min_password_age;
|
---|
38 | }
|
---|
39 |
|
---|
40 | /*******************************************************************
|
---|
41 | inits a structure.
|
---|
42 | ********************************************************************/
|
---|
43 |
|
---|
44 | void init_samr_DomInfo2(struct samr_DomInfo2 *r,
|
---|
45 | NTTIME force_logoff_time,
|
---|
46 | const char *comment,
|
---|
47 | const char *domain_name,
|
---|
48 | const char *primary,
|
---|
49 | uint64_t sequence_num,
|
---|
50 | uint32_t unknown2,
|
---|
51 | enum samr_Role role,
|
---|
52 | uint32_t unknown3,
|
---|
53 | uint32_t num_users,
|
---|
54 | uint32_t num_groups,
|
---|
55 | uint32_t num_aliases)
|
---|
56 | {
|
---|
57 | r->force_logoff_time = force_logoff_time;
|
---|
58 | init_lsa_String(&r->comment, comment);
|
---|
59 | init_lsa_String(&r->domain_name, domain_name);
|
---|
60 | init_lsa_String(&r->primary, primary);
|
---|
61 | r->sequence_num = sequence_num;
|
---|
62 | r->unknown2 = unknown2;
|
---|
63 | r->role = role;
|
---|
64 | r->unknown3 = unknown3;
|
---|
65 | r->num_users = num_users;
|
---|
66 | r->num_groups = num_groups;
|
---|
67 | r->num_aliases = num_aliases;
|
---|
68 | }
|
---|
69 |
|
---|
70 | /*******************************************************************
|
---|
71 | inits a structure.
|
---|
72 | ********************************************************************/
|
---|
73 |
|
---|
74 | void init_samr_DomInfo3(struct samr_DomInfo3 *r,
|
---|
75 | NTTIME force_logoff_time)
|
---|
76 | {
|
---|
77 | r->force_logoff_time = force_logoff_time;
|
---|
78 | }
|
---|
79 |
|
---|
80 | /*******************************************************************
|
---|
81 | inits a structure.
|
---|
82 | ********************************************************************/
|
---|
83 |
|
---|
84 | void init_samr_DomInfo4(struct samr_DomInfo4 *r,
|
---|
85 | const char *comment)
|
---|
86 | {
|
---|
87 | init_lsa_String(&r->comment, comment);
|
---|
88 | }
|
---|
89 |
|
---|
90 | /*******************************************************************
|
---|
91 | inits a structure.
|
---|
92 | ********************************************************************/
|
---|
93 |
|
---|
94 | void init_samr_DomInfo5(struct samr_DomInfo5 *r,
|
---|
95 | const char *domain_name)
|
---|
96 | {
|
---|
97 | init_lsa_String(&r->domain_name, domain_name);
|
---|
98 | }
|
---|
99 |
|
---|
100 | /*******************************************************************
|
---|
101 | inits a structure.
|
---|
102 | ********************************************************************/
|
---|
103 |
|
---|
104 | void init_samr_DomInfo6(struct samr_DomInfo6 *r,
|
---|
105 | const char *primary)
|
---|
106 | {
|
---|
107 | init_lsa_String(&r->primary, primary);
|
---|
108 | }
|
---|
109 |
|
---|
110 | /*******************************************************************
|
---|
111 | inits a structure.
|
---|
112 | ********************************************************************/
|
---|
113 |
|
---|
114 | void init_samr_DomInfo7(struct samr_DomInfo7 *r,
|
---|
115 | enum samr_Role role)
|
---|
116 | {
|
---|
117 | r->role = role;
|
---|
118 | }
|
---|
119 |
|
---|
120 | /*******************************************************************
|
---|
121 | inits a structure.
|
---|
122 | ********************************************************************/
|
---|
123 |
|
---|
124 | void init_samr_DomInfo8(struct samr_DomInfo8 *r,
|
---|
125 | uint64_t sequence_num,
|
---|
126 | NTTIME domain_create_time)
|
---|
127 | {
|
---|
128 | r->sequence_num = sequence_num;
|
---|
129 | r->domain_create_time = domain_create_time;
|
---|
130 | }
|
---|
131 |
|
---|
132 | /*******************************************************************
|
---|
133 | inits a structure.
|
---|
134 | ********************************************************************/
|
---|
135 |
|
---|
136 | void init_samr_DomInfo9(struct samr_DomInfo9 *r,
|
---|
137 | uint32_t unknown)
|
---|
138 | {
|
---|
139 | r->unknown = unknown;
|
---|
140 | }
|
---|
141 |
|
---|
142 | /*******************************************************************
|
---|
143 | inits a structure.
|
---|
144 | ********************************************************************/
|
---|
145 |
|
---|
146 | void init_samr_DomInfo12(struct samr_DomInfo12 *r,
|
---|
147 | uint64_t lockout_duration,
|
---|
148 | uint64_t lockout_window,
|
---|
149 | uint16_t lockout_threshold)
|
---|
150 | {
|
---|
151 | r->lockout_duration = lockout_duration;
|
---|
152 | r->lockout_window = lockout_window;
|
---|
153 | r->lockout_threshold = lockout_threshold;
|
---|
154 | }
|
---|
155 |
|
---|
156 | /*******************************************************************
|
---|
157 | inits a samr_GroupInfoAll structure.
|
---|
158 | ********************************************************************/
|
---|
159 |
|
---|
160 | void init_samr_group_info1(struct samr_GroupInfoAll *r,
|
---|
161 | const char *name,
|
---|
162 | uint32_t attributes,
|
---|
163 | uint32_t num_members,
|
---|
164 | const char *description)
|
---|
165 | {
|
---|
166 | DEBUG(5, ("init_samr_group_info1\n"));
|
---|
167 |
|
---|
168 | init_lsa_String(&r->name, name);
|
---|
169 | r->attributes = attributes;
|
---|
170 | r->num_members = num_members;
|
---|
171 | init_lsa_String(&r->description, description);
|
---|
172 | }
|
---|
173 |
|
---|
174 | /*******************************************************************
|
---|
175 | inits a lsa_String structure
|
---|
176 | ********************************************************************/
|
---|
177 |
|
---|
178 | void init_samr_group_info2(struct lsa_String *r, const char *group_name)
|
---|
179 | {
|
---|
180 | DEBUG(5, ("init_samr_group_info2\n"));
|
---|
181 |
|
---|
182 | init_lsa_String(r, group_name);
|
---|
183 | }
|
---|
184 |
|
---|
185 | /*******************************************************************
|
---|
186 | inits a samr_GroupInfoAttributes structure.
|
---|
187 | ********************************************************************/
|
---|
188 |
|
---|
189 | void init_samr_group_info3(struct samr_GroupInfoAttributes *r,
|
---|
190 | uint32_t attributes)
|
---|
191 | {
|
---|
192 | DEBUG(5, ("init_samr_group_info3\n"));
|
---|
193 |
|
---|
194 | r->attributes = attributes;
|
---|
195 | }
|
---|
196 |
|
---|
197 | /*******************************************************************
|
---|
198 | inits a lsa_String structure
|
---|
199 | ********************************************************************/
|
---|
200 |
|
---|
201 | void init_samr_group_info4(struct lsa_String *r, const char *description)
|
---|
202 | {
|
---|
203 | DEBUG(5, ("init_samr_group_info4\n"));
|
---|
204 |
|
---|
205 | init_lsa_String(r, description);
|
---|
206 | }
|
---|
207 |
|
---|
208 | /*******************************************************************
|
---|
209 | inits a samr_GroupInfoAll structure.
|
---|
210 | ********************************************************************/
|
---|
211 |
|
---|
212 | void init_samr_group_info5(struct samr_GroupInfoAll *r,
|
---|
213 | const char *name,
|
---|
214 | uint32_t attributes,
|
---|
215 | uint32_t num_members,
|
---|
216 | const char *description)
|
---|
217 | {
|
---|
218 | DEBUG(5, ("init_samr_group_info5\n"));
|
---|
219 |
|
---|
220 | init_lsa_String(&r->name, name);
|
---|
221 | r->attributes = attributes;
|
---|
222 | r->num_members = num_members;
|
---|
223 | init_lsa_String(&r->description, description);
|
---|
224 | }
|
---|
225 |
|
---|
226 | /*******************************************************************
|
---|
227 | inits a samr_AliasInfoAll structure.
|
---|
228 | ********************************************************************/
|
---|
229 |
|
---|
230 | void init_samr_alias_info1(struct samr_AliasInfoAll *r,
|
---|
231 | const char *name,
|
---|
232 | uint32_t num_members,
|
---|
233 | const char *description)
|
---|
234 | {
|
---|
235 | DEBUG(5, ("init_samr_alias_info1\n"));
|
---|
236 |
|
---|
237 | init_lsa_String(&r->name, name);
|
---|
238 | r->num_members = num_members;
|
---|
239 | init_lsa_String(&r->description, description);
|
---|
240 | }
|
---|
241 |
|
---|
242 | /*******************************************************************
|
---|
243 | inits a lsa_String structure.
|
---|
244 | ********************************************************************/
|
---|
245 |
|
---|
246 | void init_samr_alias_info3(struct lsa_String *r,
|
---|
247 | const char *description)
|
---|
248 | {
|
---|
249 | DEBUG(5, ("init_samr_alias_info3\n"));
|
---|
250 |
|
---|
251 | init_lsa_String(r, description);
|
---|
252 | }
|
---|
253 |
|
---|
254 | /*******************************************************************
|
---|
255 | inits a samr_UserInfo5 structure.
|
---|
256 | ********************************************************************/
|
---|
257 |
|
---|
258 | void init_samr_user_info5(struct samr_UserInfo5 *r,
|
---|
259 | const char *account_name,
|
---|
260 | const char *full_name,
|
---|
261 | uint32_t rid,
|
---|
262 | uint32_t primary_gid,
|
---|
263 | const char *home_directory,
|
---|
264 | const char *home_drive,
|
---|
265 | const char *logon_script,
|
---|
266 | const char *profile_path,
|
---|
267 | const char *description,
|
---|
268 | const char *workstations,
|
---|
269 | NTTIME last_logon,
|
---|
270 | NTTIME last_logoff,
|
---|
271 | struct samr_LogonHours logon_hours,
|
---|
272 | uint16_t bad_password_count,
|
---|
273 | uint16_t logon_count,
|
---|
274 | NTTIME last_password_change,
|
---|
275 | NTTIME acct_expiry,
|
---|
276 | uint32_t acct_flags)
|
---|
277 | {
|
---|
278 | DEBUG(5, ("init_samr_user_info5\n"));
|
---|
279 |
|
---|
280 | init_lsa_String(&r->account_name, account_name);
|
---|
281 | init_lsa_String(&r->full_name, full_name);
|
---|
282 | r->rid = rid;
|
---|
283 | r->primary_gid = primary_gid;
|
---|
284 | init_lsa_String(&r->home_directory, home_directory);
|
---|
285 | init_lsa_String(&r->home_drive, home_drive);
|
---|
286 | init_lsa_String(&r->logon_script, logon_script);
|
---|
287 | init_lsa_String(&r->profile_path, profile_path);
|
---|
288 | init_lsa_String(&r->description, description);
|
---|
289 | init_lsa_String(&r->workstations, workstations);
|
---|
290 | r->last_logon = last_logon;
|
---|
291 | r->last_logoff = last_logoff;
|
---|
292 | r->logon_hours = logon_hours;
|
---|
293 | r->bad_password_count = bad_password_count;
|
---|
294 | r->logon_count = logon_count;
|
---|
295 | r->last_password_change = last_password_change;
|
---|
296 | r->acct_expiry = acct_expiry;
|
---|
297 | r->acct_flags = acct_flags;
|
---|
298 | }
|
---|
299 |
|
---|
300 |
|
---|
301 | /*******************************************************************
|
---|
302 | inits a samr_UserInfo7 structure.
|
---|
303 | ********************************************************************/
|
---|
304 |
|
---|
305 | void init_samr_user_info7(struct samr_UserInfo7 *r,
|
---|
306 | const char *account_name)
|
---|
307 | {
|
---|
308 | DEBUG(5, ("init_samr_user_info7\n"));
|
---|
309 |
|
---|
310 | init_lsa_String(&r->account_name, account_name);
|
---|
311 | }
|
---|
312 |
|
---|
313 | /*******************************************************************
|
---|
314 | inits a samr_UserInfo9 structure.
|
---|
315 | ********************************************************************/
|
---|
316 |
|
---|
317 | void init_samr_user_info9(struct samr_UserInfo9 *r,
|
---|
318 | uint32_t primary_gid)
|
---|
319 | {
|
---|
320 | DEBUG(5, ("init_samr_user_info9\n"));
|
---|
321 |
|
---|
322 | r->primary_gid = primary_gid;
|
---|
323 | }
|
---|
324 |
|
---|
325 | /*******************************************************************
|
---|
326 | inits a SAM_USER_INFO_16 structure.
|
---|
327 | ********************************************************************/
|
---|
328 |
|
---|
329 | void init_samr_user_info16(struct samr_UserInfo16 *r,
|
---|
330 | uint32_t acct_flags)
|
---|
331 | {
|
---|
332 | DEBUG(5, ("init_samr_user_info16\n"));
|
---|
333 |
|
---|
334 | r->acct_flags = acct_flags;
|
---|
335 | }
|
---|
336 |
|
---|
337 | /*******************************************************************
|
---|
338 | inits a samr_UserInfo18 structure.
|
---|
339 | ********************************************************************/
|
---|
340 |
|
---|
341 | void init_samr_user_info18(struct samr_UserInfo18 *r,
|
---|
342 | const uint8 lm_pwd[16],
|
---|
343 | const uint8 nt_pwd[16],
|
---|
344 | uint8_t password_expired)
|
---|
345 | {
|
---|
346 | DEBUG(5, ("init_samr_user_info18\n"));
|
---|
347 |
|
---|
348 | r->lm_pwd_active =
|
---|
349 | memcpy(r->lm_pwd.hash, lm_pwd, sizeof(r->lm_pwd.hash)) ? true : false;
|
---|
350 | r->nt_pwd_active =
|
---|
351 | memcpy(r->nt_pwd.hash, nt_pwd, sizeof(r->nt_pwd.hash)) ? true : false;
|
---|
352 | r->password_expired = password_expired;
|
---|
353 | }
|
---|
354 |
|
---|
355 | /*******************************************************************
|
---|
356 | inits a samr_UserInfo20 structure.
|
---|
357 | ********************************************************************/
|
---|
358 |
|
---|
359 | void init_samr_user_info20(struct samr_UserInfo20 *r,
|
---|
360 | struct lsa_BinaryString *parameters)
|
---|
361 | {
|
---|
362 | r->parameters = *parameters;
|
---|
363 | }
|
---|
364 |
|
---|
365 | /*************************************************************************
|
---|
366 | inits a samr_UserInfo21 structure
|
---|
367 | *************************************************************************/
|
---|
368 |
|
---|
369 | void init_samr_user_info21(struct samr_UserInfo21 *r,
|
---|
370 | NTTIME last_logon,
|
---|
371 | NTTIME last_logoff,
|
---|
372 | NTTIME last_password_change,
|
---|
373 | NTTIME acct_expiry,
|
---|
374 | NTTIME allow_password_change,
|
---|
375 | NTTIME force_password_change,
|
---|
376 | const char *account_name,
|
---|
377 | const char *full_name,
|
---|
378 | const char *home_directory,
|
---|
379 | const char *home_drive,
|
---|
380 | const char *logon_script,
|
---|
381 | const char *profile_path,
|
---|
382 | const char *description,
|
---|
383 | const char *workstations,
|
---|
384 | const char *comment,
|
---|
385 | struct lsa_BinaryString *parameters,
|
---|
386 | uint32_t rid,
|
---|
387 | uint32_t primary_gid,
|
---|
388 | uint32_t acct_flags,
|
---|
389 | uint32_t fields_present,
|
---|
390 | struct samr_LogonHours logon_hours,
|
---|
391 | uint16_t bad_password_count,
|
---|
392 | uint16_t logon_count,
|
---|
393 | uint16_t country_code,
|
---|
394 | uint16_t code_page,
|
---|
395 | uint8_t lm_password_set,
|
---|
396 | uint8_t nt_password_set,
|
---|
397 | uint8_t password_expired)
|
---|
398 | {
|
---|
399 | r->last_logon = last_logon;
|
---|
400 | r->last_logoff = last_logoff;
|
---|
401 | r->last_password_change = last_password_change;
|
---|
402 | r->acct_expiry = acct_expiry;
|
---|
403 | r->allow_password_change = allow_password_change;
|
---|
404 | r->force_password_change = force_password_change;
|
---|
405 | init_lsa_String(&r->account_name, account_name);
|
---|
406 | init_lsa_String(&r->full_name, full_name);
|
---|
407 | init_lsa_String(&r->home_directory, home_directory);
|
---|
408 | init_lsa_String(&r->home_drive, home_drive);
|
---|
409 | init_lsa_String(&r->logon_script, logon_script);
|
---|
410 | init_lsa_String(&r->profile_path, profile_path);
|
---|
411 | init_lsa_String(&r->description, description);
|
---|
412 | init_lsa_String(&r->workstations, workstations);
|
---|
413 | init_lsa_String(&r->comment, comment);
|
---|
414 | r->parameters = *parameters;
|
---|
415 | r->rid = rid;
|
---|
416 | r->primary_gid = primary_gid;
|
---|
417 | r->acct_flags = acct_flags;
|
---|
418 | r->fields_present = fields_present;
|
---|
419 | r->logon_hours = logon_hours;
|
---|
420 | r->bad_password_count = bad_password_count;
|
---|
421 | r->logon_count = logon_count;
|
---|
422 | r->country_code = country_code;
|
---|
423 | r->code_page = code_page;
|
---|
424 | r->lm_password_set = lm_password_set;
|
---|
425 | r->nt_password_set = nt_password_set;
|
---|
426 | r->password_expired = password_expired;
|
---|
427 | }
|
---|
428 |
|
---|
429 | /*************************************************************************
|
---|
430 | init_samr_user_info23
|
---|
431 | *************************************************************************/
|
---|
432 |
|
---|
433 | void init_samr_user_info23(struct samr_UserInfo23 *r,
|
---|
434 | NTTIME last_logon,
|
---|
435 | NTTIME last_logoff,
|
---|
436 | NTTIME last_password_change,
|
---|
437 | NTTIME acct_expiry,
|
---|
438 | NTTIME allow_password_change,
|
---|
439 | NTTIME force_password_change,
|
---|
440 | const char *account_name,
|
---|
441 | const char *full_name,
|
---|
442 | const char *home_directory,
|
---|
443 | const char *home_drive,
|
---|
444 | const char *logon_script,
|
---|
445 | const char *profile_path,
|
---|
446 | const char *description,
|
---|
447 | const char *workstations,
|
---|
448 | const char *comment,
|
---|
449 | struct lsa_BinaryString *parameters,
|
---|
450 | uint32_t rid,
|
---|
451 | uint32_t primary_gid,
|
---|
452 | uint32_t acct_flags,
|
---|
453 | uint32_t fields_present,
|
---|
454 | struct samr_LogonHours logon_hours,
|
---|
455 | uint16_t bad_password_count,
|
---|
456 | uint16_t logon_count,
|
---|
457 | uint16_t country_code,
|
---|
458 | uint16_t code_page,
|
---|
459 | uint8_t lm_password_set,
|
---|
460 | uint8_t nt_password_set,
|
---|
461 | uint8_t password_expired,
|
---|
462 | struct samr_CryptPassword *pwd_buf)
|
---|
463 | {
|
---|
464 | memset(r, '\0', sizeof(*r));
|
---|
465 | init_samr_user_info21(&r->info,
|
---|
466 | last_logon,
|
---|
467 | last_logoff,
|
---|
468 | last_password_change,
|
---|
469 | acct_expiry,
|
---|
470 | allow_password_change,
|
---|
471 | force_password_change,
|
---|
472 | account_name,
|
---|
473 | full_name,
|
---|
474 | home_directory,
|
---|
475 | home_drive,
|
---|
476 | logon_script,
|
---|
477 | profile_path,
|
---|
478 | description,
|
---|
479 | workstations,
|
---|
480 | comment,
|
---|
481 | parameters,
|
---|
482 | rid,
|
---|
483 | primary_gid,
|
---|
484 | acct_flags,
|
---|
485 | fields_present,
|
---|
486 | logon_hours,
|
---|
487 | bad_password_count,
|
---|
488 | logon_count,
|
---|
489 | country_code,
|
---|
490 | code_page,
|
---|
491 | lm_password_set,
|
---|
492 | nt_password_set,
|
---|
493 | password_expired);
|
---|
494 |
|
---|
495 | r->password = *pwd_buf;
|
---|
496 | }
|
---|
497 |
|
---|
498 | /*************************************************************************
|
---|
499 | init_samr_user_info24
|
---|
500 | *************************************************************************/
|
---|
501 |
|
---|
502 | void init_samr_user_info24(struct samr_UserInfo24 *r,
|
---|
503 | struct samr_CryptPassword *pwd_buf,
|
---|
504 | uint8_t password_expired)
|
---|
505 | {
|
---|
506 | DEBUG(10, ("init_samr_user_info24:\n"));
|
---|
507 |
|
---|
508 | r->password = *pwd_buf;
|
---|
509 | r->password_expired = password_expired;
|
---|
510 | }
|
---|
511 |
|
---|
512 | /*************************************************************************
|
---|
513 | init_samr_user_info25
|
---|
514 | *************************************************************************/
|
---|
515 |
|
---|
516 | void init_samr_user_info25(struct samr_UserInfo25 *r,
|
---|
517 | NTTIME last_logon,
|
---|
518 | NTTIME last_logoff,
|
---|
519 | NTTIME last_password_change,
|
---|
520 | NTTIME acct_expiry,
|
---|
521 | NTTIME allow_password_change,
|
---|
522 | NTTIME force_password_change,
|
---|
523 | const char *account_name,
|
---|
524 | const char *full_name,
|
---|
525 | const char *home_directory,
|
---|
526 | const char *home_drive,
|
---|
527 | const char *logon_script,
|
---|
528 | const char *profile_path,
|
---|
529 | const char *description,
|
---|
530 | const char *workstations,
|
---|
531 | const char *comment,
|
---|
532 | struct lsa_BinaryString *parameters,
|
---|
533 | uint32_t rid,
|
---|
534 | uint32_t primary_gid,
|
---|
535 | uint32_t acct_flags,
|
---|
536 | uint32_t fields_present,
|
---|
537 | struct samr_LogonHours logon_hours,
|
---|
538 | uint16_t bad_password_count,
|
---|
539 | uint16_t logon_count,
|
---|
540 | uint16_t country_code,
|
---|
541 | uint16_t code_page,
|
---|
542 | uint8_t lm_password_set,
|
---|
543 | uint8_t nt_password_set,
|
---|
544 | uint8_t password_expired,
|
---|
545 | struct samr_CryptPasswordEx *pwd_buf)
|
---|
546 | {
|
---|
547 | DEBUG(10, ("init_samr_user_info25:\n"));
|
---|
548 |
|
---|
549 | memset(r, '\0', sizeof(*r));
|
---|
550 | init_samr_user_info21(&r->info,
|
---|
551 | last_logon,
|
---|
552 | last_logoff,
|
---|
553 | last_password_change,
|
---|
554 | acct_expiry,
|
---|
555 | allow_password_change,
|
---|
556 | force_password_change,
|
---|
557 | account_name,
|
---|
558 | full_name,
|
---|
559 | home_directory,
|
---|
560 | home_drive,
|
---|
561 | logon_script,
|
---|
562 | profile_path,
|
---|
563 | description,
|
---|
564 | workstations,
|
---|
565 | comment,
|
---|
566 | parameters,
|
---|
567 | rid,
|
---|
568 | primary_gid,
|
---|
569 | acct_flags,
|
---|
570 | fields_present,
|
---|
571 | logon_hours,
|
---|
572 | bad_password_count,
|
---|
573 | logon_count,
|
---|
574 | country_code,
|
---|
575 | code_page,
|
---|
576 | lm_password_set,
|
---|
577 | nt_password_set,
|
---|
578 | password_expired);
|
---|
579 |
|
---|
580 | r->password = *pwd_buf;
|
---|
581 | }
|
---|
582 |
|
---|
583 | /*************************************************************************
|
---|
584 | init_samr_user_info26
|
---|
585 | *************************************************************************/
|
---|
586 |
|
---|
587 | void init_samr_user_info26(struct samr_UserInfo26 *r,
|
---|
588 | struct samr_CryptPasswordEx *pwd_buf,
|
---|
589 | uint8_t password_expired)
|
---|
590 | {
|
---|
591 | DEBUG(10, ("init_samr_user_info26:\n"));
|
---|
592 |
|
---|
593 | r->password = *pwd_buf;
|
---|
594 | r->password_expired = password_expired;
|
---|
595 | }
|
---|
596 |
|
---|
597 | /*************************************************************************
|
---|
598 | inits a samr_CryptPasswordEx structure
|
---|
599 | *************************************************************************/
|
---|
600 |
|
---|
601 | void init_samr_CryptPasswordEx(const char *pwd,
|
---|
602 | DATA_BLOB *session_key,
|
---|
603 | struct samr_CryptPasswordEx *pwd_buf)
|
---|
604 | {
|
---|
605 | /* samr_CryptPasswordEx */
|
---|
606 |
|
---|
607 | uchar pwbuf[532];
|
---|
608 | struct MD5Context md5_ctx;
|
---|
609 | uint8_t confounder[16];
|
---|
610 | DATA_BLOB confounded_session_key = data_blob(NULL, 16);
|
---|
611 |
|
---|
612 | encode_pw_buffer(pwbuf, pwd, STR_UNICODE);
|
---|
613 |
|
---|
614 | generate_random_buffer((uint8_t *)confounder, 16);
|
---|
615 |
|
---|
616 | MD5Init(&md5_ctx);
|
---|
617 | MD5Update(&md5_ctx, confounder, 16);
|
---|
618 | MD5Update(&md5_ctx, session_key->data,
|
---|
619 | session_key->length);
|
---|
620 | MD5Final(confounded_session_key.data, &md5_ctx);
|
---|
621 |
|
---|
622 | SamOEMhashBlob(pwbuf, 516, &confounded_session_key);
|
---|
623 | memcpy(&pwbuf[516], confounder, 16);
|
---|
624 |
|
---|
625 | memcpy(pwd_buf->data, pwbuf, sizeof(pwbuf));
|
---|
626 | data_blob_free(&confounded_session_key);
|
---|
627 | }
|
---|
628 |
|
---|
629 | /*************************************************************************
|
---|
630 | inits a samr_CryptPassword structure
|
---|
631 | *************************************************************************/
|
---|
632 |
|
---|
633 | void init_samr_CryptPassword(const char *pwd,
|
---|
634 | DATA_BLOB *session_key,
|
---|
635 | struct samr_CryptPassword *pwd_buf)
|
---|
636 | {
|
---|
637 | /* samr_CryptPassword */
|
---|
638 |
|
---|
639 | encode_pw_buffer(pwd_buf->data, pwd, STR_UNICODE);
|
---|
640 | SamOEMhashBlob(pwd_buf->data, 516, session_key);
|
---|
641 | }
|
---|