[PATCH] copy_id2X_to_sam_passwd
Stefan (metze) Metzmacher
metze at metzemix.de
Thu Jun 27 07:14:04 GMT 2002
Hi Andrew,
this patch handles the use of usrmgr.exe much better...
I'm not shure about the debuglevels
metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <metze at metzemix.de>
-------------- next part --------------
diff -Npur --exclude=CVS HEAD/source/passdb/passdb.c HEAD-fix/source/passdb/passdb.c
--- HEAD/source/passdb/passdb.c Fri Jun 14 09:20:58 2002
+++ HEAD-fix/source/passdb/passdb.c Thu Jun 27 16:04:56 2002
@@ -942,53 +942,155 @@ const char *pdb_unistr2_convert(const UN
void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
{
+ time_t time;
if (from == NULL || to == NULL)
return;
- pdb_set_logon_time(to,nt_time_to_unix(&from->logon_time), True);
- pdb_set_logoff_time(to,nt_time_to_unix(&from->logoff_time), True);
- pdb_set_kickoff_time(to, nt_time_to_unix(&from->kickoff_time), True);
- pdb_set_pass_can_change_time(to, nt_time_to_unix(&from->pass_can_change_time), True);
- pdb_set_pass_must_change_time(to, nt_time_to_unix(&from->pass_must_change_time), True);
-
- pdb_set_pass_last_set_time(to, nt_time_to_unix(&from->pass_last_set_time));
-
- if (from->uni_user_name.buffer)
+ if ((time=nt_time_to_unix(&from->logon_time))>0) {
+ DEBUG(10,("INFO_23 LOGON_TIME: %d -> %d\n",pdb_get_logon_time(to),time));
+ pdb_set_logon_time(to, time, True);
+ }
+ if ((time=nt_time_to_unix(&from->logoff_time))>0) {
+ DEBUG(10,("INFO_23 LOGOFF_TIME: %d -> %d\n",pdb_get_logoff_time(to),time));
+ pdb_set_logoff_time(to, time, True);
+ }
+ if ((time=nt_time_to_unix(&from->kickoff_time))>0) {
+ DEBUG(10,("INFO_23 KICKOFF_TIME: %d -> %d\n",pdb_get_kickoff_time(to),from->kickoff_time));
+ pdb_set_kickoff_time(to, time , True);
+ }
+ if ((time=nt_time_to_unix(&from->pass_can_change_time))>0) {
+ DEBUG(10,("INFO_23 PASS_CAN_CH: %d -> %d\n",pdb_get_pass_can_change_time(to),from->pass_can_change_time));
+ pdb_set_pass_can_change_time(to, time, True);
+ }
+ /* I'm not sure about pass_must_change_time,
+ because there's no differenz when the
+ MustChangePassword at next Logon is checked or not:
+ nt_time_to_unix == 0 in any case :-( metze
+ */
+ /* In INFO_23 the passwd is changed by the admin:
+ -> we rely on the value catched from usrmgr.exe
+ */
+ /*if ((*/time=nt_time_to_unix(&from->pass_must_change_time)/*)>0)*/;{
+ DEBUG(10,("INFO_23 PASS_MUST_CH: %d -> %d\n",pdb_get_pass_must_change_time(to),time));
+ pdb_set_pass_must_change_time(to, time, True);
+ }
+ if ((time=nt_time_to_unix(&from->pass_last_set_time))>0) {
+ DEBUG(10,("INFO_23 PASS_LAST_SET: %d -> %d\n",pdb_get_pass_last_set_time(to),time));
+ pdb_set_pass_last_set_time(to, time);
+ }
+ /* TODO: check if the new user name doesn't exist */
+ if (from->uni_user_name.buffer) {
+ DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n",pdb_get_username(to),pdb_unistr2_convert(&from->uni_user_name)));
pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name ));
- if (from->uni_full_name.buffer)
+ }
+
+ /* TODO: updating the empty string should be handle by the pdb backend
+ */
+ if (from->uni_full_name.buffer) {
+ DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",pdb_get_fullname(to),pdb_unistr2_convert(&from->uni_user_name)));
pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name ));
- if (from->uni_home_dir.buffer)
+ } else{
+ DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",pdb_get_fullname(to),""));
+ pdb_set_fullname(to , "\0");
+ }
+
+ if (from->uni_home_dir.buffer) {
+ DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",pdb_get_homedir(to),pdb_unistr2_convert(&from->uni_home_dir)));
pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True);
- if (from->uni_dir_drive.buffer)
+ } else{
+ DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",pdb_get_homedir(to),""));
+ pdb_set_homedir(to , "\0", True);
+ }
+
+ if (from->uni_dir_drive.buffer) {
+ DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",pdb_get_dirdrive(to),pdb_unistr2_convert(&from->uni_dir_drive)));
pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True);
- if (from->uni_logon_script.buffer)
+ } else {
+ DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",pdb_get_dirdrive(to),""));
+ pdb_set_dir_drive(to , "\0", True);
+ }
+
+ if (from->uni_logon_script.buffer) {
+ DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",pdb_get_logon_script(to),pdb_unistr2_convert(&from->uni_logon_script)));
pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True);
- if (from->uni_profile_path.buffer)
+ } else {
+ DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",pdb_get_logon_script(to),""));
+ pdb_set_logon_script(to , "\0", True);
+ }
+
+ if (from->uni_profile_path.buffer) {
+ DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",pdb_get_profile_path(to),pdb_unistr2_convert(&from->uni_profile_path)));
pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True);
- if (from->uni_acct_desc.buffer)
+ } else {
+ DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",pdb_get_profile_path(to),""));
+ pdb_set_profile_path(to , "\0", True);
+ }
+
+ if (from->uni_acct_desc.buffer) {
+ DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",pdb_get_acct_desc(to),pdb_unistr2_convert(&from->uni_acct_desc)));
pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc ));
- if (from->uni_workstations.buffer)
+ } else {
+ DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",pdb_get_acct_desc(to),""));
+ pdb_set_acct_desc(to , "\0");
+ }
+
+ if (from->uni_workstations.buffer) {
+ DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",pdb_get_workstations(to),pdb_unistr2_convert(&from->uni_workstations)));
pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations));
- if (from->uni_unknown_str.buffer)
+ } else {
+ DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",pdb_get_workstations(to),""));
+ pdb_set_workstations(to , "\0");
+ }
+
+ if (from->uni_unknown_str.buffer) {
+ DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",pdb_get_unknown_str(to),pdb_unistr2_convert(&from->uni_unknown_str)));
pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str ));
- if (from->uni_munged_dial.buffer)
+ } else {
+ DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",pdb_get_unknown_str(to),""));
+ pdb_set_unknown_str(to , "\0");
+ }
+
+ if (from->uni_munged_dial.buffer) {
+ DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",pdb_get_munged_dial(to),pdb_unistr2_convert(&from->uni_munged_dial)));
pdb_set_munged_dial(to , pdb_unistr2_convert(&from->uni_munged_dial ));
-
- if (from->user_rid)
- pdb_set_user_sid_from_rid(to, from->user_rid);
- if (from->group_rid)
+ } else {
+ DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",pdb_get_munged_dial(to),""));
+ pdb_set_munged_dial(to , "\0");
+ }
+
+ if (from->user_rid) {
+ DEBUG(10,("INFO_23 USER_RID: %d -> %d 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);*/
+ }
+
+ if (from->group_rid) {
+ DEBUG(10,("INFO_23 GROUP_RID: %d -> %d\n",pdb_get_group_rid(to),from->group_rid));
pdb_set_group_sid_from_rid(to, from->group_rid);
-
+ }
+
+ DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
pdb_set_acct_ctrl(to, from->acb_info);
+
+ DEBUG(10,("INFO_23 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3));
pdb_set_unknown_3(to, from->unknown_3);
+
+ DEBUG(10,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
pdb_set_logon_divs(to, from->logon_divs);
+
+ DEBUG(10,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
pdb_set_hours_len(to, from->logon_hrs.len);
+ DEBUG(10,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
pdb_set_hours(to, from->logon_hrs.hours);
+ DEBUG(10,("INFO_23 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5));
pdb_set_unknown_5(to, from->unknown_5);
+
+ DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6));
pdb_set_unknown_6(to, from->unknown_6);
+
}
@@ -998,57 +1100,156 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT
void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
{
+ time_t time;
+
if (from == NULL || to == NULL)
return;
- pdb_set_logon_time(to,nt_time_to_unix(&from->logon_time), True);
- pdb_set_logoff_time(to,nt_time_to_unix(&from->logoff_time), True);
- pdb_set_kickoff_time(to, nt_time_to_unix(&from->kickoff_time), True);
- pdb_set_pass_can_change_time(to, nt_time_to_unix(&from->pass_can_change_time), True);
- pdb_set_pass_must_change_time(to, nt_time_to_unix(&from->pass_must_change_time), True);
-
- pdb_set_pass_last_set_time(to, nt_time_to_unix(&from->pass_last_set_time));
-
- if (from->uni_user_name.buffer)
+ if ((time=nt_time_to_unix(&from->logon_time))>0) {
+ DEBUG(10,("INFO_21 LOGON_TIME: %d -> %d\n",pdb_get_logon_time(to),time));
+ pdb_set_logon_time(to,time, True);
+ }
+ if ((time=nt_time_to_unix(&from->logoff_time))>0) {
+ DEBUG(10,("INFO_21 LOGOFF_TIME: %d -> %d\n",pdb_get_logoff_time(to),time));
+ pdb_set_logoff_time(to,time, True);
+ }
+ if ((time=nt_time_to_unix(&from->kickoff_time))>0) {
+ DEBUG(10,("INFO_21 KICKOFF_TIME: %d -> %d\n",pdb_get_kickoff_time(to),from->kickoff_time));
+ pdb_set_kickoff_time(to,time , True);
+ }
+ if ((time=nt_time_to_unix(&from->pass_can_change_time))>0) {
+ DEBUG(10,("INFO_21 PASS_CAN_CH: %d -> %d\n",pdb_get_pass_can_change_time(to),from->pass_can_change_time));
+ pdb_set_pass_can_change_time(to, time, True);
+ }
+ /* I'm not sure about pass_must_change_time,
+ because there's no differenz when the
+ MustChangePassword at next Logon is checked or not:
+ nt_time_to_unix == 0 in any case :-( metze
+ */
+ if ((time=nt_time_to_unix(&from->pass_must_change_time))>0){
+ DEBUG(10,("INFO_21 PASS_MUST_CH: %u -> %u\n",pdb_get_pass_must_change_time(to),time));
+ pdb_set_pass_must_change_time(to, time, True);
+ }
+ if ((time=nt_time_to_unix(&from->pass_last_set_time))>0) {
+ DEBUG(10,("INFO_21 PASS_LAST_SET: %u -> %u\n",pdb_get_pass_last_set_time(to),time));
+ pdb_set_pass_last_set_time(to, time);
+ }
+ /* TODO: check if the new user name doesn't exist */
+ if (from->uni_user_name.buffer) {
+ DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n",pdb_get_username(to),pdb_unistr2_convert(&from->uni_user_name)));
pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name ));
- if (from->uni_full_name.buffer)
+ }
+
+ /* TODO: updating the empty string should be handle by the pdb backend
+ */
+ if (from->uni_full_name.buffer) {
+ DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",pdb_get_fullname(to),pdb_unistr2_convert(&from->uni_user_name)));
pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name ));
- if (from->uni_home_dir.buffer)
+ } else{
+ DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",pdb_get_fullname(to),""));
+ pdb_set_fullname(to , "\0");
+ }
+
+ if (from->uni_home_dir.buffer) {
+ DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",pdb_get_homedir(to),pdb_unistr2_convert(&from->uni_home_dir)));
pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True);
- if (from->uni_dir_drive.buffer)
+ } else{
+ DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",pdb_get_homedir(to),""));
+ pdb_set_homedir(to , "\0", True);
+ }
+
+ if (from->uni_dir_drive.buffer) {
+ DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",pdb_get_dirdrive(to),pdb_unistr2_convert(&from->uni_dir_drive)));
pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True);
- if (from->uni_logon_script.buffer)
+ } else {
+ DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",pdb_get_dirdrive(to),""));
+ pdb_set_dir_drive(to , "\0", True);
+ }
+
+ if (from->uni_logon_script.buffer) {
+ DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",pdb_get_logon_script(to),pdb_unistr2_convert(&from->uni_logon_script)));
pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True);
- if (from->uni_profile_path.buffer)
+ } else {
+ DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",pdb_get_logon_script(to),""));
+ pdb_set_logon_script(to , "\0", True);
+ }
+
+ if (from->uni_profile_path.buffer) {
+ DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",pdb_get_profile_path(to),pdb_unistr2_convert(&from->uni_profile_path)));
pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True);
- if (from->uni_acct_desc.buffer)
+ } else {
+ DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",pdb_get_profile_path(to),""));
+ pdb_set_profile_path(to , "\0", True);
+ }
+
+ if (from->uni_acct_desc.buffer) {
+ DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",pdb_get_acct_desc(to),pdb_unistr2_convert(&from->uni_acct_desc)));
pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc ));
- if (from->uni_workstations.buffer)
+ } else {
+ DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",pdb_get_acct_desc(to),""));
+ pdb_set_acct_desc(to , "\0");
+ }
+
+ if (from->uni_workstations.buffer) {
+ DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",pdb_get_workstations(to),pdb_unistr2_convert(&from->uni_workstations)));
pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations));
- if (from->uni_unknown_str.buffer)
+ } else {
+ DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",pdb_get_workstations(to),""));
+ pdb_set_workstations(to , "\0");
+ }
+
+ if (from->uni_unknown_str.buffer) {
+ DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",pdb_get_unknown_str(to),pdb_unistr2_convert(&from->uni_unknown_str)));
pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str ));
- if (from->uni_munged_dial.buffer)
+ } else {
+ DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",pdb_get_unknown_str(to),""));
+ pdb_set_unknown_str(to , "\0");
+ }
+
+ if (from->uni_munged_dial.buffer) {
+ DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",pdb_get_munged_dial(to),pdb_unistr2_convert(&from->uni_munged_dial)));
pdb_set_munged_dial(to , pdb_unistr2_convert(&from->uni_munged_dial ));
-
- if (from->user_rid)
- pdb_set_user_sid_from_rid(to, from->user_rid);
- if (from->group_rid)
+ } else {
+ DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",pdb_get_munged_dial(to),""));
+ pdb_set_munged_dial(to , "\0");
+ }
+
+ if (from->user_rid) {
+ DEBUG(10,("INFO_21 USER_RID: %d -> %d 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);*/
+ }
+
+ if (from->group_rid) {
+ DEBUG(10,("INFO_21 GROUP_RID: %d -> %d\n",pdb_get_group_rid(to),from->group_rid));
pdb_set_group_sid_from_rid(to, from->group_rid);
-
- /* FIXME!! Do we need to copy the passwords here as well?
- I don't know. Need to figure this out --jerry */
-
- /* Passwords dealt with in caller --abartlet */
-
+ }
+
+ DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info));
pdb_set_acct_ctrl(to, from->acb_info);
+
+ DEBUG(10,("INFO_21 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3));
pdb_set_unknown_3(to, from->unknown_3);
+
+ DEBUG(10,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
pdb_set_logon_divs(to, from->logon_divs);
+
+ DEBUG(10,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len));
pdb_set_hours_len(to, from->logon_hrs.len);
+ DEBUG(10,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours));
pdb_set_hours(to, from->logon_hrs.hours);
+ DEBUG(10,("INFO_21 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5));
pdb_set_unknown_5(to, from->unknown_5);
+
+ DEBUG(10,("INFO_21 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6));
pdb_set_unknown_6(to, from->unknown_6);
+
+ /* FIXME!! Do we need to copy the passwords here as well?
+ I don't know. Need to figure this out --jerry */
+
+ /* Passwords dealt with in caller --abartlet */
}
More information about the samba-technical
mailing list