s3-netapi: use cli_get_session_key() in netapi.
authorGünther Deschner <gd@samba.org>
Thu, 24 Mar 2011 21:14:20 +0000 (22:14 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 24 Mar 2011 22:08:22 +0000 (23:08 +0100)
Guenther

source3/lib/netapi/joindomain.c
source3/lib/netapi/user.c

index 6bae363b1439cbb6a3f020ddf2f94781c652e7e4..edc45efe9eb094bba03898edae839565d3bd1506 100644 (file)
@@ -113,6 +113,7 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx,
        WERROR werr;
        unsigned int old_timeout = 0;
        struct dcerpc_binding_handle *b;
+       DATA_BLOB session_key;
 
        werr = libnetapi_open_pipe(ctx, r->in.server,
                                   &ndr_table_wkssvc.syntax_id,
@@ -124,9 +125,16 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx,
        b = pipe_cli->binding_handle;
 
        if (r->in.password) {
+
+               status = cli_get_session_key(ctx, pipe_cli, &session_key);
+               if (!NT_STATUS_IS_OK(status)) {
+                       werr = ntstatus_to_werror(status);
+                       goto done;
+               }
+
                encode_wkssvc_join_password_buffer(ctx,
                                                   r->in.password,
-                                                  &pipe_cli->auth->user_session_key,
+                                                  &session_key,
                                                   &encrypted_password);
        }
 
@@ -246,6 +254,7 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx,
        WERROR werr;
        unsigned int old_timeout = 0;
        struct dcerpc_binding_handle *b;
+       DATA_BLOB session_key;
 
        werr = libnetapi_open_pipe(ctx, r->in.server_name,
                                   &ndr_table_wkssvc.syntax_id,
@@ -257,9 +266,16 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx,
        b = pipe_cli->binding_handle;
 
        if (r->in.password) {
+
+               status = cli_get_session_key(ctx, pipe_cli, &session_key);
+               if (!NT_STATUS_IS_OK(status)) {
+                       werr = ntstatus_to_werror(status);
+                       goto done;
+               }
+
                encode_wkssvc_join_password_buffer(ctx,
                                                   r->in.password,
-                                                  &pipe_cli->auth->user_session_key,
+                                                  &session_key,
                                                   &encrypted_password);
        }
 
@@ -436,6 +452,7 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx,
        NTSTATUS status;
        WERROR werr;
        struct dcerpc_binding_handle *b;
+       DATA_BLOB session_key;
 
        werr = libnetapi_open_pipe(ctx, r->in.server_name,
                                   &ndr_table_wkssvc.syntax_id,
@@ -447,9 +464,16 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx,
        b = pipe_cli->binding_handle;
 
        if (r->in.password) {
+
+               status = cli_get_session_key(ctx, pipe_cli, &session_key);
+               if (!NT_STATUS_IS_OK(status)) {
+                       werr = ntstatus_to_werror(status);
+                       goto done;
+               }
+
                encode_wkssvc_join_password_buffer(ctx,
                                                   r->in.password,
-                                                  &pipe_cli->auth->user_session_key,
+                                                  &session_key,
                                                   &encrypted_password);
        }
 
@@ -481,6 +505,7 @@ WERROR NetRenameMachineInDomain_r(struct libnetapi_ctx *ctx,
        NTSTATUS status;
        WERROR werr;
        struct dcerpc_binding_handle *b;
+       DATA_BLOB session_key;
 
        werr = libnetapi_open_pipe(ctx, r->in.server_name,
                                   &ndr_table_wkssvc.syntax_id,
@@ -492,9 +517,16 @@ WERROR NetRenameMachineInDomain_r(struct libnetapi_ctx *ctx,
        b = pipe_cli->binding_handle;
 
        if (r->in.password) {
+
+               status = cli_get_session_key(ctx, pipe_cli, &session_key);
+               if (!NT_STATUS_IS_OK(status)) {
+                       werr = ntstatus_to_werror(status);
+                       goto done;
+               }
+
                encode_wkssvc_join_password_buffer(ctx,
                                                   r->in.password,
-                                                  &pipe_cli->auth->user_session_key,
+                                                  &session_key,
                                                   &encrypted_password);
        }
 
index 51a093441f16ec17b5b458aabc9080183700d420..29f609d7bc099b40881d0c9abbfbc33c01003d24 100644 (file)
@@ -29,6 +29,7 @@
 #include "rpc_client/init_lsa.h"
 #include "../libcli/security/security.h"
 #include "../libds/common/flag_mapping.h"
+#include "rpc_client/cli_pipe.h"
 
 /****************************************************************
 ****************************************************************/
@@ -377,6 +378,7 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
        uint32_t rid = 0;
        struct USER_INFO_X uX;
        struct dcerpc_binding_handle *b = NULL;
+       DATA_BLOB session_key;
 
        ZERO_STRUCT(connect_handle);
        ZERO_STRUCT(domain_handle);
@@ -481,10 +483,16 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
                goto done;
        }
 
+       status = cli_get_session_key(ctx, pipe_cli, &session_key);
+       if (!NT_STATUS_IS_OK(status)) {
+               werr = ntstatus_to_werror(status);
+               goto done;
+       }
+
        uX.usriX_flags |= ACB_NORMAL;
 
        status = set_user_info_USER_INFO_X(ctx, pipe_cli,
-                                          &pipe_cli->auth->user_session_key,
+                                          &session_key,
                                           &user_handle,
                                           &uX);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1850,6 +1858,7 @@ WERROR NetUserSetInfo_r(struct libnetapi_ctx *ctx,
 
        struct USER_INFO_X uX;
        struct dcerpc_binding_handle *b = NULL;
+       DATA_BLOB session_key;
 
        ZERO_STRUCT(connect_handle);
        ZERO_STRUCT(domain_handle);
@@ -1980,8 +1989,14 @@ WERROR NetUserSetInfo_r(struct libnetapi_ctx *ctx,
                goto done;
        }
 
+       status = cli_get_session_key(ctx, pipe_cli, &session_key);
+       if (!NT_STATUS_IS_OK(status)) {
+               werr = ntstatus_to_werror(status);
+               goto done;
+       }
+
        status = set_user_info_USER_INFO_X(ctx, pipe_cli,
-                                          &pipe_cli->auth->user_session_key,
+                                          &session_key,
                                           &user_handle,
                                           &uX);
        if (!NT_STATUS_IS_OK(status)) {