s3-samr: let set_user_info_16 and 20 follow the same pattern as all other levels.
authorGünther Deschner <gd@samba.org>
Thu, 7 May 2009 19:45:51 +0000 (21:45 +0200)
committerGünther Deschner <gd@samba.org>
Thu, 7 May 2009 22:41:40 +0000 (00:41 +0200)
Guenther

source3/include/proto.h
source3/rpc_server/srv_samr_nt.c
source3/rpc_server/srv_samr_util.c

index 24078d1cfbcf98c6ca64d6c534840f38235b9651..3c14fb5a41b9afba339318b34b3c68e437dca876 100644 (file)
@@ -5835,6 +5835,8 @@ void copy_id13_to_sam_passwd(struct samu *to,
                             struct samr_UserInfo13 *from);
 void copy_id14_to_sam_passwd(struct samu *to,
                             struct samr_UserInfo14 *from);
+void copy_id16_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo16 *from);
 void copy_id17_to_sam_passwd(struct samu *to,
                             struct samr_UserInfo17 *from);
 void copy_id18_to_sam_passwd(struct samu *to,
index c3d9dafc4b7882441e0015301760a3d0c5bbbb78..e0ba51c68ac27e3d87263d40d88848e77d1ada68 100644 (file)
@@ -3877,24 +3877,18 @@ static NTSTATUS set_user_info_14(TALLOC_CTX *mem_ctx,
  set_user_info_16
  ********************************************************************/
 
-static bool set_user_info_16(struct samr_UserInfo16 *id16,
-                            struct samu *pwd)
+static NTSTATUS set_user_info_16(TALLOC_CTX *mem_ctx,
+                                struct samr_UserInfo16 *id16,
+                                struct samu *pwd)
 {
        if (id16 == NULL) {
-               DEBUG(5, ("set_user_info_16: NULL id16\n"));
-               return False;
+               DEBUG(5,("set_user_info_16: NULL id16\n"));
+               return NT_STATUS_ACCESS_DENIED;
        }
 
-       /* FIX ME: check if the value is really changed --metze */
-       if (!pdb_set_acct_ctrl(pwd, id16->acct_flags, PDB_CHANGED)) {
-               return False;
-       }
+       copy_id16_to_sam_passwd(pwd, id16);
 
-       if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) {
-               return False;
-       }
-
-       return True;
+       return pdb_update_sam_account(pwd);
 }
 
 /*******************************************************************
@@ -3976,22 +3970,18 @@ static NTSTATUS set_user_info_18(struct samr_UserInfo18 *id18,
  set_user_info_20
  ********************************************************************/
 
-static bool set_user_info_20(struct samr_UserInfo20 *id20,
-                            struct samu *pwd)
+static NTSTATUS set_user_info_20(TALLOC_CTX *mem_ctx,
+                                struct samr_UserInfo20 *id20,
+                                struct samu *pwd)
 {
        if (id20 == NULL) {
-               DEBUG(5, ("set_user_info_20: NULL id20\n"));
-               return False;
+               DEBUG(5,("set_user_info_20: NULL id20\n"));
+               return NT_STATUS_ACCESS_DENIED;
        }
 
        copy_id20_to_sam_passwd(pwd, id20);
 
-       /* write the change out */
-       if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) {
-               return False;
-       }
-
-       return True;
+       return pdb_update_sam_account(pwd);
 }
 
 /*******************************************************************
@@ -4542,9 +4532,8 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p,
                        break;
 
                case 16:
-                       if (!set_user_info_16(&info->info16, pwd)) {
-                               status = NT_STATUS_ACCESS_DENIED;
-                       }
+                       status = set_user_info_16(p->mem_ctx,
+                                                 &info->info16, pwd);
                        break;
 
                case 17:
@@ -4561,9 +4550,8 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p,
                        break;
 
                case 20:
-                       if (!set_user_info_20(&info->info20, pwd)) {
-                               status = NT_STATUS_ACCESS_DENIED;
-                       }
+                       status = set_user_info_20(p->mem_ctx,
+                                                 &info->info20, pwd);
                        break;
 
                case 21:
index 5dad3bdc70bb84b6d4fe488e972db0b5d5acd92d..8f136b12165d4846f6edc7cc5b37db699eda64a2 100644 (file)
@@ -232,6 +232,27 @@ void copy_id14_to_sam_passwd(struct samu *to,
        copy_id21_to_sam_passwd("INFO_14", to, &i);
 }
 
+/*************************************************************
+ Copies a struct samr_UserInfo16 to a struct samu
+**************************************************************/
+
+void copy_id16_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo16 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_ACCT_FLAGS;
+       i.acct_flags            = from->acct_flags;
+
+       copy_id21_to_sam_passwd("INFO_16", to, &i);
+}
+
 /*************************************************************
  Copies a struct samr_UserInfo17 to a struct samu
 **************************************************************/