s3:printing: Allow to run samba-bgqd as a standalone systemd service
[Samba.git] / source3 / rpc_server / samr / srv_samr_util.c
blobfa35ce6a5de708895944273d845a855ac0df0022
1 /*
2 Unix SMB/CIFS implementation.
3 SAMR Pipe utility functions.
5 Copyright (C) Luke Kenneth Casson Leighton 1996-1998
6 Copyright (C) Gerald (Jerry) Carter 2000-2001
7 Copyright (C) Andrew Bartlett 2001-2002
8 Copyright (C) Stefan (metze) Metzmacher 2002
9 Copyright (C) Guenther Deschner 2008
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "includes.h"
26 #include "../librpc/gen_ndr/samr.h"
27 #include "rpc_server/samr/srv_samr_util.h"
28 #include "passdb.h"
29 #include "lib/util/base64.h"
31 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_RPC_SRV
34 #define STRING_CHANGED (old_string && !new_string) ||\
35 (!old_string && new_string) ||\
36 (old_string && new_string && (strcmp(old_string, new_string) != 0))
38 #define STRING_CHANGED_NC(s1,s2) ((s1) && !(s2)) ||\
39 (!(s1) && (s2)) ||\
40 ((s1) && (s2) && (strcmp((s1), (s2)) != 0))
42 /*************************************************************
43 Copies a struct samr_UserInfo2 to a struct samu
44 **************************************************************/
46 void copy_id2_to_sam_passwd(struct samu *to,
47 struct samr_UserInfo2 *from)
49 struct samr_UserInfo21 i;
51 if (from == NULL || to == NULL) {
52 return;
55 ZERO_STRUCT(i);
57 i.fields_present = SAMR_FIELD_COMMENT |
58 SAMR_FIELD_COUNTRY_CODE |
59 SAMR_FIELD_CODE_PAGE;
60 i.comment = from->comment;
61 i.country_code = from->country_code;
62 i.code_page = from->code_page;
64 copy_id21_to_sam_passwd("INFO_2", to, &i);
67 /*************************************************************
68 Copies a struct samr_UserInfo4 to a struct samu
69 **************************************************************/
71 void copy_id4_to_sam_passwd(struct samu *to,
72 struct samr_UserInfo4 *from)
74 struct samr_UserInfo21 i;
76 if (from == NULL || to == NULL) {
77 return;
80 ZERO_STRUCT(i);
82 i.fields_present = SAMR_FIELD_LOGON_HOURS;
83 i.logon_hours = from->logon_hours;
85 copy_id21_to_sam_passwd("INFO_4", to, &i);
88 /*************************************************************
89 Copies a struct samr_UserInfo6 to a struct samu
90 **************************************************************/
92 void copy_id6_to_sam_passwd(struct samu *to,
93 struct samr_UserInfo6 *from)
95 struct samr_UserInfo21 i;
97 if (from == NULL || to == NULL) {
98 return;
101 ZERO_STRUCT(i);
103 i.fields_present = SAMR_FIELD_ACCOUNT_NAME |
104 SAMR_FIELD_FULL_NAME;
105 i.account_name = from->account_name;
106 i.full_name = from->full_name;
108 copy_id21_to_sam_passwd("INFO_6", to, &i);
111 /*************************************************************
112 Copies a struct samr_UserInfo8 to a struct samu
113 **************************************************************/
115 void copy_id8_to_sam_passwd(struct samu *to,
116 struct samr_UserInfo8 *from)
118 struct samr_UserInfo21 i;
120 if (from == NULL || to == NULL) {
121 return;
124 ZERO_STRUCT(i);
126 i.fields_present = SAMR_FIELD_FULL_NAME;
127 i.full_name = from->full_name;
129 copy_id21_to_sam_passwd("INFO_8", to, &i);
132 /*************************************************************
133 Copies a struct samr_UserInfo10 to a struct samu
134 **************************************************************/
136 void copy_id10_to_sam_passwd(struct samu *to,
137 struct samr_UserInfo10 *from)
139 struct samr_UserInfo21 i;
141 if (from == NULL || to == NULL) {
142 return;
145 ZERO_STRUCT(i);
147 i.fields_present = SAMR_FIELD_HOME_DIRECTORY |
148 SAMR_FIELD_HOME_DRIVE;
149 i.home_directory = from->home_directory;
150 i.home_drive = from->home_drive;
152 copy_id21_to_sam_passwd("INFO_10", to, &i);
155 /*************************************************************
156 Copies a struct samr_UserInfo11 to a struct samu
157 **************************************************************/
159 void copy_id11_to_sam_passwd(struct samu *to,
160 struct samr_UserInfo11 *from)
162 struct samr_UserInfo21 i;
164 if (from == NULL || to == NULL) {
165 return;
168 ZERO_STRUCT(i);
170 i.fields_present = SAMR_FIELD_LOGON_SCRIPT;
171 i.logon_script = from->logon_script;
173 copy_id21_to_sam_passwd("INFO_11", to, &i);
176 /*************************************************************
177 Copies a struct samr_UserInfo12 to a struct samu
178 **************************************************************/
180 void copy_id12_to_sam_passwd(struct samu *to,
181 struct samr_UserInfo12 *from)
183 struct samr_UserInfo21 i;
185 if (from == NULL || to == NULL) {
186 return;
189 ZERO_STRUCT(i);
191 i.fields_present = SAMR_FIELD_PROFILE_PATH;
192 i.profile_path = from->profile_path;
194 copy_id21_to_sam_passwd("INFO_12", to, &i);
197 /*************************************************************
198 Copies a struct samr_UserInfo13 to a struct samu
199 **************************************************************/
201 void copy_id13_to_sam_passwd(struct samu *to,
202 struct samr_UserInfo13 *from)
204 struct samr_UserInfo21 i;
206 if (from == NULL || to == NULL) {
207 return;
210 ZERO_STRUCT(i);
212 i.fields_present = SAMR_FIELD_DESCRIPTION;
213 i.description = from->description;
215 copy_id21_to_sam_passwd("INFO_13", to, &i);
218 /*************************************************************
219 Copies a struct samr_UserInfo14 to a struct samu
220 **************************************************************/
222 void copy_id14_to_sam_passwd(struct samu *to,
223 struct samr_UserInfo14 *from)
225 struct samr_UserInfo21 i;
227 if (from == NULL || to == NULL) {
228 return;
231 ZERO_STRUCT(i);
233 i.fields_present = SAMR_FIELD_WORKSTATIONS;
234 i.workstations = from->workstations;
236 copy_id21_to_sam_passwd("INFO_14", to, &i);
239 /*************************************************************
240 Copies a struct samr_UserInfo16 to a struct samu
241 **************************************************************/
243 void copy_id16_to_sam_passwd(struct samu *to,
244 struct samr_UserInfo16 *from)
246 struct samr_UserInfo21 i;
248 if (from == NULL || to == NULL) {
249 return;
252 ZERO_STRUCT(i);
254 i.fields_present = SAMR_FIELD_ACCT_FLAGS;
255 i.acct_flags = from->acct_flags;
257 copy_id21_to_sam_passwd("INFO_16", to, &i);
260 /*************************************************************
261 Copies a struct samr_UserInfo17 to a struct samu
262 **************************************************************/
264 void copy_id17_to_sam_passwd(struct samu *to,
265 struct samr_UserInfo17 *from)
267 struct samr_UserInfo21 i;
269 if (from == NULL || to == NULL) {
270 return;
273 ZERO_STRUCT(i);
275 i.fields_present = SAMR_FIELD_ACCT_EXPIRY;
276 i.acct_expiry = from->acct_expiry;
278 copy_id21_to_sam_passwd("INFO_17", to, &i);
281 /*************************************************************
282 Copies a struct samr_UserInfo18 to a struct samu
283 **************************************************************/
285 void copy_id18_to_sam_passwd(struct samu *to,
286 struct samr_UserInfo18 *from)
288 struct samr_UserInfo21 i;
290 if (from == NULL || to == NULL) {
291 return;
294 ZERO_STRUCT(i);
296 i.fields_present = SAMR_FIELD_EXPIRED_FLAG;
297 i.password_expired = from->password_expired;
299 copy_id21_to_sam_passwd("INFO_18", to, &i);
302 /*************************************************************
303 Copies a struct samr_UserInfo20 to a struct samu
304 **************************************************************/
306 void copy_id20_to_sam_passwd(struct samu *to,
307 struct samr_UserInfo20 *from)
309 DATA_BLOB mung;
311 if (from == NULL || to == NULL) {
312 return;
315 if (from->parameters.array) {
316 const char *old_string;
317 char *new_string = NULL;
318 old_string = pdb_get_munged_dial(to);
319 mung = data_blob_const(from->parameters.array,
320 from->parameters.length);
322 if (mung.length != 0) {
323 new_string = base64_encode_data_blob(talloc_tos(),
324 mung);
325 SMB_ASSERT(new_string != NULL);
328 DEBUG(10,("INFO_20 PARAMETERS: %s -> %s\n",
329 old_string, new_string));
330 if (STRING_CHANGED_NC(old_string,new_string)) {
331 pdb_set_munged_dial(to, new_string, PDB_CHANGED);
334 TALLOC_FREE(new_string);
338 /*************************************************************
339 Copies a struct samr_UserInfo21 to a struct samu
340 **************************************************************/
342 void copy_id21_to_sam_passwd(const char *log_prefix,
343 struct samu *to,
344 struct samr_UserInfo21 *from)
346 time_t unix_time, stored_time;
347 const char *old_string, *new_string;
348 const char *l;
350 if (from == NULL || to == NULL) {
351 return;
354 if (log_prefix) {
355 l = log_prefix;
356 } else {
357 l = "INFO_21";
360 if (from->fields_present & SAMR_FIELD_LAST_LOGON) {
361 unix_time = nt_time_to_unix(from->last_logon);
362 stored_time = pdb_get_logon_time(to);
363 DEBUG(10,("%s SAMR_FIELD_LAST_LOGON: %lu -> %lu\n", l,
364 (long unsigned int)stored_time,
365 (long unsigned int)unix_time));
366 if (stored_time != unix_time) {
367 pdb_set_logon_time(to, unix_time, PDB_CHANGED);
371 if (from->fields_present & SAMR_FIELD_LAST_LOGOFF) {
372 unix_time = nt_time_to_unix(from->last_logoff);
373 stored_time = pdb_get_logoff_time(to);
374 DEBUG(10,("%s SAMR_FIELD_LAST_LOGOFF: %lu -> %lu\n", l,
375 (long unsigned int)stored_time,
376 (long unsigned int)unix_time));
377 if (stored_time != unix_time) {
378 pdb_set_logoff_time(to, unix_time, PDB_CHANGED);
382 if (from->fields_present & SAMR_FIELD_ACCT_EXPIRY) {
383 unix_time = nt_time_to_unix(from->acct_expiry);
384 stored_time = pdb_get_kickoff_time(to);
385 DEBUG(10,("%s SAMR_FIELD_ACCT_EXPIRY: %lu -> %lu\n", l,
386 (long unsigned int)stored_time,
387 (long unsigned int)unix_time));
388 if (stored_time != unix_time) {
389 pdb_set_kickoff_time(to, unix_time , PDB_CHANGED);
393 if (from->fields_present & SAMR_FIELD_LAST_PWD_CHANGE) {
394 unix_time = nt_time_to_unix(from->last_password_change);
395 stored_time = pdb_get_pass_last_set_time(to);
396 DEBUG(10,("%s SAMR_FIELD_LAST_PWD_CHANGE: %lu -> %lu\n", l,
397 (long unsigned int)stored_time,
398 (long unsigned int)unix_time));
399 if (stored_time != unix_time) {
400 pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED);
404 if ((from->fields_present & SAMR_FIELD_ACCOUNT_NAME) &&
405 (from->account_name.string)) {
406 old_string = pdb_get_username(to);
407 new_string = from->account_name.string;
408 DEBUG(10,("%s SAMR_FIELD_ACCOUNT_NAME: %s -> %s\n", l,
409 old_string, new_string));
410 if (STRING_CHANGED) {
411 pdb_set_username(to, new_string, PDB_CHANGED);
415 if ((from->fields_present & SAMR_FIELD_FULL_NAME) &&
416 (from->full_name.string)) {
417 old_string = pdb_get_fullname(to);
418 new_string = from->full_name.string;
419 DEBUG(10,("%s SAMR_FIELD_FULL_NAME: %s -> %s\n", l,
420 old_string, new_string));
421 if (STRING_CHANGED) {
422 pdb_set_fullname(to, new_string, PDB_CHANGED);
426 if ((from->fields_present & SAMR_FIELD_HOME_DIRECTORY) &&
427 (from->home_directory.string)) {
428 old_string = pdb_get_homedir(to);
429 new_string = from->home_directory.string;
430 DEBUG(10,("%s SAMR_FIELD_HOME_DIRECTORY: %s -> %s\n", l,
431 old_string, new_string));
432 if (STRING_CHANGED) {
433 pdb_set_homedir(to, new_string, PDB_CHANGED);
437 if ((from->fields_present & SAMR_FIELD_HOME_DRIVE) &&
438 (from->home_drive.string)) {
439 old_string = pdb_get_dir_drive(to);
440 new_string = from->home_drive.string;
441 DEBUG(10,("%s SAMR_FIELD_HOME_DRIVE: %s -> %s\n", l,
442 old_string, new_string));
443 if (STRING_CHANGED) {
444 pdb_set_dir_drive(to, new_string, PDB_CHANGED);
448 if ((from->fields_present & SAMR_FIELD_LOGON_SCRIPT) &&
449 (from->logon_script.string)) {
450 old_string = pdb_get_logon_script(to);
451 new_string = from->logon_script.string;
452 DEBUG(10,("%s SAMR_FIELD_LOGON_SCRIPT: %s -> %s\n", l,
453 old_string, new_string));
454 if (STRING_CHANGED) {
455 pdb_set_logon_script(to , new_string, PDB_CHANGED);
459 if ((from->fields_present & SAMR_FIELD_PROFILE_PATH) &&
460 (from->profile_path.string)) {
461 old_string = pdb_get_profile_path(to);
462 new_string = from->profile_path.string;
463 DEBUG(10,("%s SAMR_FIELD_PROFILE_PATH: %s -> %s\n", l,
464 old_string, new_string));
465 if (STRING_CHANGED) {
466 pdb_set_profile_path(to , new_string, PDB_CHANGED);
470 if ((from->fields_present & SAMR_FIELD_DESCRIPTION) &&
471 (from->description.string)) {
472 old_string = pdb_get_acct_desc(to);
473 new_string = from->description.string;
474 DEBUG(10,("%s SAMR_FIELD_DESCRIPTION: %s -> %s\n", l,
475 old_string, new_string));
476 if (STRING_CHANGED) {
477 pdb_set_acct_desc(to, new_string, PDB_CHANGED);
481 if ((from->fields_present & SAMR_FIELD_WORKSTATIONS) &&
482 (from->workstations.string)) {
483 old_string = pdb_get_workstations(to);
484 new_string = from->workstations.string;
485 DEBUG(10,("%s SAMR_FIELD_WORKSTATIONS: %s -> %s\n", l,
486 old_string, new_string));
487 if (STRING_CHANGED) {
488 pdb_set_workstations(to , new_string, PDB_CHANGED);
492 if ((from->fields_present & SAMR_FIELD_COMMENT) &&
493 (from->comment.string)) {
494 old_string = pdb_get_comment(to);
495 new_string = from->comment.string;
496 DEBUG(10,("%s SAMR_FIELD_COMMENT: %s -> %s\n", l,
497 old_string, new_string));
498 if (STRING_CHANGED) {
499 pdb_set_comment(to, new_string, PDB_CHANGED);
503 if ((from->fields_present & SAMR_FIELD_PARAMETERS) &&
504 (from->parameters.array)) {
505 char *newstr = NULL;
506 DATA_BLOB mung;
507 old_string = pdb_get_munged_dial(to);
509 mung = data_blob_const(from->parameters.array,
510 from->parameters.length);
512 if (mung.length != 0) {
513 newstr = base64_encode_data_blob(talloc_tos(), mung);
514 SMB_ASSERT(newstr != NULL);
516 DEBUG(10,("%s SAMR_FIELD_PARAMETERS: %s -> %s\n", l,
517 old_string, newstr));
518 if (STRING_CHANGED_NC(old_string,newstr)) {
519 pdb_set_munged_dial(to, newstr, PDB_CHANGED);
522 TALLOC_FREE(newstr);
525 if (from->fields_present & SAMR_FIELD_RID) {
526 if (from->rid == 0) {
527 DEBUG(10,("%s: Asked to set User RID to 0 !? Skipping change!\n", l));
528 } else if (from->rid != pdb_get_user_rid(to)) {
529 DEBUG(10,("%s SAMR_FIELD_RID: %u -> %u NOT UPDATED!\n", l,
530 pdb_get_user_rid(to), from->rid));
534 if (from->fields_present & SAMR_FIELD_PRIMARY_GID) {
535 if (from->primary_gid == 0) {
536 DEBUG(10,("%s: Asked to set Group RID to 0 !? Skipping change!\n", l));
537 } else if (from->primary_gid != pdb_get_group_rid(to)) {
538 DEBUG(10,("%s SAMR_FIELD_PRIMARY_GID: %u -> %u\n", l,
539 pdb_get_group_rid(to), from->primary_gid));
540 pdb_set_group_sid_from_rid(to,
541 from->primary_gid, PDB_CHANGED);
545 if (from->fields_present & SAMR_FIELD_ACCT_FLAGS) {
546 DEBUG(10,("%s SAMR_FIELD_ACCT_FLAGS: %08X -> %08X\n", l,
547 pdb_get_acct_ctrl(to), from->acct_flags));
548 if (from->acct_flags != pdb_get_acct_ctrl(to)) {
550 /* You cannot autolock an unlocked account via
551 * setuserinfo calls, so make sure to remove the
552 * ACB_AUTOLOCK bit here - gd */
554 if ((from->acct_flags & ACB_AUTOLOCK) &&
555 !(pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) {
556 from->acct_flags &= ~ACB_AUTOLOCK;
559 if (!(from->acct_flags & ACB_AUTOLOCK) &&
560 (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) {
561 /* We're unlocking a previously locked user. Reset bad password counts.
562 Patch from Jianliang Lu. <Jianliang.Lu@getronics.com> */
563 pdb_set_bad_password_count(to, 0, PDB_CHANGED);
564 pdb_set_bad_password_time(to, 0, PDB_CHANGED);
566 pdb_set_acct_ctrl(to, from->acct_flags, PDB_CHANGED);
570 if (from->fields_present & SAMR_FIELD_LOGON_HOURS) {
571 char oldstr[44]; /* hours strings are 42 bytes. */
572 char newstr[44];
573 DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (units_per_week): %08X -> %08X\n", l,
574 pdb_get_logon_divs(to), from->logon_hours.units_per_week));
575 if (from->logon_hours.units_per_week != pdb_get_logon_divs(to)) {
576 pdb_set_logon_divs(to,
577 from->logon_hours.units_per_week, PDB_CHANGED);
580 DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (units_per_week/8): %08X -> %08X\n", l,
581 pdb_get_hours_len(to),
582 from->logon_hours.units_per_week/8));
583 if (from->logon_hours.units_per_week/8 != pdb_get_hours_len(to)) {
584 pdb_set_hours_len(to,
585 from->logon_hours.units_per_week/8, PDB_CHANGED);
588 DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (bits): %s -> %s\n", l,
589 pdb_get_hours(to), from->logon_hours.bits));
590 pdb_sethexhours(oldstr, pdb_get_hours(to));
591 pdb_sethexhours(newstr, from->logon_hours.bits);
592 if (!strequal(oldstr, newstr)) {
593 pdb_set_hours(to, from->logon_hours.bits,
594 from->logon_hours.units_per_week/8,
595 PDB_CHANGED);
599 if (from->fields_present & SAMR_FIELD_BAD_PWD_COUNT) {
600 DEBUG(10,("%s SAMR_FIELD_BAD_PWD_COUNT: %08X -> %08X\n", l,
601 pdb_get_bad_password_count(to), from->bad_password_count));
602 if (from->bad_password_count != pdb_get_bad_password_count(to)) {
603 pdb_set_bad_password_count(to,
604 from->bad_password_count, PDB_CHANGED);
608 if (from->fields_present & SAMR_FIELD_NUM_LOGONS) {
609 DEBUG(10,("%s SAMR_FIELD_NUM_LOGONS: %08X -> %08X\n", l,
610 pdb_get_logon_count(to), from->logon_count));
611 if (from->logon_count != pdb_get_logon_count(to)) {
612 pdb_set_logon_count(to, from->logon_count, PDB_CHANGED);
616 /* If the must change flag is set, the last set time goes to zero.
617 the must change and can change fields also do, but they are
618 calculated from policy, not set from the wire */
620 if (from->fields_present & SAMR_FIELD_EXPIRED_FLAG) {
621 DEBUG(10,("%s SAMR_FIELD_EXPIRED_FLAG: %02X\n", l,
622 from->password_expired));
623 if (from->password_expired != 0) {
624 /* Only allow the set_time to zero (which means
625 "User Must Change Password on Next Login"
626 if the user object allows password change. */
627 if (pdb_get_pass_can_change(to)) {
628 pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
629 } else {
630 DEBUG(10,("%s Disallowing set of 'User Must "
631 "Change Password on Next Login' as "
632 "user object disallows this.\n", l));
634 } else {
635 /* A subtlety here: some windows commands will
636 clear the expired flag even though it's not
637 set, and we don't want to reset the time
638 in these caess. "net user /dom <user> /active:y"
639 for example, to clear an autolocked acct.
640 We must check to see if it's expired first. jmcd */
642 uint32_t pwd_max_age = 0;
643 time_t now = time(NULL);
645 pdb_get_account_policy(PDB_POLICY_MAX_PASSWORD_AGE, &pwd_max_age);
647 if (pwd_max_age == (uint32_t)-1 || pwd_max_age == 0) {
648 pwd_max_age = get_time_t_max();
651 stored_time = pdb_get_pass_last_set_time(to);
653 /* we will only *set* a pwdlastset date when
654 a) the last pwdlastset time was 0 (user was forced to
655 change password).
656 b) the users password has not expired. gd. */
658 if ((stored_time == 0) ||
659 ((now - stored_time) > pwd_max_age)) {
660 pdb_set_pass_last_set_time(to, now, PDB_CHANGED);
665 if (from->fields_present & SAMR_FIELD_COUNTRY_CODE) {
666 DEBUG(10,("%s SAMR_FIELD_COUNTRY_CODE: %08X -> %08X\n", l,
667 pdb_get_country_code(to), from->country_code));
668 if (from->country_code != pdb_get_country_code(to)) {
669 pdb_set_country_code(to,
670 from->country_code, PDB_CHANGED);
674 if (from->fields_present & SAMR_FIELD_CODE_PAGE) {
675 DEBUG(10,("%s SAMR_FIELD_CODE_PAGE: %08X -> %08X\n", l,
676 pdb_get_code_page(to), from->code_page));
677 if (from->code_page != pdb_get_code_page(to)) {
678 pdb_set_code_page(to,
679 from->code_page, PDB_CHANGED);
685 /*************************************************************
686 Copies a struct samr_UserInfo23 to a struct samu
687 **************************************************************/
689 void copy_id23_to_sam_passwd(struct samu *to,
690 struct samr_UserInfo23 *from)
692 if (from == NULL || to == NULL) {
693 return;
696 copy_id21_to_sam_passwd("INFO 23", to, &from->info);
699 /*************************************************************
700 Copies a struct samr_UserInfo24 to a struct samu
701 **************************************************************/
703 void copy_id24_to_sam_passwd(struct samu *to,
704 struct samr_UserInfo24 *from)
706 struct samr_UserInfo21 i;
708 if (from == NULL || to == NULL) {
709 return;
712 ZERO_STRUCT(i);
714 i.fields_present = SAMR_FIELD_EXPIRED_FLAG;
715 i.password_expired = from->password_expired;
717 copy_id21_to_sam_passwd("INFO_24", to, &i);
720 /*************************************************************
721 Copies a struct samr_UserInfo25 to a struct samu
722 **************************************************************/
724 void copy_id25_to_sam_passwd(struct samu *to,
725 struct samr_UserInfo25 *from)
727 if (from == NULL || to == NULL) {
728 return;
731 copy_id21_to_sam_passwd("INFO_25", to, &from->info);
734 void copy_id32_to_sam_passwd(struct samu *to, struct samr_UserInfo32 *from)
736 if (from == NULL || to == NULL) {
737 return;
740 copy_id21_to_sam_passwd("INFO_32", to, &from->info);
743 void copy_pwd_expired_to_sam_passwd(struct samu *to,
744 uint8_t password_expired)
746 struct samr_UserInfo21 i = {
747 .fields_present = SAMR_FIELD_EXPIRED_FLAG,
748 .password_expired = password_expired,
751 if (to == NULL) {
752 return;
755 copy_id21_to_sam_passwd("INFO_GENERIC", to, &i);