diff options
author | Günther Deschner <gd@samba.org> | 2008-02-11 21:09:21 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-02-11 22:49:10 +0100 |
commit | 6bb6af65abfced64576d990b5f734d61130b3d77 (patch) | |
tree | 8145f106db29cf0c94a876581eebe0bc06cb339b | |
parent | 7303fce0e0154e9db460ebf71ebb79811c768122 (diff) | |
download | samba-6bb6af65abfced64576d990b5f734d61130b3d77.tar.gz samba-6bb6af65abfced64576d990b5f734d61130b3d77.tar.bz2 samba-6bb6af65abfced64576d990b5f734d61130b3d77.zip |
Use pidl for _samr_SetUserInfo and _samr_SetUserInfo2.
Guenther
(This used to be commit d148ffbc955aa62e42ab480e41d3a9b8c63117cd)
-rw-r--r-- | source3/rpc_server/srv_samr.c | 51 | ||||
-rw-r--r-- | source3/rpc_server/srv_samr_nt.c | 239 | ||||
-rw-r--r-- | source3/rpc_server/srv_samr_util.c | 514 |
3 files changed, 174 insertions, 630 deletions
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 771c1e3341..8d626fced9 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -383,33 +383,7 @@ static bool api_samr_open_alias(pipes_struct *p) static bool api_samr_set_userinfo(pipes_struct *p) { - SAMR_Q_SET_USERINFO q_u; - SAMR_R_SET_USERINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_set_userinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_userinfo: Unable to unmarshall SAMR_Q_SET_USERINFO.\n")); - /* Fix for W2K SP2 */ - /* what is that status-code ? - gd */ - if (q_u.switch_value == 0x1a) { - setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG)); - return True; - } - return False; - } - - r_u.status = _samr_set_userinfo(p, &q_u, &r_u); - - if(!samr_io_r_set_userinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_userinfo: Unable to marshall SAMR_R_SET_USERINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_SETUSERINFO); } /******************************************************************* @@ -418,28 +392,7 @@ static bool api_samr_set_userinfo(pipes_struct *p) static bool api_samr_set_userinfo2(pipes_struct *p) { - SAMR_Q_SET_USERINFO2 q_u; - SAMR_R_SET_USERINFO2 r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_set_userinfo2("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_userinfo2: Unable to unmarshall SAMR_Q_SET_USERINFO2.\n")); - return False; - } - - r_u.status = _samr_set_userinfo2(p, &q_u, &r_u); - - if(!samr_io_r_set_userinfo2("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_userinfo2: Unable to marshall SAMR_R_SET_USERINFO2.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_SETUSERINFO2); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6619e0651e..cb5bfe5440 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3132,10 +3132,11 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p, /******************************************************************* set_user_info_7 ********************************************************************/ + static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, - const SAM_USER_INFO_7 *id7, struct samu *pwd) + struct samr_UserInfo7 *id7, + struct samu *pwd) { - fstring new_name; NTSTATUS rc; if (id7 == NULL) { @@ -3144,7 +3145,7 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, return NT_STATUS_ACCESS_DENIED; } - if(!rpcstr_pull(new_name, id7->uni_name.buffer, sizeof(new_name), id7->uni_name.uni_str_len*2, 0)) { + if (!id7->account_name.string) { DEBUG(5, ("set_user_info_7: failed to get new username\n")); TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; @@ -3159,12 +3160,12 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, simply that the rename fails with a slightly different status code (like UNSUCCESSFUL instead of ALREADY_EXISTS). */ - rc = can_create(mem_ctx, new_name); + rc = can_create(mem_ctx, id7->account_name.string); if (!NT_STATUS_IS_OK(rc)) { return rc; } - rc = pdb_rename_sam_account(pwd, new_name); + rc = pdb_rename_sam_account(pwd, id7->account_name.string); TALLOC_FREE(pwd); return rc; @@ -3174,7 +3175,8 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, set_user_info_16 ********************************************************************/ -static bool set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) +static bool set_user_info_16(struct samr_UserInfo16 *id16, + struct samu *pwd) { if (id16 == NULL) { DEBUG(5, ("set_user_info_16: NULL id16\n")); @@ -3183,7 +3185,7 @@ static bool set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) } /* FIX ME: check if the value is really changed --metze */ - if (!pdb_set_acct_ctrl(pwd, id16->acb_info, PDB_CHANGED)) { + if (!pdb_set_acct_ctrl(pwd, id16->acct_flags, PDB_CHANGED)) { TALLOC_FREE(pwd); return False; } @@ -3202,20 +3204,20 @@ static bool set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) set_user_info_18 ********************************************************************/ -static bool set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) +static bool set_user_info_18(struct samr_UserInfo18 *id18, + struct samu *pwd) { - if (id18 == NULL) { DEBUG(2, ("set_user_info_18: id18 is NULL\n")); TALLOC_FREE(pwd); return False; } - if (!pdb_set_lanman_passwd (pwd, id18->lm_pwd, PDB_CHANGED)) { + if (!pdb_set_lanman_passwd (pwd, id18->lm_pwd.hash, PDB_CHANGED)) { TALLOC_FREE(pwd); return False; } - if (!pdb_set_nt_passwd (pwd, id18->nt_pwd, PDB_CHANGED)) { + if (!pdb_set_nt_passwd (pwd, id18->nt_pwd.hash, PDB_CHANGED)) { TALLOC_FREE(pwd); return False; } @@ -3237,7 +3239,8 @@ static bool set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) set_user_info_20 ********************************************************************/ -static bool set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) +static bool set_user_info_20(struct samr_UserInfo20 *id20, + struct samu *pwd) { if (id20 == NULL) { DEBUG(5, ("set_user_info_20: NULL id20\n")); @@ -3256,14 +3259,15 @@ static bool set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) return True; } + /******************************************************************* set_user_info_21 ********************************************************************/ -static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, +static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, + struct samr_UserInfo21 *id21, struct samu *pwd) { - fstring new_name; NTSTATUS status; if (id21 == NULL) { @@ -3273,9 +3277,8 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, /* we need to separately check for an account rename first */ - if (rpcstr_pull(new_name, id21->uni_user_name.buffer, - sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0) - && (!strequal(new_name, pdb_get_username(pwd)))) + if (id21->account_name.string && + (!strequal(id21->account_name.string, pdb_get_username(pwd)))) { /* check to see if the new username already exists. Note: we can't @@ -3287,12 +3290,12 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, simply that the rename fails with a slightly different status code (like UNSUCCESSFUL instead of ALREADY_EXISTS). */ - status = can_create(mem_ctx, new_name); + status = can_create(mem_ctx, id21->account_name.string); if (!NT_STATUS_IS_OK(status)) { return status; } - status = pdb_rename_sam_account(pwd, new_name); + status = pdb_rename_sam_account(pwd, id21->account_name.string); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("set_user_info_21: failed to rename account: %s\n", @@ -3303,7 +3306,7 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, /* set the new username so that later functions can work on the new account */ - pdb_set_username(pwd, new_name, PDB_SET); + pdb_set_username(pwd, id21->account_name.string, PDB_SET); } copy_id21_to_sam_passwd(pwd, id21); @@ -3341,7 +3344,8 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, set_user_info_23 ********************************************************************/ -static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, +static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, + struct samr_UserInfo23 *id23, struct samu *pwd) { char *plaintext_buf = NULL; @@ -3360,7 +3364,7 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, acct_ctrl = pdb_get_acct_ctrl(pwd); if (!decode_pw_buffer(mem_ctx, - id23->pass, + id23->password.data, &plaintext_buf, &len, STR_UNICODE)) { @@ -3508,7 +3512,8 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd) set_user_info_25 ********************************************************************/ -static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, +static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, + struct samr_UserInfo25 *id25, struct samu *pwd) { NTSTATUS status; @@ -3548,16 +3553,18 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, } /******************************************************************* - samr_reply_set_userinfo + _samr_SetUserInfo ********************************************************************/ -NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) +NTSTATUS _samr_SetUserInfo(pipes_struct *p, + struct samr_SetUserInfo *r) { + NTSTATUS status; struct samu *pwd = NULL; DOM_SID sid; - POLICY_HND *pol = &q_u->pol; - uint16 switch_value = q_u->switch_value; - SAM_USERINFO_CTR *ctr = q_u->ctr; + POLICY_HND *pol = r->in.user_handle; + uint16 switch_value = r->in.level; + union samr_UserInfo *info = r->in.info; uint32 acc_granted; uint32 acc_required; bool ret; @@ -3565,9 +3572,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE uint32 acb_info; DISP_INFO *disp_info = NULL; - DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); - - r_u->status = NT_STATUS_OK; + DEBUG(5, ("_samr_SetUserInfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) @@ -3592,15 +3597,18 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE break; } - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, + acc_required, + "_samr_SetUserInfo"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - DEBUG(5, ("_samr_set_userinfo: sid:%s, level:%d\n", + DEBUG(5, ("_samr_SetUserInfo: sid:%s, level:%d\n", sid_string_dbg(&sid), switch_value)); - if (ctr == NULL) { - DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); + if (info == NULL) { + DEBUG(5, ("_samr_SetUserInfo: NULL info level\n")); return NT_STATUS_INVALID_INFO_CLASS; } @@ -3630,7 +3638,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", + DEBUG(5, ("_samr_SetUserInfo: %s does%s possess sufficient rights\n", uidtoname(p->pipe_user.ut.uid), has_enough_rights ? "" : " not")); @@ -3643,65 +3651,67 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE switch (switch_value) { case 18: - if (!set_user_info_18(ctr->info.id18, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_18(&info->info18, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 24: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhashBlob(ctr->info.id24->pass, 516, &p->session_key); + SamOEMhashBlob(info->info24.password.data, + 516, + &p->session_key); - dump_data(100, ctr->info.id24->pass, 516); + dump_data(100, info->info24.password.data, 516); - if (!set_user_info_pw(ctr->info.id24->pass, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_pw(info->info24.password.data, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 25: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(ctr->info.id25->pass, &p->session_key); + encode_or_decode_arc4_passwd_buffer(info->info25.password.data, &p->session_key); - dump_data(100, ctr->info.id25->pass, 532); + dump_data(100, info->info25.password.data, 532); - r_u->status = set_user_info_25(p->mem_ctx, - ctr->info.id25, pwd); - if (!NT_STATUS_IS_OK(r_u->status)) { + status = set_user_info_25(p->mem_ctx, + &info->info25, pwd); + if (!NT_STATUS_IS_OK(status)) { goto done; } - if (!set_user_info_pw(ctr->info.id25->pass, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_pw(info->info25.password.data, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 26: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(ctr->info.id26->pass, &p->session_key); + encode_or_decode_arc4_passwd_buffer(info->info26.password.data, &p->session_key); - dump_data(100, ctr->info.id26->pass, 516); + dump_data(100, info->info26.password.data, 516); - if (!set_user_info_pw(ctr->info.id26->pass, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_pw(info->info26.password.data, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 23: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); + SamOEMhashBlob(info->info23.password.data, 516, &p->session_key); - dump_data(100, ctr->info.id23->pass, 516); + dump_data(100, info->info23.password.data, 516); - r_u->status = set_user_info_23(p->mem_ctx, - ctr->info.id23, pwd); + status = set_user_info_23(p->mem_ctx, + &info->info23, pwd); break; default: - r_u->status = NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; } done: @@ -3711,24 +3721,26 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE /* ================ END SeMachineAccountPrivilege BLOCK ================ */ - if (NT_STATUS_IS_OK(r_u->status)) { + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } - return r_u->status; + return status; } /******************************************************************* - samr_reply_set_userinfo2 + _samr_SetUserInfo2 ********************************************************************/ -NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) +NTSTATUS _samr_SetUserInfo2(pipes_struct *p, + struct samr_SetUserInfo2 *r) { + NTSTATUS status; struct samu *pwd = NULL; DOM_SID sid; - SAM_USERINFO_CTR *ctr = q_u->ctr; - POLICY_HND *pol = &q_u->pol; - uint16 switch_value = q_u->switch_value; + union samr_UserInfo *info = r->in.info; + POLICY_HND *pol = r->in.user_handle; + uint16 switch_value = r->in.level; uint32 acc_granted; uint32 acc_required; bool ret; @@ -3736,9 +3748,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ uint32 acb_info; DISP_INFO *disp_info = NULL; - DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); - - r_u->status = NT_STATUS_OK; + DEBUG(5, ("_samr_SetUserInfo2: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) @@ -3753,20 +3763,21 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ acc_required = SA_RIGHT_USER_SET_ATTRIBUTES; #endif - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, + acc_required, + "_samr_SetUserInfo2"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - DEBUG(5, ("samr_reply_set_userinfo2: sid:%s\n", + DEBUG(5,("_samr_SetUserInfo2: sid:%s\n", sid_string_dbg(&sid))); - if (ctr == NULL) { - DEBUG(5, ("samr_reply_set_userinfo2: NULL info level\n")); + if (info == NULL) { + DEBUG(5,("_samr_SetUserInfo2: NULL info level\n")); return NT_STATUS_INVALID_INFO_CLASS; } - switch_value=ctr->switch_value; - if ( !(pwd = samu_new( NULL )) ) { return NT_STATUS_NO_MEMORY; } @@ -3790,7 +3801,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - DEBUG(5, ("_samr_set_userinfo2: %s does%s possess sufficient rights\n", + DEBUG(5, ("_samr_SetUserInfo2: %s does%s possess sufficient rights\n", uidtoname(p->pipe_user.ut.uid), has_enough_rights ? "" : " not")); @@ -3803,50 +3814,50 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ switch (switch_value) { case 7: - r_u->status = set_user_info_7(p->mem_ctx, - ctr->info.id7, pwd); + status = set_user_info_7(p->mem_ctx, + &info->info7, pwd); break; case 16: - if (!set_user_info_16(ctr->info.id16, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_16(&info->info16, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 18: /* Used by AS/U JRA. */ - if (!set_user_info_18(ctr->info.id18, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_18(&info->info18, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 20: - if (!set_user_info_20(ctr->info.id20, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_20(&info->info20, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 21: - r_u->status = set_user_info_21(p->mem_ctx, - ctr->info.id21, pwd); + status = set_user_info_21(p->mem_ctx, + &info->info21, pwd); break; case 23: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); + SamOEMhashBlob(info->info23.password.data, 516, &p->session_key); - dump_data(100, ctr->info.id23->pass, 516); + dump_data(100, info->info23.password.data, 516); - r_u->status = set_user_info_23(p->mem_ctx, - ctr->info.id23, pwd); + status = set_user_info_23(p->mem_ctx, + &info->info23, pwd); break; case 26: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(ctr->info.id26->pass, &p->session_key); + encode_or_decode_arc4_passwd_buffer(info->info26.password.data, &p->session_key); - dump_data(100, ctr->info.id26->pass, 516); + dump_data(100, info->info26.password.data, 516); - if (!set_user_info_pw(ctr->info.id26->pass, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_pw(info->info26.password.data, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; default: - r_u->status = NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; } if ( has_enough_rights ) @@ -3854,11 +3865,11 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* ================ END SeMachineAccountPrivilege BLOCK ================ */ - if (NT_STATUS_IS_OK(r_u->status)) { + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } - return r_u->status; + return status; } /********************************************************************* @@ -5258,16 +5269,6 @@ NTSTATUS _samr_QueryUserInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_SetUserInfo(pipes_struct *p, - struct samr_SetUserInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_ChangePasswordUser(pipes_struct *p, struct samr_ChangePasswordUser *r) { @@ -5378,16 +5379,6 @@ NTSTATUS _samr_OemChangePasswordUser2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_SetUserInfo2(pipes_struct *p, - struct samr_SetUserInfo2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetBootKeyInformation(pipes_struct *p, struct samr_SetBootKeyInformation *r) { diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 0b7cbbed4a..a6c0e7b448 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -35,10 +35,11 @@ ((s1) && (s2) && (strcmp((s1), (s2)) != 0)) /************************************************************* - Copies a SAM_USER_INFO_20 to a struct samu + Copies a struct samr_UserInfo20 to a struct samu **************************************************************/ -void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) +void copy_id20_to_sam_passwd(struct samu *to, + struct samr_UserInfo20 *from) { const char *old_string; char *new_string; @@ -47,6 +48,7 @@ void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) if (from == NULL || to == NULL) return; +#if 0 if (from->hdr_munged_dial.buffer) { old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; @@ -60,13 +62,15 @@ void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) TALLOC_FREE(new_string); } +#endif } /************************************************************* - Copies a SAM_USER_INFO_21 to a struct samu + Copies a struct samr_UserInfo21 to a struct samu **************************************************************/ -void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) +void copy_id21_to_sam_passwd(struct samu *to, + struct samr_UserInfo21 *from) { time_t unix_time, stored_time; const char *old_string, *new_string; @@ -76,7 +80,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) return; if (from->fields_present & ACCT_LAST_LOGON) { - unix_time=nt_time_to_unix(from->logon_time); + unix_time=nt_time_to_unix(from->last_logon); 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) @@ -84,7 +88,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LAST_LOGOFF) { - unix_time=nt_time_to_unix(from->logoff_time); + unix_time=nt_time_to_unix(from->last_logoff); 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) @@ -92,7 +96,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_EXPIRY) { - unix_time=nt_time_to_unix(from->kickoff_time); + unix_time=nt_time_to_unix(from->acct_expiry); 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) @@ -100,7 +104,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LAST_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_last_set_time); + unix_time=nt_time_to_unix(from->last_password_change); 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) @@ -108,86 +112,87 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if ((from->fields_present & ACCT_USERNAME) && - (from->hdr_user_name.buffer)) { + (from->account_name.string)) { old_string = pdb_get_username(to); - new_string = unistr2_static(&from->uni_user_name); + new_string = from->account_name.string; DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) pdb_set_username(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_FULL_NAME) && - (from->hdr_full_name.buffer)) { + (from->full_name.string)) { old_string = pdb_get_fullname(to); - new_string = unistr2_static(&from->uni_full_name); + new_string = from->full_name.string; DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_HOME_DIR) && - (from->hdr_home_dir.buffer)) { + (from->home_directory.string)) { old_string = pdb_get_homedir(to); - new_string = unistr2_static(&from->uni_home_dir); + new_string = from->home_directory.string; DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_homedir(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_HOME_DRIVE) && - (from->hdr_dir_drive.buffer)) { + (from->home_drive.string)) { old_string = pdb_get_dir_drive(to); - new_string = unistr2_static(&from->uni_dir_drive); + new_string = from->home_drive.string; DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_dir_drive(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_LOGON_SCRIPT) && - (from->hdr_logon_script.buffer)) { + (from->logon_script.string)) { old_string = pdb_get_logon_script(to); - new_string = unistr2_static(&from->uni_logon_script); + new_string = from->logon_script.string; DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_logon_script(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_PROFILE) && - (from->hdr_profile_path.buffer)) { + (from->profile_path.string)) { old_string = pdb_get_profile_path(to); - new_string = unistr2_static(&from->uni_profile_path); + new_string = from->profile_path.string; DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_DESCRIPTION) && - (from->hdr_acct_desc.buffer)) { + (from->description.string)) { old_string = pdb_get_acct_desc(to); - new_string = unistr2_static(&from->uni_acct_desc); + new_string = from->description.string; DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_WORKSTATIONS) && - (from->hdr_workstations.buffer)) { + (from->workstations.string)) { old_string = pdb_get_workstations(to); - new_string = unistr2_static(&from->uni_workstations); + new_string = from->workstations.string; DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_workstations(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_COMMENT) && - (from->hdr_comment.buffer)) { + (from->comment.string)) { old_string = pdb_get_comment(to); - new_string = unistr2_static(&from->uni_comment); + new_string = from->comment.string; DEBUG(10,("INFO_21 UNI_COMMENT: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_comment(to, new_string, PDB_CHANGED); } - +#if 0 + /* FIXME GD */ if ((from->fields_present & ACCT_CALLBACK) && (from->hdr_munged_dial.buffer)) { char *newstr; @@ -203,37 +208,37 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) TALLOC_FREE(newstr); } - +#endif if (from->fields_present & ACCT_RID) { - if (from->user_rid == 0) { + if (from->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)); + } else if (from->rid != pdb_get_user_rid(to)) { + DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->rid)); } } if (from->fields_present & ACCT_PRIMARY_GID) { - if (from->group_rid == 0) { + if (from->primary_gid == 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); + } else if (from->primary_gid != pdb_get_group_rid(to)) { + DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->primary_gid)); + pdb_set_group_sid_from_rid(to, from->primary_gid, 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)) { - if (!(from->acb_info & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { + DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acct_flags)); + if (from->acct_flags != pdb_get_acct_ctrl(to)) { + if (!(from->acct_flags & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { /* We're unlocking a previously locked user. Reset bad password counts. Patch from Jianliang Lu. <Jianliang.Lu@getronics.com> */ pdb_set_bad_password_count(to, 0, PDB_CHANGED); pdb_set_bad_password_time(to, 0, PDB_CHANGED); } - pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + pdb_set_acct_ctrl(to, from->acct_flags, PDB_CHANGED); } } - +#if 0 if (from->fields_present & ACCT_LOGON_HOURS) { char oldstr[44]; /* hours strings are 42 bytes. */ char newstr[44]; @@ -254,7 +259,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } } - +#endif 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)) { @@ -263,7 +268,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_NUM_LOGONS) { - DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); + 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); } @@ -274,443 +279,38 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) calculated from policy, not set from the wire */ if (from->fields_present & ACCT_EXPIRED_FLAG) { - DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); - if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { + DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n", from->password_expired)); + if (from->password_expired == PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); } } - - DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2)); } /************************************************************* - Copies a SAM_USER_INFO_23 to a struct samu + Copies a struct samr_UserInfo23 to a struct samu **************************************************************/ -void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) +void copy_id23_to_sam_passwd(struct samu *to, + struct samr_UserInfo23 *from) { - time_t unix_time, stored_time; - const char *old_string, *new_string; - DATA_BLOB mung; - if (from == NULL || to == NULL) return; - 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 (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)); - if (stored_time != unix_time) - pdb_set_logoff_time(to, unix_time, PDB_CHANGED); - } - - 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)); - if (stored_time != unix_time) - pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); - } - - 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)); - if (stored_time != unix_time) - pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); - } - - /* 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)); - if (STRING_CHANGED) - pdb_set_username(to , new_string, PDB_CHANGED); - } - - 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)); - if (STRING_CHANGED) - pdb_set_fullname(to , new_string, PDB_CHANGED); - } - - 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)); - if (STRING_CHANGED) - pdb_set_homedir(to , new_string, PDB_CHANGED); - } - - 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)); - if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, PDB_CHANGED); - } - - 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)); - if (STRING_CHANGED) - pdb_set_logon_script(to , new_string, PDB_CHANGED); - } - - 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)); - if (STRING_CHANGED) - pdb_set_profile_path(to , new_string, PDB_CHANGED); - } - - 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)); - if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string, PDB_CHANGED); - } - - 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)); - if (STRING_CHANGED) - pdb_set_workstations(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_COMMENT) && - (from->hdr_comment.buffer)) { - old_string = pdb_get_comment(to); - new_string = unistr2_static(&from->uni_comment); - DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_comment(to , new_string, PDB_CHANGED); - } - - 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; - mung.data = (uint8 *) from->uni_munged_dial.buffer; - mung.free = NULL; - newstr = (mung.length == 0) ? - NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); - if (STRING_CHANGED_NC(old_string, newstr)) - pdb_set_munged_dial(to , newstr, PDB_CHANGED); - - TALLOC_FREE(newstr); - } - - 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); - } - } - - 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); - } - } - - 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_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); - } - - 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); - } - } - - 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); - } - } - - /* If the must change flag is set, the last set time goes to zero. - the must change and can change fields also do, but they are - calculated from policy, not set from the wire */ - - if (from->fields_present & ACCT_EXPIRED_FLAG) { - 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_last_set_time(to, 0, PDB_CHANGED); - } else { - pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); - } - } - - DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); + copy_id21_to_sam_passwd(to, &from->info); } /************************************************************* - Copies a SAM_USER_INFO_25 to a struct samu + Copies a struct samr_UserInfo25 to a struct samu **************************************************************/ -void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) +void copy_id25_to_sam_passwd(struct samu *to, + struct samr_UserInfo25 *from) { - time_t unix_time, stored_time; - const char *old_string, *new_string; - DATA_BLOB mung; - if (from == NULL || to == NULL) return; - 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_25 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 (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_25 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 (from->fields_present & ACCT_EXPIRY) { - unix_time=nt_time_to_unix(from->kickoff_time); - stored_time = pdb_get_kickoff_time(to); - DEBUG(10,("INFO_25 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 , PDB_CHANGED); - } - - 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_25 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, PDB_CHANGED); - } - - 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_25 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); - if (STRING_CHANGED) - pdb_set_username(to , new_string, PDB_CHANGED); - } - - 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_25 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_fullname(to , new_string, PDB_CHANGED); - } - - 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_25 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_homedir(to , new_string, PDB_CHANGED); - } - - 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_25 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, PDB_CHANGED); - } - - 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_25 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_logon_script(to , new_string, PDB_CHANGED); - } - - 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_25 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_profile_path(to , new_string, PDB_CHANGED); - } - - 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_25 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string, PDB_CHANGED); - } - - 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_25 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_workstations(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_COMMENT) && - (from->hdr_comment.buffer)) { - old_string = pdb_get_comment(to); - new_string = unistr2_static(&from->uni_comment); - DEBUG(10,("INFO_25 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_comment(to , new_string, PDB_CHANGED); - } - - 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; - mung.data = (uint8 *) from->uni_munged_dial.buffer; - mung.free = NULL; - newstr = (mung.length == 0) ? - NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("INFO_25 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); - if (STRING_CHANGED_NC(old_string,newstr)) - pdb_set_munged_dial(to , newstr, PDB_CHANGED); - - TALLOC_FREE(newstr); - } - - if (from->fields_present & ACCT_RID) { - if (from->user_rid == 0) { - DEBUG(10, ("INFO_25: Asked to set User RID to 0 !? Skipping change!\n")); - } else if (from->user_rid != pdb_get_user_rid(to)) { - DEBUG(10,("INFO_25 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_25: Asked to set Group RID to 0 !? Skipping change!\n")); - } else if (from->group_rid != pdb_get_group_rid(to)) { - DEBUG(10,("INFO_25 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_FLAGS) { - DEBUG(10,("INFO_25 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - if (from->acb_info != pdb_get_acct_ctrl(to)) { - if (!(from->acb_info & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { - /* We're unlocking a previously locked user. Reset bad password counts. - Patch from Jianliang Lu. <Jianliang.Lu@getronics.com> */ - pdb_set_bad_password_count(to, 0, PDB_CHANGED); - pdb_set_bad_password_time(to, 0, PDB_CHANGED); - } - pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); - } - } - - if (from->fields_present & ACCT_LOGON_HOURS) { - DEBUG(15,("INFO_25 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_25 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_25 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); - } - - if (from->fields_present & ACCT_BAD_PWD_COUNT) { - DEBUG(10,("INFO_25 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_NUM_LOGONS) { - DEBUG(10,("INFO_25 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 the must change flag is set, the last set time goes to zero. - the must change and can change fields also do, but they are - calculated from policy, not set from the wire */ - - if (from->fields_present & ACCT_EXPIRED_FLAG) { - DEBUG(10,("INFO_25 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); - if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); - } else { - pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); - } - } + copy_id21_to_sam_passwd(to, &from->info); } |