"User Manager" - create user + change password now work.
authorLuke Leighton <lkcl@samba.org>
Thu, 25 Mar 1999 21:32:04 +0000 (21:32 +0000)
committerLuke Leighton <lkcl@samba.org>
Thu, 25 Mar 1999 21:32:04 +0000 (21:32 +0000)
next problem: user group adding not supported so an "access denied"
message is reported instead of "ok" when a new user is created.

source/include/proto.h
source/passdb/sampassdb.c
source/rpc_server/srv_samr.c

index caf53667c8810ef5f557117aa6345fc404b17140..94d76b9e9f4bbe8d97705f0212223eae170e879a 100644 (file)
@@ -1516,6 +1516,7 @@ struct sam_passwd *getsam21pwntnam(const char *name);
 struct sam_passwd *getsam21pwrid(uint32 rid);
 void pwdb_init_sam(struct sam_passwd *user);
 struct sam_disp_info *pwdb_sam_to_dispinfo(struct sam_passwd *user);
+void copy_id23_to_sam_passwd(struct sam_passwd *to, const SAM_USER_INFO_23 *from);
 void copy_sam_passwd(struct sam_passwd *to, const struct sam_passwd *from);
 struct smb_passwd *pwdb_sam_to_smb(struct sam_passwd *user);
 struct sam_passwd *pwdb_smb_to_sam(struct smb_passwd *user);
index 13474eda78209a71c24a2a1073cf14fd6258c431..e8a92d778d2a00c63575ccc0540d81655d0e0d27 100644 (file)
@@ -342,6 +342,48 @@ struct sam_disp_info *pwdb_sam_to_dispinfo(struct sam_passwd *user)
        return &disp_info;
 }
 
+static void select_name(fstring string, char **name, const UNISTR2 *from)
+{
+       if (from->buffer != 0)
+       {
+               unistr2_to_ascii(string, from, sizeof(string));
+               *name = string;
+       }
+}
+
+/*************************************************************
+ copies a sam passwd.
+ **************************************************************/
+void copy_id23_to_sam_passwd(struct sam_passwd *to, const SAM_USER_INFO_23 *from)
+{
+       static fstring nt_name;
+       static fstring full_name;
+       static fstring home_dir;
+       static fstring dir_drive;
+       static fstring logon_script;
+       static fstring profile_path;
+       static fstring acct_desc;
+       static fstring workstations;
+       static fstring unknown_str;
+       static fstring munged_dial;
+
+       if (from == NULL || to == NULL) return;
+
+       memcpy(to, from, sizeof(*from));
+
+       select_name(nt_name     , &to->nt_name     , &from->uni_user_name   );
+       select_name(full_name   , &to->full_name   , &from->uni_full_name   );
+       select_name(home_dir    , &to->home_dir    , &from->uni_home_dir    );
+       select_name(dir_drive   , &to->dir_drive   , &from->uni_dir_drive   );
+       select_name(logon_script, &to->logon_script, &from->uni_logon_script);
+       select_name(profile_path, &to->profile_path, &from->uni_profile_path);
+       select_name(acct_desc   , &to->acct_desc   , &from->uni_acct_desc   );
+       select_name(workstations, &to->workstations, &from->uni_workstations);
+       select_name(unknown_str , &to->unknown_str , &from->uni_unknown_str );
+       select_name(munged_dial , &to->munged_dial , &from->uni_munged_dial );
+}
+
+
 /*************************************************************
  copies a sam passwd.
  **************************************************************/
index 15b2159383e9d117924a64e8f1494f8eb15f4720..63aa0dc91452bb3ed7808a54f06795e01b147122 100644 (file)
@@ -1984,20 +1984,38 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid)
  ********************************************************************/
 static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
 {
-       static struct sam_passwd *pwd;
-       fstring new_pw;
+       struct sam_passwd *pwd = getsam21pwrid(rid);
+       struct sam_passwd new_pwd;
+       static uchar nt_hash[16];
+       static uchar lm_hash[16];
+       pstring new_pw;
+
+       if (pwd == NULL)
+       {
+               return False;
+       }
+
+       pwdb_init_sam(&new_pwd);
+       copy_sam_passwd(&new_pwd, pwd);
+#if 0
+       copy_id23_to_sam_passwd(&new_pwd, id23);
+#endif
+
        if (!decode_pw_buffer(id23->pass, new_pw, sizeof(new_pw), True))
        {
                return False;
        }
+
 #ifdef DEBUG_PASSWORD
        DEBUG(0,("New Password: %s\n", new_pw));
 #endif
-#if 0
-       return mod_sam21pwd_entry(&pwd, True);
-#else
-       return True;
-#endif
+
+       nt_lm_owf_gen(new_pw, nt_hash, lm_hash);
+
+       new_pwd.smb_passwd    = lm_hash;
+       new_pwd.smb_nt_passwd = nt_hash;
+
+       return mod_sam21pwd_entry(&new_pwd, True);
 }
 
 /*******************************************************************