Set the password for a newly created trustdom account. Tested against
authorVolker Lendecke <vlendec@samba.org>
Sun, 11 May 2003 16:59:06 +0000 (16:59 +0000)
committerVolker Lendecke <vlendec@samba.org>
Sun, 11 May 2003 16:59:06 +0000 (16:59 +0000)
PDCs running NT4SP1, NT4SP6 and Samba 3.0.

Volker
(This used to be commit 2143446043b2c29027cf69554caddf41274df709)

source3/utils/net_rpc.c

index d57793220477601db1e180456cf183832f00f61e..e5e2b0149a928bb7afcabb824e094a9f3e824637 100644 (file)
@@ -1554,8 +1554,8 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid, struct cli
        uint16 acb_info;
        uint32 unknown, user_rid;
 
-       if (argc != 1) {
-               d_printf("Usage: net rpc trustdom add <domain_name>\n");
+       if (argc != 2) {
+               d_printf("Usage: net rpc trustdom add <domain_name> <pw>\n");
                return NT_STATUS_INVALID_PARAMETER;
        }
 
@@ -1586,7 +1586,7 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid, struct cli
 
        /* Create trusting domain's account */
        acb_info = ACB_DOMTRUST;
-       unknown = 0xe005000b; /* No idea what this is - a permission mask?
+       unknown = 0xe00500b0; /* No idea what this is - a permission mask?
                                 mimir: yes, most probably it is */
 
        result = cli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
@@ -1596,6 +1596,37 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid, struct cli
                goto done;
        }
 
+       {
+               SAM_USERINFO_CTR ctr;
+               SAM_USER_INFO_24 p24;
+               fstring ucs2_trust_password;
+               int ucs2_pw_len;
+               uchar pwbuf[516];
+
+               ucs2_pw_len = push_ucs2(NULL, ucs2_trust_password, argv[1],
+                                       sizeof(ucs2_trust_password), 0);
+
+               encode_pw_buffer((char *)pwbuf, ucs2_trust_password,
+                                ucs2_pw_len);
+
+               ZERO_STRUCT(ctr);
+               ZERO_STRUCT(p24);
+
+               init_sam_user_info24(&p24, (char *)pwbuf, 24);
+
+               ctr.switch_value = 24;
+               ctr.info.id24 = &p24;
+
+               result = cli_samr_set_userinfo(cli, mem_ctx, &user_pol, 24,
+                                              cli->user_session_key, &ctr);
+
+               if (!NT_STATUS_IS_OK(result)) {
+                       DEBUG(0,("Could not set trust account password: %s\n"
+                                nt_errstr(result)));
+                       goto done;
+               }
+       }
+
  done:
        SAFE_FREE(acct_name);
        return result;