| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | SAMR Pipe utility functions.
|
|---|
| 4 |
|
|---|
| 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 |
|
|---|
| 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.
|
|---|
| 14 |
|
|---|
| 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.
|
|---|
| 19 |
|
|---|
| 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.
|
|---|
| 23 | */
|
|---|
| 24 |
|
|---|
| 25 | #include "includes.h"
|
|---|
| 26 |
|
|---|
| 27 | #undef DBGC_CLASS
|
|---|
| 28 | #define DBGC_CLASS DBGC_RPC_SRV
|
|---|
| 29 |
|
|---|
| 30 | #define STRING_CHANGED (old_string && !new_string) ||\
|
|---|
| 31 | (!old_string && new_string) ||\
|
|---|
| 32 | (old_string && new_string && (strcmp(old_string, new_string) != 0))
|
|---|
| 33 |
|
|---|
| 34 | #define STRING_CHANGED_NC(s1,s2) ((s1) && !(s2)) ||\
|
|---|
| 35 | (!(s1) && (s2)) ||\
|
|---|
| 36 | ((s1) && (s2) && (strcmp((s1), (s2)) != 0))
|
|---|
| 37 |
|
|---|
| 38 | /*************************************************************
|
|---|
| 39 | Copies a SAM_USER_INFO_20 to a struct samu
|
|---|
| 40 | **************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from)
|
|---|
| 43 | {
|
|---|
| 44 | const char *old_string;
|
|---|
| 45 | char *new_string;
|
|---|
| 46 | DATA_BLOB mung;
|
|---|
| 47 |
|
|---|
| 48 | if (from == NULL || to == NULL)
|
|---|
| 49 | return;
|
|---|
| 50 |
|
|---|
| 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 | mung.free = NULL;
|
|---|
| 56 | new_string = (mung.length == 0) ?
|
|---|
| 57 | NULL : base64_encode_data_blob(mung);
|
|---|
| 58 | DEBUG(10,("INFO_20 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string));
|
|---|
| 59 | if (STRING_CHANGED_NC(old_string,new_string))
|
|---|
| 60 | pdb_set_munged_dial(to , new_string, PDB_CHANGED);
|
|---|
| 61 |
|
|---|
| 62 | SAFE_FREE(new_string);
|
|---|
| 63 | }
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | /*************************************************************
|
|---|
| 67 | Copies a SAM_USER_INFO_21 to a struct samu
|
|---|
| 68 | **************************************************************/
|
|---|
| 69 |
|
|---|
| 70 | void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from)
|
|---|
| 71 | {
|
|---|
| 72 | time_t unix_time, stored_time;
|
|---|
| 73 | const char *old_string, *new_string;
|
|---|
| 74 | DATA_BLOB mung;
|
|---|
| 75 |
|
|---|
| 76 | if (from == NULL || to == NULL)
|
|---|
| 77 | return;
|
|---|
| 78 |
|
|---|
| 79 | if (from->fields_present & ACCT_LAST_LOGON) {
|
|---|
| 80 | unix_time=nt_time_to_unix(from->logon_time);
|
|---|
| 81 | stored_time = pdb_get_logon_time(to);
|
|---|
| 82 | DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 83 | if (stored_time != unix_time)
|
|---|
| 84 | pdb_set_logon_time(to, unix_time, PDB_CHANGED);
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | if (from->fields_present & ACCT_LAST_LOGOFF) {
|
|---|
| 88 | unix_time=nt_time_to_unix(from->logoff_time);
|
|---|
| 89 | stored_time = pdb_get_logoff_time(to);
|
|---|
| 90 | DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 91 | if (stored_time != unix_time)
|
|---|
| 92 | pdb_set_logoff_time(to, unix_time, PDB_CHANGED);
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | if (from->fields_present & ACCT_EXPIRY) {
|
|---|
| 96 | unix_time=nt_time_to_unix(from->kickoff_time);
|
|---|
| 97 | stored_time = pdb_get_kickoff_time(to);
|
|---|
| 98 | DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 99 | if (stored_time != unix_time)
|
|---|
| 100 | pdb_set_kickoff_time(to, unix_time , PDB_CHANGED);
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | if (from->fields_present & ACCT_LAST_PWD_CHANGE) {
|
|---|
| 104 | unix_time=nt_time_to_unix(from->pass_last_set_time);
|
|---|
| 105 | stored_time = pdb_get_pass_last_set_time(to);
|
|---|
| 106 | DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 107 | if (stored_time != unix_time)
|
|---|
| 108 | pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED);
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | if ((from->fields_present & ACCT_USERNAME) &&
|
|---|
| 112 | (from->hdr_user_name.buffer)) {
|
|---|
| 113 | old_string = pdb_get_username(to);
|
|---|
| 114 | new_string = unistr2_static(&from->uni_user_name);
|
|---|
| 115 | DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string));
|
|---|
| 116 | if (STRING_CHANGED)
|
|---|
| 117 | pdb_set_username(to , new_string, PDB_CHANGED);
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | if ((from->fields_present & ACCT_FULL_NAME) &&
|
|---|
| 121 | (from->hdr_full_name.buffer)) {
|
|---|
| 122 | old_string = pdb_get_fullname(to);
|
|---|
| 123 | new_string = unistr2_static(&from->uni_full_name);
|
|---|
| 124 | DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string));
|
|---|
| 125 | if (STRING_CHANGED)
|
|---|
| 126 | pdb_set_fullname(to , new_string, PDB_CHANGED);
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | if ((from->fields_present & ACCT_HOME_DIR) &&
|
|---|
| 130 | (from->hdr_home_dir.buffer)) {
|
|---|
| 131 | old_string = pdb_get_homedir(to);
|
|---|
| 132 | new_string = unistr2_static(&from->uni_home_dir);
|
|---|
| 133 | DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string));
|
|---|
| 134 | if (STRING_CHANGED)
|
|---|
| 135 | pdb_set_homedir(to , new_string, PDB_CHANGED);
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | if ((from->fields_present & ACCT_HOME_DRIVE) &&
|
|---|
| 139 | (from->hdr_dir_drive.buffer)) {
|
|---|
| 140 | old_string = pdb_get_dir_drive(to);
|
|---|
| 141 | new_string = unistr2_static(&from->uni_dir_drive);
|
|---|
| 142 | DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string));
|
|---|
| 143 | if (STRING_CHANGED)
|
|---|
| 144 | pdb_set_dir_drive(to , new_string, PDB_CHANGED);
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | if ((from->fields_present & ACCT_LOGON_SCRIPT) &&
|
|---|
| 148 | (from->hdr_logon_script.buffer)) {
|
|---|
| 149 | old_string = pdb_get_logon_script(to);
|
|---|
| 150 | new_string = unistr2_static(&from->uni_logon_script);
|
|---|
| 151 | DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string));
|
|---|
| 152 | if (STRING_CHANGED)
|
|---|
| 153 | pdb_set_logon_script(to , new_string, PDB_CHANGED);
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | if ((from->fields_present & ACCT_PROFILE) &&
|
|---|
| 157 | (from->hdr_profile_path.buffer)) {
|
|---|
| 158 | old_string = pdb_get_profile_path(to);
|
|---|
| 159 | new_string = unistr2_static(&from->uni_profile_path);
|
|---|
| 160 | DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string));
|
|---|
| 161 | if (STRING_CHANGED)
|
|---|
| 162 | pdb_set_profile_path(to , new_string, PDB_CHANGED);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | if ((from->fields_present & ACCT_DESCRIPTION) &&
|
|---|
| 166 | (from->hdr_acct_desc.buffer)) {
|
|---|
| 167 | old_string = pdb_get_acct_desc(to);
|
|---|
| 168 | new_string = unistr2_static(&from->uni_acct_desc);
|
|---|
| 169 | DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string));
|
|---|
| 170 | if (STRING_CHANGED)
|
|---|
| 171 | pdb_set_acct_desc(to , new_string, PDB_CHANGED);
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | if ((from->fields_present & ACCT_WORKSTATIONS) &&
|
|---|
| 175 | (from->hdr_workstations.buffer)) {
|
|---|
| 176 | old_string = pdb_get_workstations(to);
|
|---|
| 177 | new_string = unistr2_static(&from->uni_workstations);
|
|---|
| 178 | DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string));
|
|---|
| 179 | if (STRING_CHANGED)
|
|---|
| 180 | pdb_set_workstations(to , new_string, PDB_CHANGED);
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | if ((from->fields_present & ACCT_COMMENT) &&
|
|---|
| 184 | (from->hdr_comment.buffer)) {
|
|---|
| 185 | old_string = pdb_get_comment(to);
|
|---|
| 186 | new_string = unistr2_static(&from->uni_comment);
|
|---|
| 187 | DEBUG(10,("INFO_21 UNI_COMMENT: %s -> %s\n",old_string, new_string));
|
|---|
| 188 | if (STRING_CHANGED)
|
|---|
| 189 | pdb_set_comment(to, new_string, PDB_CHANGED);
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | if ((from->fields_present & ACCT_CALLBACK) &&
|
|---|
| 193 | (from->hdr_munged_dial.buffer)) {
|
|---|
| 194 | char *newstr;
|
|---|
| 195 | old_string = pdb_get_munged_dial(to);
|
|---|
| 196 | mung.length = from->hdr_munged_dial.uni_str_len;
|
|---|
| 197 | mung.data = (uint8 *) from->uni_munged_dial.buffer;
|
|---|
| 198 | mung.free = NULL;
|
|---|
| 199 | newstr = (mung.length == 0) ?
|
|---|
| 200 | NULL : base64_encode_data_blob(mung);
|
|---|
| 201 | DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr));
|
|---|
| 202 | if (STRING_CHANGED_NC(old_string,newstr))
|
|---|
| 203 | pdb_set_munged_dial(to , newstr, PDB_CHANGED);
|
|---|
| 204 |
|
|---|
| 205 | SAFE_FREE(newstr);
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | if (from->fields_present & ACCT_RID) {
|
|---|
| 209 | if (from->user_rid == 0) {
|
|---|
| 210 | DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n"));
|
|---|
| 211 | } else if (from->user_rid != pdb_get_user_rid(to)) {
|
|---|
| 212 | DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid));
|
|---|
| 213 | }
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | if (from->fields_present & ACCT_PRIMARY_GID) {
|
|---|
| 217 | if (from->group_rid == 0) {
|
|---|
| 218 | DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n"));
|
|---|
| 219 | } else if (from->group_rid != pdb_get_group_rid(to)) {
|
|---|
| 220 | DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid));
|
|---|
| 221 | pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED);
|
|---|
| 222 | }
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | if (from->fields_present & ACCT_FLAGS) {
|
|---|
| 226 | DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
|
|---|
| 227 | if (from->acb_info != pdb_get_acct_ctrl(to)) {
|
|---|
| 228 | if (!(from->acb_info & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) {
|
|---|
| 229 | /* We're unlocking a previously locked user. Reset bad password counts.
|
|---|
| 230 | Patch from Jianliang Lu. <[email protected]> */
|
|---|
| 231 | pdb_set_bad_password_count(to, 0, PDB_CHANGED);
|
|---|
| 232 | pdb_set_bad_password_time(to, 0, PDB_CHANGED);
|
|---|
| 233 | }
|
|---|
| 234 | pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED);
|
|---|
| 235 | }
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | if (from->fields_present & ACCT_LOGON_HOURS) {
|
|---|
| 239 | pstring oldstr, newstr;
|
|---|
| 240 | DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
|
|---|
| 241 | if (from->logon_divs != pdb_get_logon_divs(to)) {
|
|---|
| 242 | pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED);
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
|
|---|
| 246 | if (from->logon_hrs.len != pdb_get_hours_len(to)) {
|
|---|
| 247 | pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED);
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
|
|---|
| 251 | pdb_sethexhours(oldstr, pdb_get_hours(to));
|
|---|
| 252 | pdb_sethexhours(newstr, from->logon_hrs.hours);
|
|---|
| 253 | if (!strequal(oldstr, newstr)) {
|
|---|
| 254 | pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | if (from->fields_present & ACCT_BAD_PWD_COUNT) {
|
|---|
| 259 | DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count));
|
|---|
| 260 | if (from->bad_password_count != pdb_get_bad_password_count(to)) {
|
|---|
| 261 | pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED);
|
|---|
| 262 | }
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | if (from->fields_present & ACCT_NUM_LOGONS) {
|
|---|
| 266 | DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count));
|
|---|
| 267 | if (from->logon_count != pdb_get_logon_count(to)) {
|
|---|
| 268 | pdb_set_logon_count(to, from->logon_count, PDB_CHANGED);
|
|---|
| 269 | }
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | /* If the must change flag is set, the last set time goes to zero.
|
|---|
| 273 | the must change and can change fields also do, but they are
|
|---|
| 274 | calculated from policy, not set from the wire */
|
|---|
| 275 |
|
|---|
| 276 | if (from->fields_present & ACCT_EXPIRED_FLAG) {
|
|---|
| 277 | DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
|
|---|
| 278 | if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) {
|
|---|
| 279 | pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
|
|---|
| 280 | } else {
|
|---|
| 281 | /* A subtlety here: some windows commands will
|
|---|
| 282 | clear the expired flag even though it's not
|
|---|
| 283 | set, and we don't want to reset the time
|
|---|
| 284 | in these caess. "net user /dom <user> /active:y"
|
|---|
| 285 | for example, to clear an autolocked acct.
|
|---|
| 286 | We must check to see if it's expired first. jmcd */
|
|---|
| 287 | stored_time = pdb_get_pass_last_set_time(to);
|
|---|
| 288 | if (stored_time == 0)
|
|---|
| 289 | pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED);
|
|---|
| 290 | }
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2));
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 | /*************************************************************
|
|---|
| 298 | Copies a SAM_USER_INFO_23 to a struct samu
|
|---|
| 299 | **************************************************************/
|
|---|
| 300 |
|
|---|
| 301 | void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from)
|
|---|
| 302 | {
|
|---|
| 303 | time_t unix_time, stored_time;
|
|---|
| 304 | const char *old_string, *new_string;
|
|---|
| 305 | DATA_BLOB mung;
|
|---|
| 306 |
|
|---|
| 307 | if (from == NULL || to == NULL)
|
|---|
| 308 | return;
|
|---|
| 309 |
|
|---|
| 310 | if (from->fields_present & ACCT_LAST_LOGON) {
|
|---|
| 311 | unix_time=nt_time_to_unix(from->logon_time);
|
|---|
| 312 | stored_time = pdb_get_logon_time(to);
|
|---|
| 313 | DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 314 | if (stored_time != unix_time)
|
|---|
| 315 | pdb_set_logon_time(to, unix_time, PDB_CHANGED);
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | if (from->fields_present & ACCT_LAST_LOGOFF) {
|
|---|
| 319 | unix_time=nt_time_to_unix(from->logoff_time);
|
|---|
| 320 | stored_time = pdb_get_logoff_time(to);
|
|---|
| 321 | DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 322 | if (stored_time != unix_time)
|
|---|
| 323 | pdb_set_logoff_time(to, unix_time, PDB_CHANGED);
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | if (from->fields_present & ACCT_EXPIRY) {
|
|---|
| 327 | unix_time=nt_time_to_unix(from->kickoff_time);
|
|---|
| 328 | stored_time = pdb_get_kickoff_time(to);
|
|---|
| 329 | DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 330 | if (stored_time != unix_time)
|
|---|
| 331 | pdb_set_kickoff_time(to, unix_time , PDB_CHANGED);
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | if (from->fields_present & ACCT_LAST_PWD_CHANGE) {
|
|---|
| 335 | unix_time=nt_time_to_unix(from->pass_last_set_time);
|
|---|
| 336 | stored_time = pdb_get_pass_last_set_time(to);
|
|---|
| 337 | DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 338 | if (stored_time != unix_time)
|
|---|
| 339 | pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED);
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | /* Backend should check this for sanity */
|
|---|
| 343 | if ((from->fields_present & ACCT_USERNAME) &&
|
|---|
| 344 | (from->hdr_user_name.buffer)) {
|
|---|
| 345 | old_string = pdb_get_username(to);
|
|---|
| 346 | new_string = unistr2_static(&from->uni_user_name);
|
|---|
| 347 | DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string));
|
|---|
| 348 | if (STRING_CHANGED)
|
|---|
| 349 | pdb_set_username(to , new_string, PDB_CHANGED);
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | if ((from->fields_present & ACCT_FULL_NAME) &&
|
|---|
| 353 | (from->hdr_full_name.buffer)) {
|
|---|
| 354 | old_string = pdb_get_fullname(to);
|
|---|
| 355 | new_string = unistr2_static(&from->uni_full_name);
|
|---|
| 356 | DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string));
|
|---|
| 357 | if (STRING_CHANGED)
|
|---|
| 358 | pdb_set_fullname(to , new_string, PDB_CHANGED);
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | if ((from->fields_present & ACCT_HOME_DIR) &&
|
|---|
| 362 | (from->hdr_home_dir.buffer)) {
|
|---|
| 363 | old_string = pdb_get_homedir(to);
|
|---|
| 364 | new_string = unistr2_static(&from->uni_home_dir);
|
|---|
| 365 | DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string));
|
|---|
| 366 | if (STRING_CHANGED)
|
|---|
| 367 | pdb_set_homedir(to , new_string, PDB_CHANGED);
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 | if ((from->fields_present & ACCT_HOME_DRIVE) &&
|
|---|
| 371 | (from->hdr_dir_drive.buffer)) {
|
|---|
| 372 | old_string = pdb_get_dir_drive(to);
|
|---|
| 373 | new_string = unistr2_static(&from->uni_dir_drive);
|
|---|
| 374 | DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string));
|
|---|
| 375 | if (STRING_CHANGED)
|
|---|
| 376 | pdb_set_dir_drive(to , new_string, PDB_CHANGED);
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 | if ((from->fields_present & ACCT_LOGON_SCRIPT) &&
|
|---|
| 380 | (from->hdr_logon_script.buffer)) {
|
|---|
| 381 | old_string = pdb_get_logon_script(to);
|
|---|
| 382 | new_string = unistr2_static(&from->uni_logon_script);
|
|---|
| 383 | DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string));
|
|---|
| 384 | if (STRING_CHANGED)
|
|---|
| 385 | pdb_set_logon_script(to , new_string, PDB_CHANGED);
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | if ((from->fields_present & ACCT_PROFILE) &&
|
|---|
| 389 | (from->hdr_profile_path.buffer)) {
|
|---|
| 390 | old_string = pdb_get_profile_path(to);
|
|---|
| 391 | new_string = unistr2_static(&from->uni_profile_path);
|
|---|
| 392 | DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string));
|
|---|
| 393 | if (STRING_CHANGED)
|
|---|
| 394 | pdb_set_profile_path(to , new_string, PDB_CHANGED);
|
|---|
| 395 | }
|
|---|
| 396 |
|
|---|
| 397 | if ((from->fields_present & ACCT_DESCRIPTION) &&
|
|---|
| 398 | (from->hdr_acct_desc.buffer)) {
|
|---|
| 399 | old_string = pdb_get_acct_desc(to);
|
|---|
| 400 | new_string = unistr2_static(&from->uni_acct_desc);
|
|---|
| 401 | DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string));
|
|---|
| 402 | if (STRING_CHANGED)
|
|---|
| 403 | pdb_set_acct_desc(to , new_string, PDB_CHANGED);
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | if ((from->fields_present & ACCT_WORKSTATIONS) &&
|
|---|
| 407 | (from->hdr_workstations.buffer)) {
|
|---|
| 408 | old_string = pdb_get_workstations(to);
|
|---|
| 409 | new_string = unistr2_static(&from->uni_workstations);
|
|---|
| 410 | DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string));
|
|---|
| 411 | if (STRING_CHANGED)
|
|---|
| 412 | pdb_set_workstations(to , new_string, PDB_CHANGED);
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | if ((from->fields_present & ACCT_COMMENT) &&
|
|---|
| 416 | (from->hdr_comment.buffer)) {
|
|---|
| 417 | old_string = pdb_get_comment(to);
|
|---|
| 418 | new_string = unistr2_static(&from->uni_comment);
|
|---|
| 419 | DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string));
|
|---|
| 420 | if (STRING_CHANGED)
|
|---|
| 421 | pdb_set_comment(to , new_string, PDB_CHANGED);
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | if ((from->fields_present & ACCT_CALLBACK) &&
|
|---|
| 425 | (from->hdr_munged_dial.buffer)) {
|
|---|
| 426 | char *newstr;
|
|---|
| 427 | old_string = pdb_get_munged_dial(to);
|
|---|
| 428 | mung.length = from->hdr_munged_dial.uni_str_len;
|
|---|
| 429 | mung.data = (uint8 *) from->uni_munged_dial.buffer;
|
|---|
| 430 | mung.free = NULL;
|
|---|
| 431 | newstr = (mung.length == 0) ?
|
|---|
| 432 | NULL : base64_encode_data_blob(mung);
|
|---|
| 433 | DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr));
|
|---|
| 434 | if (STRING_CHANGED_NC(old_string, newstr))
|
|---|
| 435 | pdb_set_munged_dial(to , newstr, PDB_CHANGED);
|
|---|
| 436 |
|
|---|
| 437 | SAFE_FREE(newstr);
|
|---|
| 438 | }
|
|---|
| 439 |
|
|---|
| 440 | if (from->fields_present & ACCT_RID) {
|
|---|
| 441 | if (from->user_rid == 0) {
|
|---|
| 442 | DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n"));
|
|---|
| 443 | } else if (from->user_rid != pdb_get_user_rid(to)) {
|
|---|
| 444 | DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid));
|
|---|
| 445 | }
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | if (from->fields_present & ACCT_PRIMARY_GID) {
|
|---|
| 449 | if (from->group_rid == 0) {
|
|---|
| 450 | DEBUG(10, ("INFO_23: Asked to set Group RID to 0 !? Skipping change!\n"));
|
|---|
| 451 | } else if (from->group_rid != pdb_get_group_rid(to)) {
|
|---|
| 452 | DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid));
|
|---|
| 453 | pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED);
|
|---|
| 454 | }
|
|---|
| 455 | }
|
|---|
| 456 |
|
|---|
| 457 | if (from->fields_present & ACCT_FLAGS) {
|
|---|
| 458 | DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
|
|---|
| 459 | if (from->acb_info != pdb_get_acct_ctrl(to)) {
|
|---|
| 460 | pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED);
|
|---|
| 461 | }
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | if (from->fields_present & ACCT_LOGON_HOURS) {
|
|---|
| 465 | DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
|
|---|
| 466 | if (from->logon_divs != pdb_get_logon_divs(to)) {
|
|---|
| 467 | pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED);
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 | DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
|
|---|
| 471 | if (from->logon_hrs.len != pdb_get_hours_len(to)) {
|
|---|
| 472 | pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED);
|
|---|
| 473 | }
|
|---|
| 474 |
|
|---|
| 475 | DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
|
|---|
| 476 | /* Fix me: only update if it changes --metze */
|
|---|
| 477 | pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
|
|---|
| 478 | }
|
|---|
| 479 |
|
|---|
| 480 | if (from->fields_present & ACCT_BAD_PWD_COUNT) {
|
|---|
| 481 | DEBUG(10,("INFO_23 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count));
|
|---|
| 482 | if (from->bad_password_count != pdb_get_bad_password_count(to)) {
|
|---|
| 483 | pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED);
|
|---|
| 484 | }
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | if (from->fields_present & ACCT_NUM_LOGONS) {
|
|---|
| 488 | DEBUG(10,("INFO_23 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count));
|
|---|
| 489 | if (from->logon_count != pdb_get_logon_count(to)) {
|
|---|
| 490 | pdb_set_logon_count(to, from->logon_count, PDB_CHANGED);
|
|---|
| 491 | }
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 | /* If the must change flag is set, the last set time goes to zero.
|
|---|
| 495 | the must change and can change fields also do, but they are
|
|---|
| 496 | calculated from policy, not set from the wire */
|
|---|
| 497 |
|
|---|
| 498 | if (from->fields_present & ACCT_EXPIRED_FLAG) {
|
|---|
| 499 | DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
|
|---|
| 500 | if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) {
|
|---|
| 501 | pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
|
|---|
| 502 | } else {
|
|---|
| 503 | /* A subtlety here: some windows commands will
|
|---|
| 504 | clear the expired flag even though it's not
|
|---|
| 505 | set, and we don't want to reset the time
|
|---|
| 506 | in these caess. "net user /dom <user> /active:y"
|
|---|
| 507 | for example, to clear an autolocked acct.
|
|---|
| 508 | We must check to see if it's expired first. jmcd */
|
|---|
| 509 | stored_time = pdb_get_pass_last_set_time(to);
|
|---|
| 510 | if (stored_time == 0)
|
|---|
| 511 | pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED);
|
|---|
| 512 | }
|
|---|
| 513 | }
|
|---|
| 514 |
|
|---|
| 515 | DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2));
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 | /*************************************************************
|
|---|
| 519 | Copies a SAM_USER_INFO_25 to a struct samu
|
|---|
| 520 | **************************************************************/
|
|---|
| 521 |
|
|---|
| 522 | void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from)
|
|---|
| 523 | {
|
|---|
| 524 | time_t unix_time, stored_time;
|
|---|
| 525 | const char *old_string, *new_string;
|
|---|
| 526 | DATA_BLOB mung;
|
|---|
| 527 |
|
|---|
| 528 | if (from == NULL || to == NULL)
|
|---|
| 529 | return;
|
|---|
| 530 |
|
|---|
| 531 | if (from->fields_present & ACCT_LAST_LOGON) {
|
|---|
| 532 | unix_time=nt_time_to_unix(from->logon_time);
|
|---|
| 533 | stored_time = pdb_get_logon_time(to);
|
|---|
| 534 | DEBUG(10,("INFO_25 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 535 | if (stored_time != unix_time)
|
|---|
| 536 | pdb_set_logon_time(to, unix_time, PDB_CHANGED);
|
|---|
| 537 | }
|
|---|
| 538 |
|
|---|
| 539 | if (from->fields_present & ACCT_LAST_LOGOFF) {
|
|---|
| 540 | unix_time=nt_time_to_unix(from->logoff_time);
|
|---|
| 541 | stored_time = pdb_get_logoff_time(to);
|
|---|
| 542 | DEBUG(10,("INFO_25 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 543 | if (stored_time != unix_time)
|
|---|
| 544 | pdb_set_logoff_time(to, unix_time, PDB_CHANGED);
|
|---|
| 545 | }
|
|---|
| 546 |
|
|---|
| 547 | if (from->fields_present & ACCT_EXPIRY) {
|
|---|
| 548 | unix_time=nt_time_to_unix(from->kickoff_time);
|
|---|
| 549 | stored_time = pdb_get_kickoff_time(to);
|
|---|
| 550 | DEBUG(10,("INFO_25 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 551 | if (stored_time != unix_time)
|
|---|
| 552 | pdb_set_kickoff_time(to, unix_time , PDB_CHANGED);
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 | if (from->fields_present & ACCT_LAST_PWD_CHANGE) {
|
|---|
| 556 | unix_time=nt_time_to_unix(from->pass_last_set_time);
|
|---|
| 557 | stored_time = pdb_get_pass_last_set_time(to);
|
|---|
| 558 | DEBUG(10,("INFO_25 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
|
|---|
| 559 | if (stored_time != unix_time)
|
|---|
| 560 | pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED);
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | if ((from->fields_present & ACCT_USERNAME) &&
|
|---|
| 564 | (from->hdr_user_name.buffer)) {
|
|---|
| 565 | old_string = pdb_get_username(to);
|
|---|
| 566 | new_string = unistr2_static(&from->uni_user_name);
|
|---|
| 567 | DEBUG(10,("INFO_25 UNI_USER_NAME: %s -> %s\n", old_string, new_string));
|
|---|
| 568 | if (STRING_CHANGED)
|
|---|
| 569 | pdb_set_username(to , new_string, PDB_CHANGED);
|
|---|
| 570 | }
|
|---|
| 571 |
|
|---|
| 572 | if ((from->fields_present & ACCT_FULL_NAME) &&
|
|---|
| 573 | (from->hdr_full_name.buffer)) {
|
|---|
| 574 | old_string = pdb_get_fullname(to);
|
|---|
| 575 | new_string = unistr2_static(&from->uni_full_name);
|
|---|
| 576 | DEBUG(10,("INFO_25 UNI_FULL_NAME: %s -> %s\n",old_string, new_string));
|
|---|
| 577 | if (STRING_CHANGED)
|
|---|
| 578 | pdb_set_fullname(to , new_string, PDB_CHANGED);
|
|---|
| 579 | }
|
|---|
| 580 |
|
|---|
| 581 | if ((from->fields_present & ACCT_HOME_DIR) &&
|
|---|
| 582 | (from->hdr_home_dir.buffer)) {
|
|---|
| 583 | old_string = pdb_get_homedir(to);
|
|---|
| 584 | new_string = unistr2_static(&from->uni_home_dir);
|
|---|
| 585 | DEBUG(10,("INFO_25 UNI_HOME_DIR: %s -> %s\n",old_string,new_string));
|
|---|
| 586 | if (STRING_CHANGED)
|
|---|
| 587 | pdb_set_homedir(to , new_string, PDB_CHANGED);
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | if ((from->fields_present & ACCT_HOME_DRIVE) &&
|
|---|
| 591 | (from->hdr_dir_drive.buffer)) {
|
|---|
| 592 | old_string = pdb_get_dir_drive(to);
|
|---|
| 593 | new_string = unistr2_static(&from->uni_dir_drive);
|
|---|
| 594 | DEBUG(10,("INFO_25 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string));
|
|---|
| 595 | if (STRING_CHANGED)
|
|---|
| 596 | pdb_set_dir_drive(to , new_string, PDB_CHANGED);
|
|---|
| 597 | }
|
|---|
| 598 |
|
|---|
| 599 | if ((from->fields_present & ACCT_LOGON_SCRIPT) &&
|
|---|
| 600 | (from->hdr_logon_script.buffer)) {
|
|---|
| 601 | old_string = pdb_get_logon_script(to);
|
|---|
| 602 | new_string = unistr2_static(&from->uni_logon_script);
|
|---|
| 603 | DEBUG(10,("INFO_25 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string));
|
|---|
| 604 | if (STRING_CHANGED)
|
|---|
| 605 | pdb_set_logon_script(to , new_string, PDB_CHANGED);
|
|---|
| 606 | }
|
|---|
| 607 |
|
|---|
| 608 | if ((from->fields_present & ACCT_PROFILE) &&
|
|---|
| 609 | (from->hdr_profile_path.buffer)) {
|
|---|
| 610 | old_string = pdb_get_profile_path(to);
|
|---|
| 611 | new_string = unistr2_static(&from->uni_profile_path);
|
|---|
| 612 | DEBUG(10,("INFO_25 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string));
|
|---|
| 613 | if (STRING_CHANGED)
|
|---|
| 614 | pdb_set_profile_path(to , new_string, PDB_CHANGED);
|
|---|
| 615 | }
|
|---|
| 616 |
|
|---|
| 617 | if ((from->fields_present & ACCT_DESCRIPTION) &&
|
|---|
| 618 | (from->hdr_acct_desc.buffer)) {
|
|---|
| 619 | old_string = pdb_get_acct_desc(to);
|
|---|
| 620 | new_string = unistr2_static(&from->uni_acct_desc);
|
|---|
| 621 | DEBUG(10,("INFO_25 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string));
|
|---|
| 622 | if (STRING_CHANGED)
|
|---|
| 623 | pdb_set_acct_desc(to , new_string, PDB_CHANGED);
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | if ((from->fields_present & ACCT_WORKSTATIONS) &&
|
|---|
| 627 | (from->hdr_workstations.buffer)) {
|
|---|
| 628 | old_string = pdb_get_workstations(to);
|
|---|
| 629 | new_string = unistr2_static(&from->uni_workstations);
|
|---|
| 630 | DEBUG(10,("INFO_25 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string));
|
|---|
| 631 | if (STRING_CHANGED)
|
|---|
| 632 | pdb_set_workstations(to , new_string, PDB_CHANGED);
|
|---|
| 633 | }
|
|---|
| 634 |
|
|---|
| 635 | if ((from->fields_present & ACCT_COMMENT) &&
|
|---|
| 636 | (from->hdr_comment.buffer)) {
|
|---|
| 637 | old_string = pdb_get_comment(to);
|
|---|
| 638 | new_string = unistr2_static(&from->uni_comment);
|
|---|
| 639 | DEBUG(10,("INFO_25 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string));
|
|---|
| 640 | if (STRING_CHANGED)
|
|---|
| 641 | pdb_set_comment(to , new_string, PDB_CHANGED);
|
|---|
| 642 | }
|
|---|
| 643 |
|
|---|
| 644 | if ((from->fields_present & ACCT_CALLBACK) &&
|
|---|
| 645 | (from->hdr_munged_dial.buffer)) {
|
|---|
| 646 | char *newstr;
|
|---|
| 647 | old_string = pdb_get_munged_dial(to);
|
|---|
| 648 | mung.length = from->hdr_munged_dial.uni_str_len;
|
|---|
| 649 | mung.data = (uint8 *) from->uni_munged_dial.buffer;
|
|---|
| 650 | mung.free = NULL;
|
|---|
| 651 | newstr = (mung.length == 0) ?
|
|---|
| 652 | NULL : base64_encode_data_blob(mung);
|
|---|
| 653 | DEBUG(10,("INFO_25 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr));
|
|---|
| 654 | if (STRING_CHANGED_NC(old_string,newstr))
|
|---|
| 655 | pdb_set_munged_dial(to , newstr, PDB_CHANGED);
|
|---|
| 656 |
|
|---|
| 657 | SAFE_FREE(newstr);
|
|---|
| 658 | }
|
|---|
| 659 |
|
|---|
| 660 | if (from->fields_present & ACCT_RID) {
|
|---|
| 661 | if (from->user_rid == 0) {
|
|---|
| 662 | DEBUG(10, ("INFO_25: Asked to set User RID to 0 !? Skipping change!\n"));
|
|---|
| 663 | } else if (from->user_rid != pdb_get_user_rid(to)) {
|
|---|
| 664 | DEBUG(10,("INFO_25 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid));
|
|---|
| 665 | }
|
|---|
| 666 | }
|
|---|
| 667 |
|
|---|
| 668 | if (from->fields_present & ACCT_PRIMARY_GID) {
|
|---|
| 669 | if (from->group_rid == 0) {
|
|---|
| 670 | DEBUG(10, ("INFO_25: Asked to set Group RID to 0 !? Skipping change!\n"));
|
|---|
| 671 | } else if (from->group_rid != pdb_get_group_rid(to)) {
|
|---|
| 672 | DEBUG(10,("INFO_25 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid));
|
|---|
| 673 | pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED);
|
|---|
| 674 | }
|
|---|
| 675 | }
|
|---|
| 676 |
|
|---|
| 677 | if (from->fields_present & ACCT_FLAGS) {
|
|---|
| 678 | DEBUG(10,("INFO_25 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
|
|---|
| 679 | if (from->acb_info != pdb_get_acct_ctrl(to)) {
|
|---|
| 680 | if (!(from->acb_info & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) {
|
|---|
| 681 | /* We're unlocking a previously locked user. Reset bad password counts.
|
|---|
| 682 | Patch from Jianliang Lu. <[email protected]> */
|
|---|
| 683 | pdb_set_bad_password_count(to, 0, PDB_CHANGED);
|
|---|
| 684 | pdb_set_bad_password_time(to, 0, PDB_CHANGED);
|
|---|
| 685 | }
|
|---|
| 686 | pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED);
|
|---|
| 687 | }
|
|---|
| 688 | }
|
|---|
| 689 |
|
|---|
| 690 | if (from->fields_present & ACCT_LOGON_HOURS) {
|
|---|
| 691 | DEBUG(15,("INFO_25 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
|
|---|
| 692 | if (from->logon_divs != pdb_get_logon_divs(to)) {
|
|---|
| 693 | pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED);
|
|---|
| 694 | }
|
|---|
| 695 |
|
|---|
| 696 | DEBUG(15,("INFO_25 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
|
|---|
| 697 | if (from->logon_hrs.len != pdb_get_hours_len(to)) {
|
|---|
| 698 | pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED);
|
|---|
| 699 | }
|
|---|
| 700 |
|
|---|
| 701 | DEBUG(15,("INFO_25 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
|
|---|
| 702 | /* Fix me: only update if it changes --metze */
|
|---|
| 703 | pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
|
|---|
| 704 | }
|
|---|
| 705 |
|
|---|
| 706 | if (from->fields_present & ACCT_BAD_PWD_COUNT) {
|
|---|
| 707 | DEBUG(10,("INFO_25 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count));
|
|---|
| 708 | if (from->bad_password_count != pdb_get_bad_password_count(to)) {
|
|---|
| 709 | pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED);
|
|---|
| 710 | }
|
|---|
| 711 | }
|
|---|
| 712 |
|
|---|
| 713 | if (from->fields_present & ACCT_NUM_LOGONS) {
|
|---|
| 714 | DEBUG(10,("INFO_25 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count));
|
|---|
| 715 | if (from->logon_count != pdb_get_logon_count(to)) {
|
|---|
| 716 | pdb_set_logon_count(to, from->logon_count, PDB_CHANGED);
|
|---|
| 717 | }
|
|---|
| 718 | }
|
|---|
| 719 |
|
|---|
| 720 | /* If the must change flag is set, the last set time goes to zero.
|
|---|
| 721 | the must change and can change fields also do, but they are
|
|---|
| 722 | calculated from policy, not set from the wire */
|
|---|
| 723 |
|
|---|
| 724 | if (from->fields_present & ACCT_EXPIRED_FLAG) {
|
|---|
| 725 | DEBUG(10,("INFO_25 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
|
|---|
| 726 | if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) {
|
|---|
| 727 | pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
|
|---|
| 728 | } else {
|
|---|
| 729 | /* A subtlety here: some windows commands will
|
|---|
| 730 | clear the expired flag even though it's not
|
|---|
| 731 | set, and we don't want to reset the time
|
|---|
| 732 | in these caess. "net user /dom <user> /active:y"
|
|---|
| 733 | for example, to clear an autolocked acct.
|
|---|
| 734 | We must check to see if it's expired first. jmcd */
|
|---|
| 735 | stored_time = pdb_get_pass_last_set_time(to);
|
|---|
| 736 | if (stored_time == 0)
|
|---|
| 737 | pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED);
|
|---|
| 738 | }
|
|---|
| 739 | }
|
|---|
| 740 | }
|
|---|