if (!samr_array) {
return NT_STATUS_NO_MEMORY;
}
+ *r->out.sam = samr_array;
become_root();
samr_array->entries = samr_entries;
*r->out.resume_handle = *r->in.resume_handle + num_account;
- *r->out.sam = samr_array;
*r->out.num_entries = num_account;
DEBUG(5,("_samr_EnumDomainUsers: %d\n", __LINE__));
lp_workgroup(),
global_myname(),
seq_num,
- 1,
+ DOMAIN_SERVER_ENABLED,
server_role,
1,
num_users,
uint32 des_access = r->in.access_mask;
NTSTATUS nt_status;
size_t sd_size;
+ const char *fn = "_samr_Connect2";
+ switch (p->hdr_req.opnum) {
+ case NDR_SAMR_CONNECT2:
+ fn = "_samr_Connect2";
+ break;
+ case NDR_SAMR_CONNECT4:
+ fn = "_samr_Connect4";
+ break;
+ case NDR_SAMR_CONNECT5:
+ fn = "_samr_Connect5";
+ break;
+ }
- DEBUG(5,("_samr_Connect2: %d\n", __LINE__));
+ DEBUG(5,("%s: %d\n", fn, __LINE__));
/* Access check */
if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to _samr_Connect2\n"));
+ DEBUG(3, ("access denied to %s\n", fn));
return NT_STATUS_ACCESS_DENIED;
}
se_map_generic(&des_access, &sam_generic_mapping);
nt_status = access_check_samr_object(psd, p->server_info->ptok,
- NULL, 0, des_access, &acc_granted, "_samr_Connect2");
+ NULL, 0, des_access, &acc_granted, fn);
if ( !NT_STATUS_IS_OK(nt_status) )
return nt_status;
if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- DEBUG(5,("_samr_Connect2: %d\n", __LINE__));
+ DEBUG(5,("%s: %d\n", fn, __LINE__));
return nt_status;
}
NTSTATUS _samr_Connect4(pipes_struct *p,
struct samr_Connect4 *r)
{
- struct samr_info *info = NULL;
- SEC_DESC *psd = NULL;
- uint32 acc_granted;
- uint32 des_access = r->in.access_mask;
- NTSTATUS nt_status;
- size_t sd_size;
-
-
- DEBUG(5,("_samr_Connect4: %d\n", __LINE__));
-
- /* Access check */
-
- if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to samr_Connect4\n"));
- return NT_STATUS_ACCESS_DENIED;
- }
-
- map_max_allowed_access(p->server_info->ptok, &des_access);
-
- make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
- se_map_generic(&des_access, &sam_generic_mapping);
-
- nt_status = access_check_samr_object(psd, p->server_info->ptok,
- NULL, 0, des_access, &acc_granted, "_samr_Connect4");
-
- if ( !NT_STATUS_IS_OK(nt_status) )
- return nt_status;
-
- /* associate the user's SID and access granted with the new handle. */
- if ((info = get_samr_info_by_sid(NULL)) == NULL)
- return NT_STATUS_NO_MEMORY;
+ struct samr_Connect2 c;
- info->acc_granted = acc_granted;
- info->status = r->in.access_mask; /* ??? */
-
- /* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-
- DEBUG(5,("_samr_Connect4: %d\n", __LINE__));
+ c.in.system_name = r->in.system_name;
+ c.in.access_mask = r->in.access_mask;
+ c.out.connect_handle = r->out.connect_handle;
- return NT_STATUS_OK;
+ return _samr_Connect2(p, &c);
}
/*******************************************************************
NTSTATUS _samr_Connect5(pipes_struct *p,
struct samr_Connect5 *r)
{
- struct samr_info *info = NULL;
- SEC_DESC *psd = NULL;
- uint32 acc_granted;
- uint32 des_access = r->in.access_mask;
- NTSTATUS nt_status;
- size_t sd_size;
+ NTSTATUS status;
+ struct samr_Connect2 c;
struct samr_ConnectInfo1 info1;
- DEBUG(5,("_samr_Connect5: %d\n", __LINE__));
+ info1.client_version = SAMR_CONNECT_AFTER_W2K;
+ info1.unknown2 = 0;
- /* Access check */
+ c.in.system_name = r->in.system_name;
+ c.in.access_mask = r->in.access_mask;
+ c.out.connect_handle = r->out.connect_handle;
- if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to samr_Connect5\n"));
- return NT_STATUS_ACCESS_DENIED;
+ status = _samr_Connect2(p, &c);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- map_max_allowed_access(p->server_info->ptok, &des_access);
-
- make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
- se_map_generic(&des_access, &sam_generic_mapping);
-
- nt_status = access_check_samr_object(psd, p->server_info->ptok,
- NULL, 0, des_access, &acc_granted, "_samr_Connect5");
-
- if ( !NT_STATUS_IS_OK(nt_status) )
- return nt_status;
-
- /* associate the user's SID and access granted with the new handle. */
- if ((info = get_samr_info_by_sid(NULL)) == NULL)
- return NT_STATUS_NO_MEMORY;
-
- info->acc_granted = acc_granted;
- info->status = r->in.access_mask; /* ??? */
-
- /* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-
- DEBUG(5,("_samr_Connect5: %d\n", __LINE__));
-
- info1.client_version = SAMR_CONNECT_AFTER_W2K;
- info1.unknown2 = 0;
-
*r->out.level_out = 1;
r->out.info_out->info1 = info1;
if (id7 == NULL) {
DEBUG(5, ("set_user_info_7: NULL id7\n"));
- TALLOC_FREE(pwd);
return NT_STATUS_ACCESS_DENIED;
}
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;
}
rc = pdb_rename_sam_account(pwd, id7->account_name.string);
- TALLOC_FREE(pwd);
return rc;
}
{
if (id16 == NULL) {
DEBUG(5, ("set_user_info_16: NULL id16\n"));
- TALLOC_FREE(pwd);
return False;
}
/* FIX ME: check if the value is really changed --metze */
if (!pdb_set_acct_ctrl(pwd, id16->acct_flags, PDB_CHANGED)) {
- TALLOC_FREE(pwd);
return False;
}
if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) {
- TALLOC_FREE(pwd);
return False;
}
- TALLOC_FREE(pwd);
-
return True;
}
{
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.hash, PDB_CHANGED)) {
- TALLOC_FREE(pwd);
return False;
}
if (!pdb_set_nt_passwd (pwd, id18->nt_pwd.hash, PDB_CHANGED)) {
- TALLOC_FREE(pwd);
return False;
}
if (!pdb_set_pass_last_set_time (pwd, time(NULL), PDB_CHANGED)) {
- TALLOC_FREE(pwd);
return False;
}
if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) {
- TALLOC_FREE(pwd);
return False;
}
- TALLOC_FREE(pwd);
return True;
}
/* write the change out */
if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) {
- TALLOC_FREE(pwd);
return False;
}
- TALLOC_FREE(pwd);
-
return True;
}
return NT_STATUS_INVALID_PARAMETER;
}
+ if (id21->fields_present == 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (id21->fields_present & SAMR_FIELD_LAST_PWD_CHANGE) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
/* we need to separately check for an account rename first */
if (id21->account_name.string &&
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("set_user_info_21: failed to rename account: %s\n",
nt_errstr(status)));
- TALLOC_FREE(pwd);
return status;
}
/* write the change out */
if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) {
- TALLOC_FREE(pwd);
return status;
}
- TALLOC_FREE(pwd);
-
return NT_STATUS_OK;
}
return NT_STATUS_INVALID_PARAMETER;
}
+ if (id23->info.fields_present == 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (id23->info.fields_present & SAMR_FIELD_LAST_PWD_CHANGE) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+
DEBUG(5, ("Attempting administrator password change (level 23) for user %s\n",
pdb_get_username(pwd)));
&plaintext_buf,
&len,
STR_UNICODE)) {
- TALLOC_FREE(pwd);
- return NT_STATUS_INVALID_PARAMETER;
+ return NT_STATUS_WRONG_PASSWORD;
}
if (!pdb_set_plaintext_passwd (pwd, plaintext_buf)) {
- TALLOC_FREE(pwd);
return NT_STATUS_ACCESS_DENIED;
}
struct passwd *passwd;
if (pdb_get_username(pwd) == NULL) {
DEBUG(1, ("chgpasswd: User without name???\n"));
- TALLOC_FREE(pwd);
return NT_STATUS_ACCESS_DENIED;
}
}
if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) {
- TALLOC_FREE(pwd);
return NT_STATUS_ACCESS_DENIED;
}
TALLOC_FREE(passwd);
if (IS_SAM_CHANGED(pwd, PDB_GROUPSID) &&
(!NT_STATUS_IS_OK(status = pdb_set_unix_primary_group(mem_ctx,
pwd)))) {
- TALLOC_FREE(pwd);
return status;
}
if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) {
- TALLOC_FREE(pwd);
return status;
}
- TALLOC_FREE(pwd);
-
return NT_STATUS_OK;
}
&plaintext_buf,
&len,
STR_UNICODE)) {
- TALLOC_FREE(pwd);
return False;
}
if (!pdb_set_plaintext_passwd (pwd, plaintext_buf)) {
- TALLOC_FREE(pwd);
return False;
}
if (pdb_get_username(pwd) == NULL) {
DEBUG(1, ("chgpasswd: User without name???\n"));
- TALLOC_FREE(pwd);
return False;
}
}
if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) {
- TALLOC_FREE(pwd);
return False;
}
TALLOC_FREE(passwd);
/* update the SAMBA password */
if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) {
- TALLOC_FREE(pwd);
return False;
}
- TALLOC_FREE(pwd);
-
return True;
}
return NT_STATUS_INVALID_PARAMETER;
}
+ if (id25->info.fields_present == 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (id25->info.fields_present & SAMR_FIELD_LAST_PWD_CHANGE) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
copy_id25_to_sam_passwd(pwd, id25);
/* write the change out */
if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) {
- TALLOC_FREE(pwd);
return status;
}
}
}
- /* WARNING: No TALLOC_FREE(pwd), we are about to set the password
- * hereafter! */
-
return NT_STATUS_OK;
}
if (!set_user_info_pw(info->info24.password.data, pwd,
switch_value)) {
- status = NT_STATUS_ACCESS_DENIED;
+ status = NT_STATUS_WRONG_PASSWORD;
}
break;
}
if (!set_user_info_pw(info->info25.password.data, pwd,
switch_value)) {
- status = NT_STATUS_ACCESS_DENIED;
+ status = NT_STATUS_WRONG_PASSWORD;
}
break;
if (!set_user_info_pw(info->info26.password.data, pwd,
switch_value)) {
- status = NT_STATUS_ACCESS_DENIED;
+ status = NT_STATUS_WRONG_PASSWORD;
}
break;
done:
+ TALLOC_FREE(pwd);
+
if (has_enough_rights) {
unbecome_root();
}