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
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #define DBGC_CLASS DBGC_RPC_SRV
30 #define STRING_CHANGED (old_string && !new_string) ||\
31 (!old_string && new_string) ||\
32 (old_string && new_string && (strcmp(old_string, new_string) != 0))
34 #define STRING_CHANGED_NC(s1,s2) ((s1) && !(s2)) ||\
36 ((s1) && (s2) && (strcmp((s1), (s2)) != 0))
38 /*************************************************************
39 Copies a SAM_USER_INFO_20 to a SAM_ACCOUNT
40 **************************************************************/
42 void copy_id20_to_sam_passwd(SAM_ACCOUNT
*to
, SAM_USER_INFO_20
*from
)
44 const char *old_string
;
48 if (from
== NULL
|| to
== NULL
)
51 if (from
->hdr_munged_dial
.buffer
) {
52 old_string
= pdb_get_munged_dial(to
);
53 mung
.length
= from
->hdr_munged_dial
.uni_str_len
;
54 mung
.data
= (uint8
*) from
->uni_munged_dial
.buffer
;
55 new_string
= base64_encode_data_blob(mung
);
56 DEBUG(10,("INFO_20 UNI_MUNGED_DIAL: %s -> %s\n",old_string
, new_string
));
57 if (STRING_CHANGED_NC(old_string
,new_string
))
58 pdb_set_munged_dial(to
, new_string
, PDB_CHANGED
);
60 SAFE_FREE(new_string
);
64 /*************************************************************
65 Copies a SAM_USER_INFO_21 to a SAM_ACCOUNT
66 **************************************************************/
68 void copy_id21_to_sam_passwd(SAM_ACCOUNT
*to
, SAM_USER_INFO_21
*from
)
70 time_t unix_time
, stored_time
;
71 const char *old_string
, *new_string
;
74 if (from
== NULL
|| to
== NULL
)
77 if (from
->fields_present
& ACCT_LAST_LOGON
) {
78 unix_time
=nt_time_to_unix(&from
->logon_time
);
79 stored_time
= pdb_get_logon_time(to
);
80 DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
81 if (stored_time
!= unix_time
)
82 pdb_set_logon_time(to
, unix_time
, PDB_CHANGED
);
85 if (from
->fields_present
& ACCT_LAST_LOGOFF
) {
86 unix_time
=nt_time_to_unix(&from
->logoff_time
);
87 stored_time
= pdb_get_logoff_time(to
);
88 DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
89 if (stored_time
!= unix_time
)
90 pdb_set_logoff_time(to
, unix_time
, PDB_CHANGED
);
93 if (from
->fields_present
& ACCT_EXPIRY
) {
94 unix_time
=nt_time_to_unix(&from
->kickoff_time
);
95 stored_time
= pdb_get_kickoff_time(to
);
96 DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
97 if (stored_time
!= unix_time
)
98 pdb_set_kickoff_time(to
, unix_time
, PDB_CHANGED
);
101 if (from
->fields_present
& ACCT_ALLOW_PWD_CHANGE
) {
102 unix_time
=nt_time_to_unix(&from
->pass_can_change_time
);
103 stored_time
= pdb_get_pass_can_change_time(to
);
104 DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
105 if (stored_time
!= unix_time
)
106 pdb_set_pass_can_change_time(to
, unix_time
, PDB_CHANGED
);
109 if (from
->fields_present
& ACCT_LAST_PWD_CHANGE
) {
110 unix_time
=nt_time_to_unix(&from
->pass_last_set_time
);
111 stored_time
= pdb_get_pass_last_set_time(to
);
112 DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
113 if (stored_time
!= unix_time
)
114 pdb_set_pass_last_set_time(to
, unix_time
, PDB_CHANGED
);
117 if (from
->fields_present
& ACCT_FORCE_PWD_CHANGE
) {
118 unix_time
=nt_time_to_unix(&from
->pass_must_change_time
);
119 stored_time
=pdb_get_pass_must_change_time(to
);
120 DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
121 if (stored_time
!= unix_time
)
122 pdb_set_pass_must_change_time(to
, unix_time
, PDB_CHANGED
);
125 if ((from
->fields_present
& ACCT_USERNAME
) &&
126 (from
->hdr_user_name
.buffer
)) {
127 old_string
= pdb_get_username(to
);
128 new_string
= unistr2_static(&from
->uni_user_name
);
129 DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string
, new_string
));
131 pdb_set_username(to
, new_string
, PDB_CHANGED
);
134 if ((from
->fields_present
& ACCT_FULL_NAME
) &&
135 (from
->hdr_full_name
.buffer
)) {
136 old_string
= pdb_get_fullname(to
);
137 new_string
= unistr2_static(&from
->uni_full_name
);
138 DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string
, new_string
));
140 pdb_set_fullname(to
, new_string
, PDB_CHANGED
);
143 if ((from
->fields_present
& ACCT_HOME_DIR
) &&
144 (from
->hdr_home_dir
.buffer
)) {
145 old_string
= pdb_get_homedir(to
);
146 new_string
= unistr2_static(&from
->uni_home_dir
);
147 DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string
,new_string
));
149 pdb_set_homedir(to
, new_string
, PDB_CHANGED
);
152 if ((from
->fields_present
& ACCT_HOME_DRIVE
) &&
153 (from
->hdr_dir_drive
.buffer
)) {
154 old_string
= pdb_get_dir_drive(to
);
155 new_string
= unistr2_static(&from
->uni_dir_drive
);
156 DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string
,new_string
));
158 pdb_set_dir_drive(to
, new_string
, PDB_CHANGED
);
161 if ((from
->fields_present
& ACCT_LOGON_SCRIPT
) &&
162 (from
->hdr_logon_script
.buffer
)) {
163 old_string
= pdb_get_logon_script(to
);
164 new_string
= unistr2_static(&from
->uni_logon_script
);
165 DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string
,new_string
));
167 pdb_set_logon_script(to
, new_string
, PDB_CHANGED
);
170 if ((from
->fields_present
& ACCT_PROFILE
) &&
171 (from
->hdr_profile_path
.buffer
)) {
172 old_string
= pdb_get_profile_path(to
);
173 new_string
= unistr2_static(&from
->uni_profile_path
);
174 DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string
, new_string
));
176 pdb_set_profile_path(to
, new_string
, PDB_CHANGED
);
179 if ((from
->fields_present
& ACCT_DESCRIPTION
) &&
180 (from
->hdr_acct_desc
.buffer
)) {
181 old_string
= pdb_get_acct_desc(to
);
182 new_string
= unistr2_static(&from
->uni_acct_desc
);
183 DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string
,new_string
));
185 pdb_set_acct_desc(to
, new_string
, PDB_CHANGED
);
188 if ((from
->fields_present
& ACCT_WORKSTATIONS
) &&
189 (from
->hdr_workstations
.buffer
)) {
190 old_string
= pdb_get_workstations(to
);
191 new_string
= unistr2_static(&from
->uni_workstations
);
192 DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string
, new_string
));
194 pdb_set_workstations(to
, new_string
, PDB_CHANGED
);
198 if ((from
->fields_present
& ACCT_ADMIN_DESC
) &&
199 (from
->hdr_unknown_str
.buffer
)) {
200 old_string
= pdb_get_unknown_str(to
);
201 new_string
= unistr2_static(&from
->uni_unknown_str
);
202 DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string
, new_string
));
204 pdb_set_unknown_str(to
, new_string
, PDB_CHANGED
);
207 if ((from
->fields_present
& ACCT_CALLBACK
) &&
208 (from
->hdr_munged_dial
.buffer
)) {
210 old_string
= pdb_get_munged_dial(to
);
211 mung
.length
= from
->hdr_munged_dial
.uni_str_len
;
212 mung
.data
= (uint8
*) from
->uni_munged_dial
.buffer
;
213 newstr
= base64_encode_data_blob(mung
);
214 DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string
, newstr
));
215 if (STRING_CHANGED_NC(old_string
,newstr
))
216 pdb_set_munged_dial(to
, newstr
, PDB_CHANGED
);
221 if (from
->fields_present
& ACCT_RID
) {
222 if (from
->user_rid
== 0) {
223 DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n"));
224 } else if (from
->user_rid
!= pdb_get_user_rid(to
)) {
225 DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to
),from
->user_rid
));
229 if (from
->fields_present
& ACCT_PRIMARY_GID
) {
230 if (from
->group_rid
== 0) {
231 DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n"));
232 } else if (from
->group_rid
!= pdb_get_group_rid(to
)) {
233 DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to
),from
->group_rid
));
234 pdb_set_group_sid_from_rid(to
, from
->group_rid
, PDB_CHANGED
);
238 if (from
->fields_present
& ACCT_FLAGS
) {
239 DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to
),from
->acb_info
));
240 if (from
->acb_info
!= pdb_get_acct_ctrl(to
)) {
241 pdb_set_acct_ctrl(to
, from
->acb_info
, PDB_CHANGED
);
245 if (from
->fields_present
& ACCT_LOGON_HOURS
) {
246 DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to
),from
->logon_divs
));
247 if (from
->logon_divs
!= pdb_get_logon_divs(to
)) {
248 pdb_set_logon_divs(to
, from
->logon_divs
, PDB_CHANGED
);
251 DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to
),from
->logon_hrs
.len
));
252 if (from
->logon_hrs
.len
!= pdb_get_hours_len(to
)) {
253 pdb_set_hours_len(to
, from
->logon_hrs
.len
, PDB_CHANGED
);
256 DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to
),from
->logon_hrs
.hours
));
257 /* Fix me: only update if it changes --metze */
258 pdb_set_hours(to
, from
->logon_hrs
.hours
, PDB_CHANGED
);
260 /* This is max logon hours */
261 DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to
),from
->unknown_6
));
262 if (from
->unknown_6
!= pdb_get_unknown_6(to
)) {
263 pdb_set_unknown_6(to
, from
->unknown_6
, PDB_CHANGED
);
267 if (from
->fields_present
& ACCT_BAD_PWD_COUNT
) {
268 DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to
),from
->bad_password_count
));
269 if (from
->bad_password_count
!= pdb_get_bad_password_count(to
)) {
270 pdb_set_bad_password_count(to
, from
->bad_password_count
, PDB_CHANGED
);
274 if (from
->fields_present
& ACCT_NUM_LOGONS
) {
275 DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to
),from
->logon_count
));
276 if (from
->logon_count
!= pdb_get_logon_count(to
)) {
277 pdb_set_logon_count(to
, from
->logon_count
, PDB_CHANGED
);
281 DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from
->passmustchange
));
282 if (from
->passmustchange
==PASS_MUST_CHANGE_AT_NEXT_LOGON
) {
283 pdb_set_pass_must_change_time(to
,0, PDB_CHANGED
);
287 if (pdb_get_pass_must_change_time(to
) == 0) {
288 if (!account_policy_get(AP_MAX_PASSWORD_AGE
, &expire
)
289 || expire
== (uint32
)-1) {
290 new_time
= get_time_t_max();
292 time_t old_time
= pdb_get_pass_last_set_time(to
);
293 new_time
= old_time
+ expire
;
294 if ((new_time
) < time(0)) {
295 new_time
= time(0) + expire
;
298 if (!pdb_set_pass_must_change_time (to
, new_time
, PDB_CHANGED
)) {
299 DEBUG (0, ("pdb_set_pass_must_change_time failed!\n"));
304 DEBUG(10,("INFO_21 PADDING_2: %02X\n",from
->padding2
));
306 DEBUG(10,("INFO_21 PADDING_4: %08X\n",from
->padding4
));
310 /*************************************************************
311 Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT
312 **************************************************************/
314 void copy_id23_to_sam_passwd(SAM_ACCOUNT
*to
, SAM_USER_INFO_23
*from
)
316 time_t unix_time
, stored_time
;
317 const char *old_string
, *new_string
;
320 if (from
== NULL
|| to
== NULL
)
323 if (from
->fields_present
& ACCT_LAST_LOGON
) {
324 unix_time
=nt_time_to_unix(&from
->logon_time
);
325 stored_time
= pdb_get_logon_time(to
);
326 DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
327 if (stored_time
!= unix_time
)
328 pdb_set_logon_time(to
, unix_time
, PDB_CHANGED
);
331 if (from
->fields_present
& ACCT_LAST_LOGOFF
) {
332 unix_time
=nt_time_to_unix(&from
->logoff_time
);
333 stored_time
= pdb_get_logoff_time(to
);
334 DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
335 if (stored_time
!= unix_time
)
336 pdb_set_logoff_time(to
, unix_time
, PDB_CHANGED
);
339 if (from
->fields_present
& ACCT_EXPIRY
) {
340 unix_time
=nt_time_to_unix(&from
->kickoff_time
);
341 stored_time
= pdb_get_kickoff_time(to
);
342 DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
343 if (stored_time
!= unix_time
)
344 pdb_set_kickoff_time(to
, unix_time
, PDB_CHANGED
);
347 if (from
->fields_present
& ACCT_ALLOW_PWD_CHANGE
) {
348 unix_time
=nt_time_to_unix(&from
->pass_can_change_time
);
349 stored_time
= pdb_get_pass_can_change_time(to
);
350 DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
351 if (stored_time
!= unix_time
)
352 pdb_set_pass_can_change_time(to
, unix_time
, PDB_CHANGED
);
355 if (from
->fields_present
& ACCT_LAST_PWD_CHANGE
) {
356 unix_time
=nt_time_to_unix(&from
->pass_last_set_time
);
357 stored_time
= pdb_get_pass_last_set_time(to
);
358 DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
359 if (stored_time
!= unix_time
)
360 pdb_set_pass_last_set_time(to
, unix_time
, PDB_CHANGED
);
363 if (from
->fields_present
& ACCT_FORCE_PWD_CHANGE
) {
364 unix_time
=nt_time_to_unix(&from
->pass_must_change_time
);
365 stored_time
=pdb_get_pass_must_change_time(to
);
366 DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time
, (long unsigned int)unix_time
));
367 if (stored_time
!= unix_time
)
368 pdb_set_pass_must_change_time(to
, unix_time
, PDB_CHANGED
);
371 /* Backend should check this for sanity */
372 if ((from
->fields_present
& ACCT_USERNAME
) &&
373 (from
->hdr_user_name
.buffer
)) {
374 old_string
= pdb_get_username(to
);
375 new_string
= unistr2_static(&from
->uni_user_name
);
376 DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string
, new_string
));
378 pdb_set_username(to
, new_string
, PDB_CHANGED
);
381 if ((from
->fields_present
& ACCT_FULL_NAME
) &&
382 (from
->hdr_full_name
.buffer
)) {
383 old_string
= pdb_get_fullname(to
);
384 new_string
= unistr2_static(&from
->uni_full_name
);
385 DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string
, new_string
));
387 pdb_set_fullname(to
, new_string
, PDB_CHANGED
);
390 if ((from
->fields_present
& ACCT_HOME_DIR
) &&
391 (from
->hdr_home_dir
.buffer
)) {
392 old_string
= pdb_get_homedir(to
);
393 new_string
= unistr2_static(&from
->uni_home_dir
);
394 DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string
,new_string
));
396 pdb_set_homedir(to
, new_string
, PDB_CHANGED
);
399 if ((from
->fields_present
& ACCT_HOME_DRIVE
) &&
400 (from
->hdr_dir_drive
.buffer
)) {
401 old_string
= pdb_get_dir_drive(to
);
402 new_string
= unistr2_static(&from
->uni_dir_drive
);
403 DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string
,new_string
));
405 pdb_set_dir_drive(to
, new_string
, PDB_CHANGED
);
408 if ((from
->fields_present
& ACCT_LOGON_SCRIPT
) &&
409 (from
->hdr_logon_script
.buffer
)) {
410 old_string
= pdb_get_logon_script(to
);
411 new_string
= unistr2_static(&from
->uni_logon_script
);
412 DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string
,new_string
));
414 pdb_set_logon_script(to
, new_string
, PDB_CHANGED
);
417 if ((from
->fields_present
& ACCT_PROFILE
) &&
418 (from
->hdr_profile_path
.buffer
)) {
419 old_string
= pdb_get_profile_path(to
);
420 new_string
= unistr2_static(&from
->uni_profile_path
);
421 DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string
, new_string
));
423 pdb_set_profile_path(to
, new_string
, PDB_CHANGED
);
426 if ((from
->fields_present
& ACCT_DESCRIPTION
) &&
427 (from
->hdr_acct_desc
.buffer
)) {
428 old_string
= pdb_get_acct_desc(to
);
429 new_string
= unistr2_static(&from
->uni_acct_desc
);
430 DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string
,new_string
));
432 pdb_set_acct_desc(to
, new_string
, PDB_CHANGED
);
435 if ((from
->fields_present
& ACCT_WORKSTATIONS
) &&
436 (from
->hdr_workstations
.buffer
)) {
437 old_string
= pdb_get_workstations(to
);
438 new_string
= unistr2_static(&from
->uni_workstations
);
439 DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string
, new_string
));
441 pdb_set_workstations(to
, new_string
, PDB_CHANGED
);
445 if ((from
->fields_present
& ACCT_ADMIN_DESC
) &&
446 (from
->hdr_unknown_str
.buffer
)) {
447 old_string
= pdb_get_unknown_str(to
);
448 new_string
= unistr2_static(&from
->uni_unknown_str
);
449 DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string
, new_string
));
451 pdb_set_unknown_str(to
, new_string
, PDB_CHANGED
);
454 if ((from
->fields_present
& ACCT_CALLBACK
) &&
455 (from
->hdr_munged_dial
.buffer
)) {
457 old_string
= pdb_get_munged_dial(to
);
458 mung
.length
= from
->hdr_munged_dial
.uni_str_len
;
459 mung
.data
= (uint8
*) from
->uni_munged_dial
.buffer
;
460 newstr
= base64_encode_data_blob(mung
);
461 DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string
, newstr
));
462 if (STRING_CHANGED_NC(old_string
, newstr
))
463 pdb_set_munged_dial(to
, newstr
, PDB_CHANGED
);
468 if (from
->fields_present
& ACCT_RID
) {
469 if (from
->user_rid
== 0) {
470 DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n"));
471 } else if (from
->user_rid
!= pdb_get_user_rid(to
)) {
472 DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to
),from
->user_rid
));
476 if (from
->fields_present
& ACCT_PRIMARY_GID
) {
477 if (from
->group_rid
== 0) {
478 DEBUG(10, ("INFO_23: Asked to set Group RID to 0 !? Skipping change!\n"));
479 } else if (from
->group_rid
!= pdb_get_group_rid(to
)) {
480 DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to
),from
->group_rid
));
481 pdb_set_group_sid_from_rid(to
, from
->group_rid
, PDB_CHANGED
);
485 if (from
->fields_present
& ACCT_FLAGS
) {
486 DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to
),from
->acb_info
));
487 if (from
->acb_info
!= pdb_get_acct_ctrl(to
)) {
488 pdb_set_acct_ctrl(to
, from
->acb_info
, PDB_CHANGED
);
492 if (from
->fields_present
& ACCT_LOGON_HOURS
) {
493 DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to
),from
->logon_divs
));
494 if (from
->logon_divs
!= pdb_get_logon_divs(to
)) {
495 pdb_set_logon_divs(to
, from
->logon_divs
, PDB_CHANGED
);
498 DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to
),from
->logon_hrs
.len
));
499 if (from
->logon_hrs
.len
!= pdb_get_hours_len(to
)) {
500 pdb_set_hours_len(to
, from
->logon_hrs
.len
, PDB_CHANGED
);
503 DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to
),from
->logon_hrs
.hours
));
504 /* Fix me: only update if it changes --metze */
505 pdb_set_hours(to
, from
->logon_hrs
.hours
, PDB_CHANGED
);
507 /* This is max logon hours */
508 DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to
),from
->unknown_6
));
509 if (from
->unknown_6
!= pdb_get_unknown_6(to
)) {
510 pdb_set_unknown_6(to
, from
->unknown_6
, PDB_CHANGED
);
514 if (from
->fields_present
& ACCT_BAD_PWD_COUNT
) {
515 DEBUG(10,("INFO_23 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to
),from
->bad_password_count
));
516 if (from
->bad_password_count
!= pdb_get_bad_password_count(to
)) {
517 pdb_set_bad_password_count(to
, from
->bad_password_count
, PDB_CHANGED
);
521 if (from
->fields_present
& ACCT_NUM_LOGONS
) {
522 DEBUG(10,("INFO_23 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to
),from
->logon_count
));
523 if (from
->logon_count
!= pdb_get_logon_count(to
)) {
524 pdb_set_logon_count(to
, from
->logon_count
, PDB_CHANGED
);
528 DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from
->passmustchange
));
529 if (from
->passmustchange
==PASS_MUST_CHANGE_AT_NEXT_LOGON
) {
530 pdb_set_pass_must_change_time(to
,0, PDB_CHANGED
);
534 if (pdb_get_pass_must_change_time(to
) == 0) {
535 if (!account_policy_get(AP_MAX_PASSWORD_AGE
, &expire
)
536 || expire
== (uint32
)-1) {
537 new_time
= get_time_t_max();
539 time_t old_time
= pdb_get_pass_last_set_time(to
);
540 new_time
= old_time
+ expire
;
541 if ((new_time
) < time(0)) {
542 new_time
= time(0) + expire
;
545 if (!pdb_set_pass_must_change_time (to
, new_time
, PDB_CHANGED
)) {
546 DEBUG (0, ("pdb_set_pass_must_change_time failed!\n"));
551 DEBUG(10,("INFO_23 PADDING_2: %02X\n",from
->padding2
));
553 DEBUG(10,("INFO_23 PADDING_4: %08X\n",from
->padding4
));