summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-09-26 10:25:34 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-09-26 10:25:34 +0000
commitad514000db54b887c5c0f8734415e2b10698b365 (patch)
tree5bd885d043786d2e8bef317c10adb54c13c835cb /source3
parent9e70b39ab29b877906ca3e20bc25700c2e05ae1b (diff)
downloadsamba-ad514000db54b887c5c0f8734415e2b10698b365.tar.gz
samba-ad514000db54b887c5c0f8734415e2b10698b365.tar.bz2
samba-ad514000db54b887c5c0f8734415e2b10698b365.zip
Patch from "Stefan (metze) Metzmacher" <metze@metzemix.de> to do a *much*
better job of working with usrmgr. Previously we were blanking out entires, and all sort of mischif. The new patch (which I've now had a chance to test/modify) also takes care not to expand % values (ie we go \\%L\%U -> \\server\user, we don't want to store \\server\user back) and to correctly notice 'not set' compared to 'null string' etc. Andrew Bartlett (This used to be commit ab878b6cc4132594fc33f78aeebf0d8b7266c150)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/rpc_samr.h19
-rw-r--r--source3/lib/time.c14
-rw-r--r--source3/passdb/passdb.c2
-rw-r--r--source3/rpc_parse/parse_samr.c45
-rw-r--r--source3/rpc_server/srv_samr_nt.c4
-rw-r--r--source3/rpc_server/srv_samr_util.c420
6 files changed, 419 insertions, 85 deletions
diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h
index 11438ae067..72c65ebfb7 100644
--- a/source3/include/rpc_samr.h
+++ b/source3/include/rpc_samr.h
@@ -314,6 +314,9 @@ SamrTestPrivateFunctionsUser
#define ALIAS_EXECUTE ( STANDARD_RIGHTS_EXECUTE_ACCESS | \
ALIAS_ACCESS_LOOKUP_INFO )
+/* A flag for the user info 21 and 23 structs */
+#define PASS_MUST_CHANGE_AT_NEXT_LOGON 1
+
typedef struct _DISP_USER_INFO {
SAM_ACCOUNT *sam;
} DISP_USER_INFO;
@@ -366,10 +369,14 @@ typedef struct sam_user_info_23
/* uint8 pad[2] */
uint32 ptr_logon_hrs; /* pointer to logon hours */
- uint8 padding1[8];
-
uint32 unknown_5; /* 0x0001 0000 */
+ uint8 padding1[6];
+
+ uint8 passmustchange; /* 0x00 must change = 0x01 */
+
+ uint8 padding2;
+
uint8 pass[516];
UNISTR2 uni_user_name; /* NULL - username unicode string */
@@ -487,7 +494,11 @@ typedef struct sam_user_info_21
uint32 unknown_5; /* 0x0002 0000 */
- uint8 padding1[8];
+ uint8 padding1[6];
+
+ uint8 passmustchange; /* 0x00 must change = 0x01 */
+
+ uint8 padding2;
UNISTR2 uni_user_name; /* username unicode string */
UNISTR2 uni_full_name; /* user's full name unicode string */
@@ -507,6 +518,8 @@ typedef struct sam_user_info_21
} SAM_USER_INFO_21;
+#define PASS_MUST_CHANGE_AT_NEXT_LOGON 0x01
+#define PASS_DONT_CHANGE_AT_NEXT_LOGON 0x00
/* SAM_USER_INFO_20 */
typedef struct sam_user_info_20
diff --git a/source3/lib/time.c b/source3/lib/time.c
index ef12dc15f3..5da63910d9 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -1,8 +1,8 @@
/*
Unix SMB/CIFS implementation.
time handling functions
- Copyright (C) Andrew Tridgell 1992-1998
-
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Stefan (metze) Metzmacher 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -748,3 +748,13 @@ void init_nt_time(NTTIME *nt)
nt->high = 0x7FFFFFFF;
nt->low = 0xFFFFFFFF;
}
+
+/****************************************************************************
+check if NTTIME is 0
+****************************************************************************/
+BOOL nt_time_is_zero(NTTIME *nt)
+{
+ if(nt->high==0)
+ return True;
+ return False;
+}
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index b78f26a8e8..2d8ea858aa 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -978,7 +978,7 @@ const char *pdb_unistr2_convert(const UNISTR2 *from)
static pstring convert_buffer;
*convert_buffer = 0;
if (!from) {
- return convert_buffer;
+ return NULL;
}
unistr2_to_ascii(convert_buffer, from, sizeof(pstring));
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 1137993bb6..ddf51fcf0b 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -5470,7 +5470,15 @@ void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
usr->ptr_logon_hrs = hrs ? 1 : 0;
+ if (nt_time_is_zero(pass_must_change_time)) {
+ usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
+ } else {
+ usr->passmustchange=0;
+ }
+
+
ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
usr->unknown_5 = unknown_5; /* 0x0001 0000 */
@@ -5558,7 +5566,14 @@ void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
usr->logon_divs = logon_divs; /* should be 168 (hours/week) */
usr->ptr_logon_hrs = hrs ? 1 : 0;
+ if (nt_time_is_zero(pass_must_change_time)) {
+ usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
+ } else {
+ usr->passmustchange=0;
+ }
+
ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
usr->unknown_5 = unknown_5; /* 0x0001 0000 */
@@ -5651,11 +5666,18 @@ static BOOL sam_io_user_info23(char *desc, SAM_USER_INFO_23 * usr,
return False;
if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
return False;
+
+ if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
+ return False;
+
if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
return False;
- if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
+ if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
+ return False;
+ if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
return False;
+
if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass)))
return False;
@@ -5905,7 +5927,15 @@ void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
usr->ptr_logon_hrs = hrs ? 1 : 0;
usr->unknown_5 = unknown_5; /* 0x0002 0000 */
+ if (nt_time_is_zero(pass_must_change_time)) {
+ usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
+ } else {
+ usr->passmustchange=0;
+ }
+
+
ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
copy_unistr2(&usr->uni_user_name, user_name);
copy_unistr2(&usr->uni_full_name, full_name);
@@ -6037,7 +6067,15 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *
usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0;
usr->unknown_5 = pdb_get_unknown5(pw); /* 0x0002 0000 */
+ if (pdb_get_pass_must_change_time(pw) == 0) {
+ usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON;
+ } else {
+ usr->passmustchange=0;
+ }
+
+
ZERO_STRUCT(usr->padding1);
+ ZERO_STRUCT(usr->padding2);
init_unistr2(&usr->uni_user_name, user_name, len_user_name);
init_unistr2(&usr->uni_full_name, full_name, len_full_name);
@@ -6132,11 +6170,16 @@ static BOOL sam_io_user_info21(char *desc, SAM_USER_INFO_21 * usr,
return False;
if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs))
return False;
+
if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5))
return False;
if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1)))
return False;
+ if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange))
+ return False;
+ if(!prs_uint8("padding2 ", ps, depth, &usr->padding2))
+ return False;
/* here begins pointed-to data */
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index ea631838da..6e9ba2f026 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -2802,8 +2802,6 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid)
acct_ctrl = pdb_get_acct_ctrl(pwd);
- copy_id23_to_sam_passwd(pwd, id23);
-
if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len)) {
pdb_free_sam(&pwd);
return False;
@@ -2814,6 +2812,8 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid)
return False;
}
+ copy_id23_to_sam_passwd(pwd, id23);
+
/* if it's a trust account, don't update /etc/passwd */
if ( (!IS_SAM_UNIX_USER(pwd)) ||
( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) ||
diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c
index 7a5b1e5f46..18297056d6 100644
--- a/source3/rpc_server/srv_samr_util.c
+++ b/source3/rpc_server/srv_samr_util.c
@@ -1,10 +1,11 @@
/*
Unix SMB/CIFS implementation.
SAMR Pipe utility functions.
- Copyright (C) Jeremy Allison 1996-2001
+
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
Copyright (C) Gerald (Jerry) Carter 2000-2001
Copyright (C) Andrew Bartlett 2001-2002
+ Copyright (C) Stefan (metze) Metzmacher 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,118 +27,385 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
+#define STRING_CHANGED (old_string && !new_string) ||\
+ (!old_string && new_string) ||\
+ (old_string && new_string && (strcmp(old_string, new_string) != 0))
+
/*************************************************************
- Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT
- **************************************************************/
+ Copies a SAM_USER_INFO_21 to a SAM_ACCOUNT
+**************************************************************/
-void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
+void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
{
+ time_t unix_time, stored_time;
+ const char *old_string, *new_string;
if (from == NULL || to == NULL)
return;
+ if (!nt_time_is_zero(&from->logon_time)) {
+ 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, True);
+ }
+ if (!nt_time_is_zero(&from->logoff_time)) {
+ 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, True);
+ }
+
+ if (!nt_time_is_zero(&from->kickoff_time)) {
+ 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));
+ if (stored_time != unix_time)
+ pdb_set_kickoff_time(to, unix_time , True);
+ }
- 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)
- pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name ));
- if (from->uni_full_name.buffer)
- pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name ));
- if (from->uni_home_dir.buffer)
- pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True);
- if (from->uni_dir_drive.buffer)
- pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True);
- if (from->uni_logon_script.buffer)
- pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True);
- if (from->uni_profile_path.buffer)
- pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True);
- if (from->uni_acct_desc.buffer)
- pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc ));
- if (from->uni_workstations.buffer)
- pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations));
- if (from->uni_unknown_str.buffer)
- pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str ));
- if (from->uni_munged_dial.buffer)
- 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)
- pdb_set_group_sid_from_rid(to, from->group_rid);
+ if (!nt_time_is_zero(&from->pass_can_change_time)) {
+ 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, True);
+ }
+ if (!nt_time_is_zero(&from->pass_last_set_time)) {
+ 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));
+ if (stored_time != unix_time)
+ pdb_set_pass_last_set_time(to, unix_time);
+ }
+
+ if (!nt_time_is_zero(&from->pass_must_change_time)) {
+ 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));
+ if (stored_time != unix_time)
+ pdb_set_pass_must_change_time(to, unix_time, True);
+ }
+
+ /* Backend should check this for sainity */
+ if (from->hdr_user_name.buffer) {
+ old_string = pdb_get_username(to);
+ new_string = pdb_unistr2_convert(&from->uni_user_name);
+ DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_username(to , new_string);
+ }
+
+ if (from->hdr_full_name.buffer) {
+ old_string = pdb_get_fullname(to);
+ new_string = pdb_unistr2_convert(&from->uni_user_name);
+ DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_fullname(to , new_string);
+ }
+
+ if (from->hdr_home_dir.buffer) {
+ old_string = pdb_get_homedir(to);
+ new_string = pdb_unistr2_convert(&from->uni_home_dir);
+ DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string));
+ if (STRING_CHANGED)
+ pdb_set_homedir(to , new_string, True);
+ }
+
+ if (from->hdr_dir_drive.buffer) {
+ old_string = pdb_get_dir_drive(to);
+ new_string = pdb_unistr2_convert(&from->uni_dir_drive);
+ DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string));
+ if (STRING_CHANGED)
+ pdb_set_dir_drive(to , new_string, True);
+ }
+ if (from->hdr_logon_script.buffer) {
+ old_string = pdb_get_logon_script(to);
+ new_string = pdb_unistr2_convert(&from->uni_logon_script);
+ DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string));
+ if (STRING_CHANGED)
+ pdb_set_logon_script(to , new_string, True);
+ }
+
+ if (from->hdr_profile_path.buffer) {
+ old_string = pdb_get_profile_path(to);
+ new_string = pdb_unistr2_convert(&from->uni_profile_path);
+ DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_profile_path(to , new_string, True);
+ }
+
+ if (from->hdr_acct_desc.buffer) {
+ old_string = pdb_get_acct_desc(to);
+ new_string = pdb_unistr2_convert(&from->uni_acct_desc);
+ DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string));
+ if (STRING_CHANGED)
+ pdb_set_acct_desc(to , new_string);
+ }
+
+ if (from->hdr_workstations.buffer) {
+ old_string = pdb_get_workstations(to);
+ new_string = pdb_unistr2_convert(&from->uni_workstations);
+ DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_workstations(to , new_string);
+ }
+
+ if (from->hdr_unknown_str.buffer) {
+ old_string = pdb_get_unknown_str(to);
+ new_string = pdb_unistr2_convert(&from->uni_unknown_str);
+ DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_unknown_str(to , new_string);
+ }
+
+ if (from->hdr_munged_dial.buffer) {
+ old_string = pdb_get_munged_dial(to);
+ new_string = pdb_unistr2_convert(&from->uni_munged_dial);
+ DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_munged_dial(to , new_string);
+ }
+
+ if (from->user_rid) {
+ 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);*/
+ }
+
+ if (from->group_rid) {
+ 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);
+ }
+
+ 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(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
pdb_set_logon_divs(to, from->logon_divs);
+
+ DEBUG(15,("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(15,("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);
+
+ DEBUG(10,("INFO_21 PADDING1 %02X %02X %02X %02X %02X %02X\n",
+ from->padding1[0],
+ from->padding1[1],
+ from->padding1[2],
+ from->padding1[3],
+ from->padding1[4],
+ from->padding1[5]));
+
+ DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
+ if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) {
+ pdb_set_pass_must_change_time(to,0, True);
+ }
+
+ DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2));
+
+ DEBUG(10,("INFO_21 PADDING_4: %08X\n",from->padding4));
}
/*************************************************************
- Copies a sam passwd.
- **************************************************************/
+ Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT
+**************************************************************/
-void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
+void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
{
+ time_t unix_time, stored_time;
+ const char *old_string, *new_string;
+
if (from == NULL || to == NULL)
return;
+ if (!nt_time_is_zero(&from->logon_time)) {
+ 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, True);
+ }
+ if (!nt_time_is_zero(&from->logoff_time)) {
+ 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));
+ if (stored_time != unix_time)
+ pdb_set_logoff_time(to, unix_time, True);
+ }
+
+ if (!nt_time_is_zero(&from->kickoff_time)) {
+ 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));
+ if (stored_time != unix_time)
+ pdb_set_kickoff_time(to, unix_time , True);
+ }
- 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)
- pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name ));
- if (from->uni_full_name.buffer)
- pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name ));
- if (from->uni_home_dir.buffer)
- pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True);
- if (from->uni_dir_drive.buffer)
- pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True);
- if (from->uni_logon_script.buffer)
- pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True);
- if (from->uni_profile_path.buffer)
- pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True);
- if (from->uni_acct_desc.buffer)
- pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc ));
- if (from->uni_workstations.buffer)
- pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations));
- if (from->uni_unknown_str.buffer)
- pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str ));
- if (from->uni_munged_dial.buffer)
- 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)
- pdb_set_group_sid_from_rid(to, from->group_rid);
+ if (!nt_time_is_zero(&from->pass_can_change_time)) {
+ 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, True);
+ }
+ if (!nt_time_is_zero(&from->pass_last_set_time)) {
+ 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));
+ if (stored_time != unix_time)
+ pdb_set_pass_last_set_time(to, unix_time);
+ }
+
+ if (!nt_time_is_zero(&from->pass_must_change_time)) {
+ 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));
+ if (stored_time != unix_time)
+ pdb_set_pass_must_change_time(to, unix_time, True);
+ }
+
+ /* Backend should check this for sainity */
+ if (from->hdr_user_name.buffer) {
+ old_string = pdb_get_username(to);
+ new_string = pdb_unistr2_convert(&from->uni_user_name);
+ DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_username(to , new_string);
+ }
+
+ if (from->hdr_full_name.buffer) {
+ old_string = pdb_get_fullname(to);
+ new_string = pdb_unistr2_convert(&from->uni_user_name);
+ DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_fullname(to , new_string);
+ }
+
+ if (from->hdr_home_dir.buffer) {
+ old_string = pdb_get_homedir(to);
+ new_string = pdb_unistr2_convert(&from->uni_home_dir);
+ DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string));
+ if (STRING_CHANGED)
+ pdb_set_homedir(to , new_string, True);
+ }
+
+ if (from->hdr_dir_drive.buffer) {
+ old_string = pdb_get_dir_drive(to);
+ new_string = pdb_unistr2_convert(&from->uni_dir_drive);
+ DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string));
+ if (STRING_CHANGED)
+ pdb_set_dir_drive(to , new_string, True);
+ }
- /* FIXME!! Do we need to copy the passwords here as well?
- I don't know. Need to figure this out --jerry */
+ if (from->hdr_logon_script.buffer) {
+ old_string = pdb_get_logon_script(to);
+ new_string = pdb_unistr2_convert(&from->uni_logon_script);
+ DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string));
+ if (STRING_CHANGED)
+ pdb_set_logon_script(to , new_string, True);
+ }
- /* Passwords dealt with in caller --abartlet */
+ if (from->hdr_profile_path.buffer) {
+ old_string = pdb_get_profile_path(to);
+ new_string = pdb_unistr2_convert(&from->uni_profile_path);
+ DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_profile_path(to , new_string, True);
+ }
+
+ if (from->hdr_acct_desc.buffer) {
+ old_string = pdb_get_acct_desc(to);
+ new_string = pdb_unistr2_convert(&from->uni_acct_desc);
+ DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string));
+ if (STRING_CHANGED)
+ pdb_set_acct_desc(to , new_string);
+ }
+
+ if (from->hdr_workstations.buffer) {
+ old_string = pdb_get_workstations(to);
+ new_string = pdb_unistr2_convert(&from->uni_workstations);
+ DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_workstations(to , new_string);
+ }
+ if (from->hdr_unknown_str.buffer) {
+ old_string = pdb_get_unknown_str(to);
+ new_string = pdb_unistr2_convert(&from->uni_unknown_str);
+ DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_unknown_str(to , new_string);
+ }
+
+ if (from->hdr_munged_dial.buffer) {
+ old_string = pdb_get_munged_dial(to);
+ new_string = pdb_unistr2_convert(&from->uni_munged_dial);
+ DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED)
+ pdb_set_munged_dial(to , new_string);
+ }
+
+ if (from->user_rid) {
+ 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);*/
+ }
+
+ if (from->group_rid) {
+ 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);
+ }
+
+ 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(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs));
pdb_set_logon_divs(to, from->logon_divs);
+
+ DEBUG(15,("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(15,("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);
+
+ DEBUG(10,("INFO_23 PADDING1 %02X %02X %02X %02X %02X %02X\n",
+ from->padding1[0],
+ from->padding1[1],
+ from->padding1[2],
+ from->padding1[3],
+ from->padding1[4],
+ from->padding1[5]));
+
+ DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange));
+ if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) {
+ pdb_set_pass_must_change_time(to,0, True);
+ }
+
+ DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2));
+
+ DEBUG(10,("INFO_23 PADDING_4: %08X\n",from->padding4));
}
+