diff options
author | Günther Deschner <gd@samba.org> | 2009-06-25 02:06:21 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-06-25 11:02:35 +0200 |
commit | aab9e5509ca17c76a625d9da50b498567aaaf338 (patch) | |
tree | 70f8640f9725d634342531bba9518de479329ff9 /source3/rpc_server | |
parent | 28d74f96fb9bbe0cf59df2f33d8d555ec0de4eb0 (diff) | |
download | samba-aab9e5509ca17c76a625d9da50b498567aaaf338.tar.gz samba-aab9e5509ca17c76a625d9da50b498567aaaf338.tar.bz2 samba-aab9e5509ca17c76a625d9da50b498567aaaf338.zip |
s3-samr: refactor _samr_SetDomainInfo().
Guenther
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_samr_nt.c | 97 |
1 files changed, 72 insertions, 25 deletions
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9319c14757..8560ee97c6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -6352,6 +6352,67 @@ NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p, } /******************************************************************* + ********************************************************************/ + +static NTSTATUS set_dom_info_1(TALLOC_CTX *mem_ctx, + struct samr_DomInfo1 *r) +{ + time_t u_expire, u_min_age; + + u_expire = nt_time_to_unix_abs((NTTIME *)&r->max_password_age); + u_min_age = nt_time_to_unix_abs((NTTIME *)&r->min_password_age); + + pdb_set_account_policy(AP_MIN_PASSWORD_LEN, + (uint32_t)r->min_password_length); + pdb_set_account_policy(AP_PASSWORD_HISTORY, + (uint32_t)r->password_history_length); + pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, + (uint32_t)r->password_properties); + pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (int)u_expire); + pdb_set_account_policy(AP_MIN_PASSWORD_AGE, (int)u_min_age); + + return NT_STATUS_OK; +} + +/******************************************************************* + ********************************************************************/ + +static NTSTATUS set_dom_info_3(TALLOC_CTX *mem_ctx, + struct samr_DomInfo3 *r) +{ + time_t u_logout; + + u_logout = nt_time_to_unix_abs((NTTIME *)&r->force_logoff_time); + + pdb_set_account_policy(AP_TIME_TO_LOGOUT, (int)u_logout); + + return NT_STATUS_OK; +} + +/******************************************************************* + ********************************************************************/ + +static NTSTATUS set_dom_info_12(TALLOC_CTX *mem_ctx, + struct samr_DomInfo12 *r) +{ + time_t u_lock_duration, u_reset_time; + + u_lock_duration = nt_time_to_unix_abs((NTTIME *)&r->lockout_duration); + if (u_lock_duration != -1) { + u_lock_duration /= 60; + } + + u_reset_time = nt_time_to_unix_abs((NTTIME *)&r->lockout_window)/60; + + pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); + pdb_set_account_policy(AP_RESET_COUNT_TIME, (int)u_reset_time); + pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, + (uint32_t)r->lockout_threshold); + + return NT_STATUS_OK; +} + +/******************************************************************* _samr_SetDomainInfo ********************************************************************/ @@ -6359,10 +6420,7 @@ NTSTATUS _samr_SetDomainInfo(pipes_struct *p, struct samr_SetDomainInfo *r) { struct samr_domain_info *dinfo; - time_t u_expire, u_min_age; - time_t u_logout; - time_t u_lock_duration, u_reset_time; - NTSTATUS result; + NTSTATUS status; uint32_t acc_required = 0; DEBUG(5,("_samr_SetDomainInfo: %d\n", __LINE__)); @@ -6390,26 +6448,19 @@ NTSTATUS _samr_SetDomainInfo(pipes_struct *p, dinfo = policy_handle_find(p, r->in.domain_handle, acc_required, NULL, - struct samr_domain_info, &result); - if (!NT_STATUS_IS_OK(result)) { - return result; + struct samr_domain_info, &status); + if (!NT_STATUS_IS_OK(status)) { + return status; } DEBUG(5,("_samr_SetDomainInfo: level: %d\n", r->in.level)); switch (r->in.level) { case 1: - u_expire=nt_time_to_unix_abs((NTTIME *)&r->in.info->info1.max_password_age); - u_min_age=nt_time_to_unix_abs((NTTIME *)&r->in.info->info1.min_password_age); - pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)r->in.info->info1.min_password_length); - pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)r->in.info->info1.password_history_length); - pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)r->in.info->info1.password_properties); - pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (int)u_expire); - pdb_set_account_policy(AP_MIN_PASSWORD_AGE, (int)u_min_age); + status = set_dom_info_1(p->mem_ctx, &r->in.info->info1); break; case 3: - u_logout=nt_time_to_unix_abs((NTTIME *)&r->in.info->info3.force_logoff_time); - pdb_set_account_policy(AP_TIME_TO_LOGOUT, (int)u_logout); + status = set_dom_info_3(p->mem_ctx, &r->in.info->info3); break; case 4: break; @@ -6420,20 +6471,16 @@ NTSTATUS _samr_SetDomainInfo(pipes_struct *p, case 9: break; case 12: - u_lock_duration=nt_time_to_unix_abs((NTTIME *)&r->in.info->info12.lockout_duration); - if (u_lock_duration != -1) - u_lock_duration /= 60; - - u_reset_time=nt_time_to_unix_abs((NTTIME *)&r->in.info->info12.lockout_window)/60; - - pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); - pdb_set_account_policy(AP_RESET_COUNT_TIME, (int)u_reset_time); - pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)r->in.info->info12.lockout_threshold); + status = set_dom_info_12(p->mem_ctx, &r->in.info->info12); break; default: return NT_STATUS_INVALID_INFO_CLASS; } + if (!NT_STATUS_IS_OK(status)) { + return status; + } + DEBUG(5,("_samr_SetDomainInfo: %d\n", __LINE__)); return NT_STATUS_OK; |