dce/rpc
authorLuke Leighton <lkcl@samba.org>
Sat, 10 Oct 1998 00:58:12 +0000 (00:58 +0000)
committerLuke Leighton <lkcl@samba.org>
Sat, 10 Oct 1998 00:58:12 +0000 (00:58 +0000)
(This used to be commit b0af7cfd9dea8d286f430c51456b5f67d5e0658a)

source3/include/proto.h
source3/rpcclient/cmd_samr.c
source3/rpcclient/rpcclient.c

index 9e2d4d33b0668d890189ac87911fe3acc3b96013..e5947805356622facb86f73ca99a919261ba8a0b 100644 (file)
@@ -1732,8 +1732,8 @@ void make_enc_hash(SAMR_ENC_HASH *hsh, char hash[16]);
 void samr_io_enc_hash(char *desc, SAMR_ENC_HASH *hsh, prs_struct *ps, int depth);
 void make_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u,
                                char *dest_host, char *user_name,
-                               char lm_newpass[516], char nt_oldhash[16],
-                               char nt_newpass[516], char lm_oldhash[16]);
+                               char nt_newpass[516], char nt_oldhash[16],
+                               char lm_newpass[516], char lm_oldhash[16]);
 void samr_io_q_chgpasswd_user(char *desc, SAMR_Q_CHGPASSWD_USER *q_u, prs_struct *ps, int depth);
 void samr_io_r_chgpasswd_user(char *desc, SAMR_R_CHGPASSWD_USER *r_u, prs_struct *ps, int depth);
 
@@ -1904,6 +1904,7 @@ void cmd_lsa_lookup_sids(struct client_info *info);
 
 /*The following definitions come from  rpcclient/cmd_samr.c  */
 
+void cmd_sam_ntchange_pwd(struct client_info *info);
 void cmd_sam_test(struct client_info *info);
 void cmd_sam_enum_users(struct client_info *info);
 void cmd_sam_query_user(struct client_info *info);
index 86a5619540148a6d082eddd6cf3dabf6ba7a840b..81fd37361317376583c344246cdc959d2d39a155 100644 (file)
@@ -39,9 +39,9 @@ extern FILE* out_hnd;
 
 
 /****************************************************************************
-experimental SAM encryted rpc test connection
+SAM password change
 ****************************************************************************/
-void cmd_sam_test(struct client_info *info)
+void cmd_sam_ntchange_pwd(struct client_info *info)
 {
        fstring srv_name;
        fstring domain;
@@ -60,23 +60,17 @@ void cmd_sam_test(struct client_info *info)
        fstrcpy(sid   , info->dom.level5_sid);
        fstrcpy(domain, info->dom.level5_dom);
 
-       if (strlen(sid) == 0)
-       {
-               fprintf(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
-               return;
-       }
-
        fstrcpy(srv_name, "\\\\");
        fstrcat(srv_name, info->dest_host);
        strupper(srv_name);
 
-       fprintf(out_hnd, "SAM Encryption Test\n");
+       fprintf(out_hnd, "SAM NT Password Change\n");
 
 #if 0
        struct pwd_info new_pwd;
        pwd_read(&new_pwd, "New Password (ONCE: this is test code!):", True);
 #endif
-       new_passwd = (char*)getpass("New Password (ONCE: this is test code!):");
+       new_passwd = (char*)getpass("New Password (ONCE ONLY - get it right :-)");
 
        nt_lm_owf_gen(new_passwd, lm_newhash, nt_newhash);
        pwd_get_lm_nt_16(&(smb_cli->pwd), lm_oldhash, nt_oldhash );
@@ -100,6 +94,52 @@ void cmd_sam_test(struct client_info *info)
        /* close the session */
        cli_nt_session_close(smb_cli);
 
+       if (res)
+       {
+               DEBUG(5,("cmd_sam_ntpasswd_chg: succeeded\n"));
+       }
+       else
+       {
+               DEBUG(5,("cmd_sam_ntpasswd_chg: failed\n"));
+       }
+}
+
+
+/****************************************************************************
+experimental SAM encryted rpc test connection
+****************************************************************************/
+void cmd_sam_test(struct client_info *info)
+{
+       fstring srv_name;
+       fstring domain;
+       fstring sid;
+       char *new_passwd;
+       BOOL res = True;
+
+       fstrcpy(sid   , info->dom.level5_sid);
+       fstrcpy(domain, info->dom.level5_dom);
+
+       if (strlen(sid) == 0)
+       {
+               fprintf(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
+               return;
+       }
+
+       fstrcpy(srv_name, "\\\\");
+       fstrcat(srv_name, info->dest_host);
+       strupper(srv_name);
+
+       fprintf(out_hnd, "SAM Encryption Test\n");
+
+       /* open SAMR session.  */
+       res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, True) : False;
+
+       /* establish a connection. */
+       res = res ? do_samr_unknown_38(smb_cli, srv_name) : False;
+
+       /* close the session */
+       cli_nt_session_close(smb_cli);
+
        if (res)
        {
                DEBUG(5,("cmd_sam_test: succeeded\n"));
index 9d657e923d823f9147ce4c3fdf9a2587e81cad97..a31fd60b0c5421ff8bd870930e106a3e61e43305 100644 (file)
@@ -117,6 +117,7 @@ struct
   {"lsaquery",   cmd_lsa_query_info,   "Query Info Policy (domain member or server)"},
   {"lookupsids", cmd_lsa_lookup_sids,  "Resolve names from SIDs"},
   {"enumusers",  cmd_sam_enum_users,   "SAM User Database Query (experimental!)"},
+  {"ntpass",     cmd_sam_ntchange_pwd, "NT SAM Password Change"},
   {"samuser",    cmd_sam_query_user,   "<username> SAM User Query (experimental!)"},
   {"samtest",    cmd_sam_test      ,   "SAM User Encrypted RPC test (experimental!)"},
   {"enumaliases",cmd_sam_enum_aliases, "SAM Aliases Database Query (experimental!)"},