s3:libnet_join: make use of cli_get_session_key() in libnet_join_joindomain_rpc()
authorStefan Metzmacher <metze@samba.org>
Wed, 1 Aug 2012 08:30:06 +0000 (10:30 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 1 Aug 2012 12:17:14 +0000 (14:17 +0200)
metze

source3/libnet/libnet_join.c

index c9b2282b515083118d39a609a1dadb64153ef0ec..399c13a86a72693227ac2093bba1e8f788c80a2f 100644 (file)
@@ -853,6 +853,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
        union samr_UserInfo user_info;
        struct dcerpc_binding_handle *b = NULL;
 
+       DATA_BLOB session_key = data_blob_null;
        struct samr_CryptPassword crypt_pwd;
        struct samr_CryptPasswordEx crypt_pwd_ex;
 
@@ -888,6 +889,13 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
 
        b = pipe_hnd->binding_handle;
 
+       status = cli_get_session_key(mem_ctx, pipe_hnd, &session_key);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0,("Error getting session_key of SAM pipe. Error was %s\n",
+                       nt_errstr(status)));
+               goto done;
+       }
+
        status = dcerpc_samr_Connect2(b, mem_ctx,
                                      pipe_hnd->desthost,
                                      SAMR_ACCESS_ENUM_DOMAINS
@@ -1064,7 +1072,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
        /* Set password on machine account - first try level 26 */
 
        init_samr_CryptPasswordEx(r->in.machine_password,
-                                 &cli->user_session_key,
+                                 &session_key,
                                  &crypt_pwd_ex);
 
        user_info.info26.password = crypt_pwd_ex;
@@ -1081,7 +1089,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
                /* retry with level 24 */
 
                init_samr_CryptPassword(r->in.machine_password,
-                                       &cli->user_session_key,
+                                       &session_key,
                                        &crypt_pwd);
 
                user_info.info24.password = crypt_pwd;
@@ -1125,6 +1133,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
                return status;
        }
 
+       data_blob_clear_free(&session_key);
+
        if (is_valid_policy_hnd(&sam_pol)) {
                dcerpc_samr_Close(b, mem_ctx, &sam_pol, &result);
        }