]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpcclient: Implement cmd chpasswd4
authorAndreas Schneider <asn@samba.org>
Mon, 11 Jul 2022 13:24:59 +0000 (15:24 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 28 Jul 2022 11:51:29 +0000 (11:51 +0000)
Manually tested against Windows Server 2022.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
docs-xml/manpages/rpcclient.1.xml
source3/rpcclient/cmd_samr.c

index cc654e35803f15f1bddf50e56e453a2cec7b8882..e57d614247f89b32a07562780346b7d7b0b54ef0 100644 (file)
                <varlistentry><term>lookupdomain</term><listitem><para>Lookup Domain Name</para></listitem></varlistentry>
                <varlistentry><term>chgpasswd</term><listitem><para>Change user password</para></listitem></varlistentry>
                <varlistentry><term>chgpasswd2</term><listitem><para>Change user password</para></listitem></varlistentry>
-               <varlistentry><term>chgpasswd3</term><listitem><para>Change user password</para></listitem></varlistentry>
+               <varlistentry><term>chgpasswd3</term><listitem><para>Change user password (RC4 encrypted)</para></listitem></varlistentry>
+               <varlistentry><term>chgpasswd4</term><listitem><para>Change user password (AES encrypted)</para></listitem></varlistentry>
                <varlistentry><term>getdispinfoidx</term><listitem><para>Get Display Information Index</para></listitem></varlistentry>
                <varlistentry><term>setuserinfo</term><listitem><para>Set user info</para></listitem></varlistentry>
                <varlistentry><term>setuserinfo2</term><listitem><para>Set user info2</para></listitem></varlistentry>
index 319e3546e10a77a4e56014f4b050f6a5b89646c9..9ccd2f78a8d40bcb04708897ed59fed0c5373bf1 100644 (file)
@@ -3114,6 +3114,46 @@ static NTSTATUS cmd_samr_chgpasswd3(struct rpc_pipe_client *cli,
        return status;
 }
 
+static NTSTATUS cmd_samr_chgpasswd4(struct rpc_pipe_client *cli,
+                                   TALLOC_CTX *mem_ctx,
+                                   int argc,
+                                   const char **argv)
+{
+       struct dcerpc_binding_handle *b = cli->binding_handle;
+       const char *srv_name_slash = cli->srv_name_slash;
+       const char *user = NULL;
+       const char *oldpass = NULL;
+       const char *newpass = NULL;
+       NTSTATUS status;
+       NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
+       if (argc < 4) {
+               printf("Usage: %s username oldpass newpass\n", argv[0]);
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       user = argv[1];
+       oldpass = argv[2];
+       newpass = argv[3];
+
+       /* Change user password */
+       status = dcerpc_samr_chgpasswd_user4(b,
+                                            mem_ctx,
+                                            srv_name_slash,
+                                            user,
+                                            oldpass,
+                                            newpass,
+                                            &result);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+       if (!NT_STATUS_IS_OK(result)) {
+               status = result;
+       }
+
+       return status;
+}
+
 static NTSTATUS cmd_samr_setuserinfo_int(struct rpc_pipe_client *cli,
                                         TALLOC_CTX *mem_ctx,
                                         int argc, const char **argv,
@@ -3847,6 +3887,16 @@ struct cmd_set samr_commands[] = {
                .description        = "Change user password",
                .usage              = "",
        },
+       {
+               .name               = "chgpasswd4",
+               .returntype         = RPC_RTYPE_NTSTATUS,
+               .ntfn               = cmd_samr_chgpasswd4,
+               .wfn                = NULL,
+               .table              = &ndr_table_samr,
+               .rpc_pipe           = NULL,
+               .description        = "Change user password",
+               .usage              = "",
+       },
        {
                .name               = "getdispinfoidx",
                .returntype         = RPC_RTYPE_NTSTATUS,