s3-rpc_client: Added dcerpc_samr_chgpasswd_user2.
authorAndreas Schneider <asn@samba.org>
Wed, 12 Jan 2011 07:46:28 +0000 (08:46 +0100)
committerAndreas Schneider <asn@samba.org>
Fri, 21 Jan 2011 13:34:17 +0000 (14:34 +0100)
source3/rpc_client/cli_samr.c
source3/rpc_client/cli_samr.h

index 03acafe515515049ed08397b9843eb9a7702148f..236981a2f1f2c4fd17edbf98683d48b9f0cfa605 100644 (file)
@@ -107,27 +107,29 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
 
 /* User change password */
 
-NTSTATUS rpccli_samr_chgpasswd_user2(struct rpc_pipe_client *cli,
+NTSTATUS dcerpc_samr_chgpasswd_user2(struct dcerpc_binding_handle *h,
                                     TALLOC_CTX *mem_ctx,
+                                    const char *srv_name_slash,
                                     const char *username,
                                     const char *newpassword,
-                                    const char *oldpassword)
+                                    const char *oldpassword,
+                                    NTSTATUS *presult)
 {
-       NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+       NTSTATUS status;
        struct samr_CryptPassword new_nt_password;
        struct samr_CryptPassword new_lm_password;
        struct samr_Password old_nt_hash_enc;
        struct samr_Password old_lanman_hash_enc;
 
-       uchar old_nt_hash[16];
-       uchar old_lanman_hash[16];
-       uchar new_nt_hash[16];
-       uchar new_lanman_hash[16];
+       uint8_t old_nt_hash[16];
+       uint8_t old_lanman_hash[16];
+       uint8_t new_nt_hash[16];
+       uint8_t new_lanman_hash[16];
        struct lsa_String server, account;
 
        DEBUG(10,("rpccli_samr_chgpasswd_user2\n"));
 
-       init_lsa_String(&server, cli->srv_name_slash);
+       init_lsa_String(&server, srv_name_slash);
        init_lsa_String(&account, username);
 
        /* Calculate the MD4 hash (NT compatible) of the password */
@@ -156,14 +158,39 @@ NTSTATUS rpccli_samr_chgpasswd_user2(struct rpc_pipe_client *cli,
        arcfour_crypt(new_nt_password.data, old_nt_hash, 516);
        E_old_pw_hash(new_nt_hash, old_nt_hash, old_nt_hash_enc.hash);
 
-       result = rpccli_samr_ChangePasswordUser2(cli, mem_ctx,
+       status = dcerpc_samr_ChangePasswordUser2(h,
+                                                mem_ctx,
                                                 &server,
                                                 &account,
                                                 &new_nt_password,
                                                 &old_nt_hash_enc,
                                                 true,
                                                 &new_lm_password,
-                                                &old_lanman_hash_enc);
+                                                &old_lanman_hash_enc,
+                                                presult);
+
+       return status;
+}
+
+NTSTATUS rpccli_samr_chgpasswd_user2(struct rpc_pipe_client *cli,
+                                    TALLOC_CTX *mem_ctx,
+                                    const char *username,
+                                    const char *newpassword,
+                                    const char *oldpassword)
+{
+       NTSTATUS status;
+       NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
+       status = dcerpc_samr_chgpasswd_user2(cli->binding_handle,
+                                            mem_ctx,
+                                            cli->srv_name_slash,
+                                            username,
+                                            newpassword,
+                                            oldpassword,
+                                            &result);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        return result;
 }
index aa0e5f9883f12322bab8fe636b6d6e7dce6a7c98..d73171209b178d3c8040c3b37dd31a1aba6f3e91 100644 (file)
@@ -58,6 +58,34 @@ NTSTATUS rpccli_samr_chgpasswd_user(struct rpc_pipe_client *cli,
                                    struct policy_handle *user_handle,
                                    const char *newpassword,
                                    const char *oldpassword);
+
+/**
+ * @brief Change the password of a user based on username.
+ *
+ * @param[in]  h        The dcerpc binding hanlde to use.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @param[in]  srv_name_slash The server name with leading slashes.
+ *
+ * @param[in]  username The name of ther user.
+ *
+ * @param[in]  newpassword The new password to set.
+ *
+ * @param[in]  oldpassword The old password for verification
+ *
+ * @param[out] presult  A pointer for the NDR NTSTATUS error code.
+ *
+ * @return              A corresponding NTSTATUS error code for the connection.
+ */
+NTSTATUS dcerpc_samr_chgpasswd_user2(struct dcerpc_binding_handle *h,
+                                    TALLOC_CTX *mem_ctx,
+                                    const char *srv_name_slash,
+                                    const char *username,
+                                    const char *newpassword,
+                                    const char *oldpassword,
+                                    NTSTATUS *presult);
+
 NTSTATUS rpccli_samr_chgpasswd_user2(struct rpc_pipe_client *cli,
                                     TALLOC_CTX *mem_ctx,
                                     const char *username,