rpc_client: add rpccli_samr_chgpasswd_user() call.
authorGünther Deschner <gd@samba.org>
Wed, 25 Jun 2008 09:50:17 +0000 (11:50 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 25 Jun 2008 21:58:50 +0000 (23:58 +0200)
Guenther
(This used to be commit 10fd2baa8320f96286d53b677cf38f3ca3aa88a7)

source3/include/proto.h
source3/rpc_client/cli_samr.c

index 42277277b0d2c2b7184c6599846bde11b25e90e9..1eb5fbda03736ee92820583768816116ec72d011 100644 (file)
@@ -7144,6 +7144,11 @@ uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val );
 
 /* The following definitions come from rpc_client/cli_samr.c  */
 
+NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
+                                   TALLOC_CTX *mem_ctx,
+                                   struct policy_handle *user_handle,
+                                   const char *newpassword,
+                                   const char *oldpassword);
 NTSTATUS rpccli_samr_chgpasswd_user2(struct rpc_pipe_client *cli,
                                     TALLOC_CTX *mem_ctx,
                                     const char *username,
index d0c71c5bb1a162afda3a118ddd3cf1a05c854d43..ed42d56a0251f2eea8836520025f171a4e3ebae5 100644 (file)
 
 #include "includes.h"
 
+/* User change password */
+
+NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
+                                   TALLOC_CTX *mem_ctx,
+                                   struct policy_handle *user_handle,
+                                   const char *newpassword,
+                                   const char *oldpassword)
+{
+       NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+       struct samr_Password hash1, hash2, hash3, hash4, hash5, hash6;
+
+       uchar old_nt_hash[16];
+       uchar old_lm_hash[16];
+       uchar new_nt_hash[16];
+       uchar new_lm_hash[16];
+
+       ZERO_STRUCT(old_nt_hash);
+       ZERO_STRUCT(old_lm_hash);
+       ZERO_STRUCT(new_nt_hash);
+       ZERO_STRUCT(new_lm_hash);
+
+       DEBUG(10,("rpccli_samr_chgpasswd_user\n"));
+
+       E_md4hash(oldpassword, old_nt_hash);
+       E_md4hash(newpassword, new_nt_hash);
+
+       E_deshash(oldpassword, old_lm_hash);
+       E_deshash(newpassword, new_lm_hash);
+
+       E_old_pw_hash(new_lm_hash, old_lm_hash, hash1.hash);
+       E_old_pw_hash(old_lm_hash, new_lm_hash, hash2.hash);
+       E_old_pw_hash(new_nt_hash, old_nt_hash, hash3.hash);
+       E_old_pw_hash(old_nt_hash, new_nt_hash, hash4.hash);
+       E_old_pw_hash(old_lm_hash, new_nt_hash, hash5.hash);
+       E_old_pw_hash(old_nt_hash, new_lm_hash, hash6.hash);
+
+       result = rpccli_samr_ChangePasswordUser(cli, mem_ctx,
+                                               user_handle,
+                                               true,
+                                               &hash1,
+                                               &hash2,
+                                               true,
+                                               &hash3,
+                                               &hash4,
+                                               true,
+                                               &hash5,
+                                               true,
+                                               &hash6);
+
+       return result;
+}
+
+
 /* User change password */
 
 NTSTATUS rpccli_samr_chgpasswd_user2(struct rpc_pipe_client *cli,