summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorJim McDonough <jmcd@samba.org>2004-03-02 21:02:09 +0000
committerJim McDonough <jmcd@samba.org>2004-03-02 21:02:09 +0000
commit78b8f3ca0cfbbef0c8f02de20a65d5b89e0f760c (patch)
tree882ef49efb2f2e29173371f7aba8cb1a2ee3fa3f /source3/rpc_server
parent08d03a703957b90d194819799597ea87e2913a57 (diff)
downloadsamba-78b8f3ca0cfbbef0c8f02de20a65d5b89e0f760c.tar.gz
samba-78b8f3ca0cfbbef0c8f02de20a65d5b89e0f760c.tar.bz2
samba-78b8f3ca0cfbbef0c8f02de20a65d5b89e0f760c.zip
Merge fields_present function from HEAD. Now, a field will not be updated
on setuserinfo levels which include this field, unless the corresponding bit (defined in passdb.h) is turned on. Without this, newer versions of usrmgr break us pretty bad. (This used to be commit 840340bd96d3c6693b451bc61e155b7b426271e4)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_samr_util.c274
1 files changed, 158 insertions, 116 deletions
diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c
index 409fd8efab..c30cc3e77b 100644
--- a/source3/rpc_server/srv_samr_util.c
+++ b/source3/rpc_server/srv_samr_util.c
@@ -73,22 +73,24 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
if (from == NULL || to == NULL)
return;
- if (!nt_time_is_zero(&from->logon_time)) {
+
+ if (from->fields_present & ACCT_LAST_LOGON) {
unix_time=nt_time_to_unix(&from->logon_time);
stored_time = pdb_get_logon_time(to);
DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
pdb_set_logon_time(to, unix_time, PDB_CHANGED);
- }
- if (!nt_time_is_zero(&from->logoff_time)) {
+ }
+
+ if (from->fields_present & ACCT_LAST_LOGOFF) {
unix_time=nt_time_to_unix(&from->logoff_time);
stored_time = pdb_get_logoff_time(to);
DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
pdb_set_logoff_time(to, unix_time, PDB_CHANGED);
}
-
- if (!nt_time_is_zero(&from->kickoff_time)) {
+
+ if (from->fields_present & ACCT_EXPIRY) {
unix_time=nt_time_to_unix(&from->kickoff_time);
stored_time = pdb_get_kickoff_time(to);
DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
@@ -96,14 +98,15 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_kickoff_time(to, unix_time , PDB_CHANGED);
}
- if (!nt_time_is_zero(&from->pass_can_change_time)) {
+ if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) {
unix_time=nt_time_to_unix(&from->pass_can_change_time);
stored_time = pdb_get_pass_can_change_time(to);
DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED);
}
- if (!nt_time_is_zero(&from->pass_last_set_time)) {
+
+ if (from->fields_present & ACCT_LAST_PWD_CHANGE) {
unix_time=nt_time_to_unix(&from->pass_last_set_time);
stored_time = pdb_get_pass_last_set_time(to);
DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
@@ -111,7 +114,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED);
}
- if (!nt_time_is_zero(&from->pass_must_change_time)) {
+ if (from->fields_present & ACCT_FORCE_PWD_CHANGE) {
unix_time=nt_time_to_unix(&from->pass_must_change_time);
stored_time=pdb_get_pass_must_change_time(to);
DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
@@ -119,8 +122,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED);
}
- /* Backend should check this for sainity */
- if (from->hdr_user_name.buffer) {
+ if ((from->fields_present & ACCT_USERNAME) &&
+ (from->hdr_user_name.buffer)) {
old_string = pdb_get_username(to);
new_string = unistr2_static(&from->uni_user_name);
DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string));
@@ -128,7 +131,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_username(to , new_string, PDB_CHANGED);
}
- if (from->hdr_full_name.buffer) {
+ if ((from->fields_present & ACCT_FULL_NAME) &&
+ (from->hdr_full_name.buffer)) {
old_string = pdb_get_fullname(to);
new_string = unistr2_static(&from->uni_full_name);
DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string));
@@ -136,7 +140,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_fullname(to , new_string, PDB_CHANGED);
}
- if (from->hdr_home_dir.buffer) {
+ if ((from->fields_present & ACCT_HOME_DIR) &&
+ (from->hdr_home_dir.buffer)) {
old_string = pdb_get_homedir(to);
new_string = unistr2_static(&from->uni_home_dir);
DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string));
@@ -144,7 +149,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_homedir(to , new_string, PDB_CHANGED);
}
- if (from->hdr_dir_drive.buffer) {
+ if ((from->fields_present & ACCT_HOME_DRIVE) &&
+ (from->hdr_dir_drive.buffer)) {
old_string = pdb_get_dir_drive(to);
new_string = unistr2_static(&from->uni_dir_drive);
DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string));
@@ -152,7 +158,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_dir_drive(to , new_string, PDB_CHANGED);
}
- if (from->hdr_logon_script.buffer) {
+ if ((from->fields_present & ACCT_LOGON_SCRIPT) &&
+ (from->hdr_logon_script.buffer)) {
old_string = pdb_get_logon_script(to);
new_string = unistr2_static(&from->uni_logon_script);
DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string));
@@ -160,7 +167,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_logon_script(to , new_string, PDB_CHANGED);
}
- if (from->hdr_profile_path.buffer) {
+ if ((from->fields_present & ACCT_PROFILE) &&
+ (from->hdr_profile_path.buffer)) {
old_string = pdb_get_profile_path(to);
new_string = unistr2_static(&from->uni_profile_path);
DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string));
@@ -168,7 +176,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_profile_path(to , new_string, PDB_CHANGED);
}
- if (from->hdr_acct_desc.buffer) {
+ if ((from->fields_present & ACCT_DESCRIPTION) &&
+ (from->hdr_acct_desc.buffer)) {
old_string = pdb_get_acct_desc(to);
new_string = unistr2_static(&from->uni_acct_desc);
DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string));
@@ -176,7 +185,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_acct_desc(to , new_string, PDB_CHANGED);
}
- if (from->hdr_workstations.buffer) {
+ if ((from->fields_present & ACCT_WORKSTATIONS) &&
+ (from->hdr_workstations.buffer)) {
old_string = pdb_get_workstations(to);
new_string = unistr2_static(&from->uni_workstations);
DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string));
@@ -184,7 +194,9 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_workstations(to , new_string, PDB_CHANGED);
}
- if (from->hdr_unknown_str.buffer) {
+ /* is this right? */
+ if ((from->fields_present & ACCT_ADMIN_DESC) &&
+ (from->hdr_unknown_str.buffer)) {
old_string = pdb_get_unknown_str(to);
new_string = unistr2_static(&from->uni_unknown_str);
DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string));
@@ -192,7 +204,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
pdb_set_unknown_str(to , new_string, PDB_CHANGED);
}
- if (from->hdr_munged_dial.buffer) {
+ if ((from->fields_present & ACCT_CALLBACK) &&
+ (from->hdr_munged_dial.buffer)) {
char *newstr;
old_string = pdb_get_munged_dial(to);
mung.length = from->hdr_munged_dial.uni_str_len;
@@ -205,59 +218,66 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
SAFE_FREE(newstr);
}
- if (from->user_rid == 0) {
- DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n"));
- } else if (from->user_rid != pdb_get_user_rid(to)) {
- DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid));
- /* we really allow this ??? metze */
- /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/
+ if (from->fields_present & ACCT_RID) {
+ if (from->user_rid == 0) {
+ DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n"));
+ } else if (from->user_rid != pdb_get_user_rid(to)) {
+ DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid));
+ }
}
- if (from->group_rid == 0) {
- DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n"));
- } else if (from->group_rid != pdb_get_group_rid(to)) {
- DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid));
- pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED);
+ if (from->fields_present & ACCT_PRIMARY_GID) {
+ if (from->group_rid == 0) {
+ DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n"));
+ } else if (from->group_rid != pdb_get_group_rid(to)) {
+ DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid));
+ pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED);
+ }
}
- DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
- if (from->acb_info != pdb_get_acct_ctrl(to)) {
- pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED);
+ if (from->fields_present & ACCT_FLAGS) {
+ DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
+ if (from->acb_info != pdb_get_acct_ctrl(to)) {
+ pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED);
+ }
}
- DEBUG(10,("INFO_21 FIELDS_PRESENT: %08X -> %08X\n",pdb_get_fields_present(to),from->fields_present));
- if (from->fields_present != pdb_get_fields_present(to)) {
- pdb_set_fields_present(to, from->fields_present, PDB_CHANGED);
- }
+ if (from->fields_present & ACCT_LOGON_HOURS) {
+ DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
+ if (from->logon_divs != pdb_get_logon_divs(to)) {
+ pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED);
+ }
- DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
- if (from->logon_divs != pdb_get_logon_divs(to)) {
- pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED);
- }
+ DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
+ if (from->logon_hrs.len != pdb_get_hours_len(to)) {
+ pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED);
+ }
- DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
- if (from->logon_hrs.len != pdb_get_hours_len(to)) {
- pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED);
+ DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
+ /* Fix me: only update if it changes --metze */
+ pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
}
- DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
-/* Fix me: only update if it changes --metze */
- pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
-
- DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count));
- if (from->bad_password_count != pdb_get_bad_password_count(to)) {
- pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED);
+ if (from->fields_present & ACCT_BAD_PWD_COUNT) {
+ DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count));
+ if (from->bad_password_count != pdb_get_bad_password_count(to)) {
+ pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED);
+ }
}
- DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count));
- if (from->logon_count != pdb_get_logon_count(to)) {
- pdb_set_logon_count(to, from->logon_count, PDB_CHANGED);
+ if (from->fields_present & ACCT_NUM_LOGONS) {
+ DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count));
+ if (from->logon_count != pdb_get_logon_count(to)) {
+ pdb_set_logon_count(to, from->logon_count, PDB_CHANGED);
+ }
}
- DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6));
- if (from->unknown_6 != pdb_get_unknown_6(to)) {
- pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED);
- }
+ /* if (from->fields_present & ACCT_??) { */
+ DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6));
+ if (from->unknown_6 != pdb_get_unknown_6(to)) {
+ pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED);
+ }
+ /* } */
DEBUG(10,("INFO_21 PADDING1 %02X %02X %02X %02X %02X %02X\n",
from->padding1[0],
@@ -290,14 +310,16 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
if (from == NULL || to == NULL)
return;
- if (!nt_time_is_zero(&from->logon_time)) {
+
+ if (from->fields_present & ACCT_LAST_LOGON) {
unix_time=nt_time_to_unix(&from->logon_time);
stored_time = pdb_get_logon_time(to);
DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
pdb_set_logon_time(to, unix_time, PDB_CHANGED);
- }
- if (!nt_time_is_zero(&from->logoff_time)) {
+ }
+
+ if (from->fields_present & ACCT_LAST_LOGOFF) {
unix_time=nt_time_to_unix(&from->logoff_time);
stored_time = pdb_get_logoff_time(to);
DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
@@ -305,7 +327,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_logoff_time(to, unix_time, PDB_CHANGED);
}
- if (!nt_time_is_zero(&from->kickoff_time)) {
+ if (from->fields_present & ACCT_EXPIRY) {
unix_time=nt_time_to_unix(&from->kickoff_time);
stored_time = pdb_get_kickoff_time(to);
DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
@@ -313,14 +335,15 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_kickoff_time(to, unix_time , PDB_CHANGED);
}
- if (!nt_time_is_zero(&from->pass_can_change_time)) {
+ if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) {
unix_time=nt_time_to_unix(&from->pass_can_change_time);
stored_time = pdb_get_pass_can_change_time(to);
DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
if (stored_time != unix_time)
pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED);
}
- if (!nt_time_is_zero(&from->pass_last_set_time)) {
+
+ if (from->fields_present & ACCT_LAST_PWD_CHANGE) {
unix_time=nt_time_to_unix(&from->pass_last_set_time);
stored_time = pdb_get_pass_last_set_time(to);
DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
@@ -328,7 +351,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED);
}
- if (!nt_time_is_zero(&from->pass_must_change_time)) {
+ if (from->fields_present & ACCT_FORCE_PWD_CHANGE) {
unix_time=nt_time_to_unix(&from->pass_must_change_time);
stored_time=pdb_get_pass_must_change_time(to);
DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time));
@@ -336,8 +359,9 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED);
}
- /* Backend should check this for sainity */
- if (from->hdr_user_name.buffer) {
+ /* Backend should check this for sanity */
+ if ((from->fields_present & ACCT_USERNAME) &&
+ (from->hdr_user_name.buffer)) {
old_string = pdb_get_username(to);
new_string = unistr2_static(&from->uni_user_name);
DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string));
@@ -345,7 +369,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_username(to , new_string, PDB_CHANGED);
}
- if (from->hdr_full_name.buffer) {
+ if ((from->fields_present & ACCT_FULL_NAME) &&
+ (from->hdr_full_name.buffer)) {
old_string = pdb_get_fullname(to);
new_string = unistr2_static(&from->uni_full_name);
DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string));
@@ -353,7 +378,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_fullname(to , new_string, PDB_CHANGED);
}
- if (from->hdr_home_dir.buffer) {
+ if ((from->fields_present & ACCT_HOME_DIR) &&
+ (from->hdr_home_dir.buffer)) {
old_string = pdb_get_homedir(to);
new_string = unistr2_static(&from->uni_home_dir);
DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string));
@@ -361,7 +387,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_homedir(to , new_string, PDB_CHANGED);
}
- if (from->hdr_dir_drive.buffer) {
+ if ((from->fields_present & ACCT_HOME_DRIVE) &&
+ (from->hdr_dir_drive.buffer)) {
old_string = pdb_get_dir_drive(to);
new_string = unistr2_static(&from->uni_dir_drive);
DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string));
@@ -369,7 +396,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_dir_drive(to , new_string, PDB_CHANGED);
}
- if (from->hdr_logon_script.buffer) {
+ if ((from->fields_present & ACCT_LOGON_SCRIPT) &&
+ (from->hdr_logon_script.buffer)) {
old_string = pdb_get_logon_script(to);
new_string = unistr2_static(&from->uni_logon_script);
DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string));
@@ -377,7 +405,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_logon_script(to , new_string, PDB_CHANGED);
}
- if (from->hdr_profile_path.buffer) {
+ if ((from->fields_present & ACCT_PROFILE) &&
+ (from->hdr_profile_path.buffer)) {
old_string = pdb_get_profile_path(to);
new_string = unistr2_static(&from->uni_profile_path);
DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string));
@@ -385,7 +414,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_profile_path(to , new_string, PDB_CHANGED);
}
- if (from->hdr_acct_desc.buffer) {
+ if ((from->fields_present & ACCT_DESCRIPTION) &&
+ (from->hdr_acct_desc.buffer)) {
old_string = pdb_get_acct_desc(to);
new_string = unistr2_static(&from->uni_acct_desc);
DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string));
@@ -393,7 +423,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_acct_desc(to , new_string, PDB_CHANGED);
}
- if (from->hdr_workstations.buffer) {
+ if ((from->fields_present & ACCT_WORKSTATIONS) &&
+ (from->hdr_workstations.buffer)) {
old_string = pdb_get_workstations(to);
new_string = unistr2_static(&from->uni_workstations);
DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string));
@@ -401,7 +432,9 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_workstations(to , new_string, PDB_CHANGED);
}
- if (from->hdr_unknown_str.buffer) {
+ /* is this right? */
+ if ((from->fields_present & ACCT_ADMIN_DESC) &&
+ (from->hdr_unknown_str.buffer)) {
old_string = pdb_get_unknown_str(to);
new_string = unistr2_static(&from->uni_unknown_str);
DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string));
@@ -409,7 +442,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
pdb_set_unknown_str(to , new_string, PDB_CHANGED);
}
- if (from->hdr_munged_dial.buffer) {
+ if ((from->fields_present & ACCT_CALLBACK) &&
+ (from->hdr_munged_dial.buffer)) {
char *newstr;
old_string = pdb_get_munged_dial(to);
mung.length = from->hdr_munged_dial.uni_str_len;
@@ -422,58 +456,66 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
SAFE_FREE(newstr);
}
- if (from->user_rid == 0) {
- DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n"));
- } else if (from->user_rid != pdb_get_user_rid(to)) {
- DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid));
- /* we really allow this ??? metze */
- /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/
- }
- if (from->group_rid == 0) {
- DEBUG(10, ("INFO_23: Asked to set Group RID to 0 !? Skipping change!\n"));
- } else if (from->group_rid != pdb_get_group_rid(to)) {
- DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid));
- pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED);
+ if (from->fields_present & ACCT_RID) {
+ if (from->user_rid == 0) {
+ DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n"));
+ } else if (from->user_rid != pdb_get_user_rid(to)) {
+ DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid));
+ }
+ }
+
+ if (from->fields_present & ACCT_PRIMARY_GID) {
+ if (from->group_rid == 0) {
+ DEBUG(10, ("INFO_23: Asked to set Group RID to 0 !? Skipping change!\n"));
+ } else if (from->group_rid != pdb_get_group_rid(to)) {
+ DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid));
+ pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED);
+ }
}
- DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
- if (from->acb_info != pdb_get_acct_ctrl(to)) {
- pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED);
+ if (from->fields_present & ACCT_FLAGS) {
+ DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
+ if (from->acb_info != pdb_get_acct_ctrl(to)) {
+ pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED);
+ }
}
- DEBUG(10,("INFO_23 FIELDS_PRESENT: %08X -> %08X\n",pdb_get_fields_present(to),from->fields_present));
- if (from->fields_present != pdb_get_fields_present(to)) {
- pdb_set_fields_present(to, from->fields_present, PDB_CHANGED);
- }
+ if (from->fields_present & ACCT_LOGON_HOURS) {
+ DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
+ if (from->logon_divs != pdb_get_logon_divs(to)) {
+ pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED);
+ }
- DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
- if (from->logon_divs != pdb_get_logon_divs(to)) {
- pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED);
- }
+ DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
+ if (from->logon_hrs.len != pdb_get_hours_len(to)) {
+ pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED);
+ }
- DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
- if (from->logon_hrs.len != pdb_get_hours_len(to)) {
- pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED);
+ DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
+ /* Fix me: only update if it changes --metze */
+ pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
}
- DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
-/* Fix me: only update if it changes --metze */
- pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED);
-
- DEBUG(10,("INFO_23 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count));
- if (from->bad_password_count != pdb_get_bad_password_count(to)) {
- pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED);
+ if (from->fields_present & ACCT_BAD_PWD_COUNT) {
+ DEBUG(10,("INFO_23 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count));
+ if (from->bad_password_count != pdb_get_bad_password_count(to)) {
+ pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED);
+ }
}
- DEBUG(10,("INFO_23 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count));
- if (from->logon_count != pdb_get_logon_count(to)) {
- pdb_set_logon_count(to, from->logon_count, PDB_CHANGED);
+ if (from->fields_present & ACCT_NUM_LOGONS) {
+ DEBUG(10,("INFO_23 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count));
+ if (from->logon_count != pdb_get_logon_count(to)) {
+ pdb_set_logon_count(to, from->logon_count, PDB_CHANGED);
+ }
}
- DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6));
- if (from->unknown_6 != pdb_get_unknown_6(to)) {
- pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED);
- }
+ /* if (from->fields_present & ACCT_??) { */
+ DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6));
+ if (from->unknown_6 != pdb_get_unknown_6(to)) {
+ pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED);
+ }
+ /* } */
DEBUG(10,("INFO_23 PADDING1 %02X %02X %02X %02X %02X %02X\n",
from->padding1[0],