s3-samr: support some more info levels in samr_SetUserInfo calls.
authorGünther Deschner <gd@samba.org>
Thu, 7 May 2009 15:06:26 +0000 (17:06 +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 eaaca56c0459467bfd3cbdf871591a48d4953996..24078d1cfbcf98c6ca64d6c534840f38235b9651 100644 (file)
@@ -5817,6 +5817,26 @@ NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
 
 /* The following definitions come from rpc_server/srv_samr_util.c  */
 
+void copy_id2_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo2 *from);
+void copy_id4_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo4 *from);
+void copy_id6_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo6 *from);
+void copy_id8_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo8 *from);
+void copy_id10_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo10 *from);
+void copy_id11_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo11 *from);
+void copy_id12_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo12 *from);
+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_id17_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo17 *from);
 void copy_id18_to_sam_passwd(struct samu *to,
                             struct samr_UserInfo18 *from);
 void copy_id20_to_sam_passwd(struct samu *to,
index adc2651ee2e882f65d5bcde13df4cb88fd77ccd7..c3d9dafc4b7882441e0015301760a3d0c5bbbb78 100644 (file)
@@ -3672,6 +3672,60 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p,
        return NT_STATUS_OK;
 }
 
+/*******************************************************************
+ set_user_info_2
+ ********************************************************************/
+
+static NTSTATUS set_user_info_2(TALLOC_CTX *mem_ctx,
+                               struct samr_UserInfo2 *id2,
+                               struct samu *pwd)
+{
+       if (id2 == NULL) {
+               DEBUG(5,("set_user_info_2: NULL id2\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id2_to_sam_passwd(pwd, id2);
+
+       return pdb_update_sam_account(pwd);
+}
+
+/*******************************************************************
+ set_user_info_4
+ ********************************************************************/
+
+static NTSTATUS set_user_info_4(TALLOC_CTX *mem_ctx,
+                               struct samr_UserInfo4 *id4,
+                               struct samu *pwd)
+{
+       if (id4 == NULL) {
+               DEBUG(5,("set_user_info_2: NULL id4\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id4_to_sam_passwd(pwd, id4);
+
+       return pdb_update_sam_account(pwd);
+}
+
+/*******************************************************************
+ set_user_info_6
+ ********************************************************************/
+
+static NTSTATUS set_user_info_6(TALLOC_CTX *mem_ctx,
+                               struct samr_UserInfo6 *id6,
+                               struct samu *pwd)
+{
+       if (id6 == NULL) {
+               DEBUG(5,("set_user_info_6: NULL id6\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id6_to_sam_passwd(pwd, id6);
+
+       return pdb_update_sam_account(pwd);
+}
+
 /*******************************************************************
  set_user_info_7
  ********************************************************************/
@@ -3711,6 +3765,114 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx,
        return rc;
 }
 
+/*******************************************************************
+ set_user_info_8
+ ********************************************************************/
+
+static NTSTATUS set_user_info_8(TALLOC_CTX *mem_ctx,
+                               struct samr_UserInfo8 *id8,
+                               struct samu *pwd)
+{
+       if (id8 == NULL) {
+               DEBUG(5,("set_user_info_8: NULL id8\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id8_to_sam_passwd(pwd, id8);
+
+       return pdb_update_sam_account(pwd);
+}
+
+/*******************************************************************
+ set_user_info_10
+ ********************************************************************/
+
+static NTSTATUS set_user_info_10(TALLOC_CTX *mem_ctx,
+                                struct samr_UserInfo10 *id10,
+                                struct samu *pwd)
+{
+       if (id10 == NULL) {
+               DEBUG(5,("set_user_info_8: NULL id10\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id10_to_sam_passwd(pwd, id10);
+
+       return pdb_update_sam_account(pwd);
+}
+
+/*******************************************************************
+ set_user_info_11
+ ********************************************************************/
+
+static NTSTATUS set_user_info_11(TALLOC_CTX *mem_ctx,
+                                struct samr_UserInfo11 *id11,
+                                struct samu *pwd)
+{
+       if (id11 == NULL) {
+               DEBUG(5,("set_user_info_11: NULL id11\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id11_to_sam_passwd(pwd, id11);
+
+       return pdb_update_sam_account(pwd);
+}
+
+/*******************************************************************
+ set_user_info_12
+ ********************************************************************/
+
+static NTSTATUS set_user_info_12(TALLOC_CTX *mem_ctx,
+                                struct samr_UserInfo12 *id12,
+                                struct samu *pwd)
+{
+       if (id12 == NULL) {
+               DEBUG(5,("set_user_info_12: NULL id12\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id12_to_sam_passwd(pwd, id12);
+
+       return pdb_update_sam_account(pwd);
+}
+
+/*******************************************************************
+ set_user_info_13
+ ********************************************************************/
+
+static NTSTATUS set_user_info_13(TALLOC_CTX *mem_ctx,
+                                struct samr_UserInfo13 *id13,
+                                struct samu *pwd)
+{
+       if (id13 == NULL) {
+               DEBUG(5,("set_user_info_13: NULL id13\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id13_to_sam_passwd(pwd, id13);
+
+       return pdb_update_sam_account(pwd);
+}
+
+/*******************************************************************
+ set_user_info_14
+ ********************************************************************/
+
+static NTSTATUS set_user_info_14(TALLOC_CTX *mem_ctx,
+                                struct samr_UserInfo14 *id14,
+                                struct samu *pwd)
+{
+       if (id14 == NULL) {
+               DEBUG(5,("set_user_info_14: NULL id14\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id14_to_sam_passwd(pwd, id14);
+
+       return pdb_update_sam_account(pwd);
+}
+
 /*******************************************************************
  set_user_info_16
  ********************************************************************/
@@ -3735,6 +3897,24 @@ static bool set_user_info_16(struct samr_UserInfo16 *id16,
        return True;
 }
 
+/*******************************************************************
+ set_user_info_17
+ ********************************************************************/
+
+static NTSTATUS set_user_info_17(TALLOC_CTX *mem_ctx,
+                                struct samr_UserInfo17 *id17,
+                                struct samu *pwd)
+{
+       if (id17 == NULL) {
+               DEBUG(5,("set_user_info_17: NULL id17\n"));
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
+       copy_id17_to_sam_passwd(pwd, id17);
+
+       return pdb_update_sam_account(pwd);
+}
+
 /*******************************************************************
  set_user_info_18
  ********************************************************************/
@@ -4311,17 +4491,67 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p,
 
        switch (switch_value) {
 
+               case 2:
+                       status = set_user_info_2(p->mem_ctx,
+                                                &info->info2, pwd);
+                       break;
+
+               case 4:
+                       status = set_user_info_4(p->mem_ctx,
+                                                &info->info4, pwd);
+                       break;
+
+               case 6:
+                       status = set_user_info_6(p->mem_ctx,
+                                                &info->info6, pwd);
+                       break;
+
                case 7:
                        status = set_user_info_7(p->mem_ctx,
                                                 &info->info7, pwd);
                        break;
 
+               case 8:
+                       status = set_user_info_8(p->mem_ctx,
+                                                &info->info8, pwd);
+                       break;
+
+               case 10:
+                       status = set_user_info_10(p->mem_ctx,
+                                                 &info->info10, pwd);
+                       break;
+
+               case 11:
+                       status = set_user_info_11(p->mem_ctx,
+                                                 &info->info11, pwd);
+                       break;
+
+               case 12:
+                       status = set_user_info_12(p->mem_ctx,
+                                                 &info->info12, pwd);
+                       break;
+
+               case 13:
+                       status = set_user_info_13(p->mem_ctx,
+                                                 &info->info13, pwd);
+                       break;
+
+               case 14:
+                       status = set_user_info_14(p->mem_ctx,
+                                                 &info->info14, pwd);
+                       break;
+
                case 16:
                        if (!set_user_info_16(&info->info16, pwd)) {
                                status = NT_STATUS_ACCESS_DENIED;
                        }
                        break;
 
+               case 17:
+                       status = set_user_info_17(p->mem_ctx,
+                                                 &info->info17, pwd);
+                       break;
+
                case 18:
                        /* Used by AS/U JRA. */
                        status = set_user_info_18(&info->info18,
index 068156054f00ccaffe289fc30a49656399dbfb48..5dad3bdc70bb84b6d4fe488e972db0b5d5acd92d 100644 (file)
                    (!(s1) && (s2)) ||\
                ((s1) && (s2) && (strcmp((s1), (s2)) != 0))
 
+/*************************************************************
+ Copies a struct samr_UserInfo2 to a struct samu
+**************************************************************/
+
+void copy_id2_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo2 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_COMMENT |
+                                 SAMR_FIELD_COUNTRY_CODE |
+                                 SAMR_FIELD_CODE_PAGE;
+       i.comment               = from->comment;
+       i.country_code          = from->country_code;
+       i.code_page             = from->code_page;
+
+       copy_id21_to_sam_passwd("INFO_2", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo4 to a struct samu
+**************************************************************/
+
+void copy_id4_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo4 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_LOGON_HOURS;
+       i.logon_hours           = from->logon_hours;
+
+       copy_id21_to_sam_passwd("INFO_4", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo6 to a struct samu
+**************************************************************/
+
+void copy_id6_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo6 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_ACCOUNT_NAME |
+                                 SAMR_FIELD_FULL_NAME;
+       i.account_name          = from->account_name;
+       i.full_name             = from->full_name;
+
+       copy_id21_to_sam_passwd("INFO_6", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo8 to a struct samu
+**************************************************************/
+
+void copy_id8_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo8 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_FULL_NAME;
+       i.full_name             = from->full_name;
+
+       copy_id21_to_sam_passwd("INFO_8", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo10 to a struct samu
+**************************************************************/
+
+void copy_id10_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo10 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_HOME_DIRECTORY |
+                                 SAMR_FIELD_HOME_DRIVE;
+       i.home_directory        = from->home_directory;
+       i.home_drive            = from->home_drive;
+
+       copy_id21_to_sam_passwd("INFO_10", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo11 to a struct samu
+**************************************************************/
+
+void copy_id11_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo11 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_LOGON_SCRIPT;
+       i.logon_script          = from->logon_script;
+
+       copy_id21_to_sam_passwd("INFO_11", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo12 to a struct samu
+**************************************************************/
+
+void copy_id12_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo12 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_PROFILE_PATH;
+       i.profile_path          = from->profile_path;
+
+       copy_id21_to_sam_passwd("INFO_12", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo13 to a struct samu
+**************************************************************/
+
+void copy_id13_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo13 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_DESCRIPTION;
+       i.description           = from->description;
+
+       copy_id21_to_sam_passwd("INFO_13", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo14 to a struct samu
+**************************************************************/
+
+void copy_id14_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo14 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_WORKSTATIONS;
+       i.workstations          = from->workstations;
+
+       copy_id21_to_sam_passwd("INFO_14", to, &i);
+}
+
+/*************************************************************
+ Copies a struct samr_UserInfo17 to a struct samu
+**************************************************************/
+
+void copy_id17_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo17 *from)
+{
+       struct samr_UserInfo21 i;
+
+       if (from == NULL || to == NULL) {
+               return;
+       }
+
+       ZERO_STRUCT(i);
+
+       i.fields_present        = SAMR_FIELD_ACCT_EXPIRY;
+       i.acct_expiry           = from->acct_expiry;
+
+       copy_id21_to_sam_passwd("INFO_17", to, &i);
+}
+
 /*************************************************************
  Copies a struct samr_UserInfo18 to a struct samu
 **************************************************************/