net: for robustness reasons, fallback to level 24 pwd set while joining.
authorGünther Deschner <gd@samba.org>
Wed, 4 Jun 2008 18:02:13 +0000 (20:02 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 4 Jun 2008 18:02:13 +0000 (20:02 +0200)
DCERPC_FAULT_INVALID_TAG is returned by older windows releases, in that case it
is wise to do what we did prior to 3.0.28.

Guenther

source/utils/net_domain.c

index 533bb9c6989cc6a62af1435873e5b35fb448f14f..1c19a61a6328c5471c38acb95b84ca9455f695f2 100644 (file)
@@ -213,6 +213,7 @@ NTSTATUS netdom_join_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli,
        uint32 fields_present;
        uchar pwbuf[532];
        SAM_USERINFO_CTR ctr;
+       SAM_USER_INFO_24 p24;
        SAM_USER_INFO_25 p25;
        const int infolevel = 25;
        struct MD5Context md5ctx;
@@ -337,6 +338,27 @@ NTSTATUS netdom_join_domain( TALLOC_CTX *mem_ctx, struct cli_state *cli,
        status = rpccli_samr_set_userinfo2(pipe_hnd, mem_ctx, &user_pol,
                                           infolevel, &cli->user_session_key, &ctr);
 
+       if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
+
+               uchar pwbuf2[516];
+
+               ZERO_STRUCT(p24);
+
+               encode_pw_buffer(pwbuf2, clear_pw, STR_UNICODE);
+
+               /* retry with level 24 */
+               init_sam_user_info24(&p24, (char *)pwbuf2, 24);
+
+               ctr.switch_value = 24;
+               ctr.info.id24    = &p24;
+
+               status = rpccli_samr_set_userinfo(pipe_hnd, mem_ctx,
+                                                 &user_pol,
+                                                 24,
+                                                 &cli->user_session_key,
+                                                 &ctr);
+       }
+
        if ( !NT_STATUS_IS_OK(status) ) {
                d_fprintf( stderr, "Failed to set password for machine account (%s)\n", 
                        nt_errstr(status));