summaryrefslogtreecommitdiff
path: root/source/libsmb/passchange.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/libsmb/passchange.c')
-rw-r--r--source/libsmb/passchange.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/source/libsmb/passchange.c b/source/libsmb/passchange.c
index c8a4406949..468750f801 100644
--- a/source/libsmb/passchange.c
+++ b/source/libsmb/passchange.c
@@ -136,13 +136,13 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
/* Try not to give the password away too easily */
if (!pass_must_change) {
- result = cli_rpc_pipe_open_ntlmssp(cli,
- &ndr_table_samr.syntax_id,
- PIPE_AUTH_LEVEL_PRIVACY,
- "", /* what domain... ? */
- user_name,
- old_passwd,
- &pipe_hnd);
+ pipe_hnd = cli_rpc_pipe_open_ntlmssp(cli,
+ PI_SAMR,
+ PIPE_AUTH_LEVEL_PRIVACY,
+ "", /* what domain... ? */
+ user_name,
+ old_passwd,
+ &result);
} else {
/*
* If the user password must be changed the ntlmssp bind will
@@ -152,11 +152,10 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
* will just fail. So we do it anonymously, there's no other
* way.
*/
- result = cli_rpc_pipe_open_noauth(
- cli, &ndr_table_samr.syntax_id, &pipe_hnd);
+ pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
}
- if (!NT_STATUS_IS_OK(result)) {
+ if (!pipe_hnd) {
if (lp_client_lanman_auth()) {
/* Use the old RAP method. */
if (!cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) {
@@ -178,9 +177,8 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
}
}
- result = rpccli_samr_chgpasswd_user2(pipe_hnd, talloc_tos(),
- user_name, new_passwd, old_passwd);
- if (NT_STATUS_IS_OK(result)) {
+ if (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd, pipe_hnd->mem_ctx, user_name,
+ new_passwd, old_passwd))) {
/* Great - it all worked! */
cli_shutdown(cli);
return NT_STATUS_OK;
@@ -197,7 +195,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
}
/* OK, that failed, so try again... */
- TALLOC_FREE(pipe_hnd);
+ cli_rpc_pipe_close(pipe_hnd);
/* Try anonymous NTLMSSP... */
cli_init_creds(cli, "", "", NULL);
@@ -205,13 +203,14 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
result = NT_STATUS_UNSUCCESSFUL;
/* OK, this is ugly, but... try an anonymous pipe. */
- result = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
- &pipe_hnd);
+ pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SAMR, &result);
- if ( NT_STATUS_IS_OK(result) &&
- (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user2(
- pipe_hnd, talloc_tos(), user_name,
- new_passwd, old_passwd)))) {
+ if ( pipe_hnd &&
+ (NT_STATUS_IS_OK(result = rpccli_samr_chgpasswd_user(pipe_hnd,
+ pipe_hnd->mem_ctx,
+ user_name,
+ new_passwd,
+ old_passwd)))) {
/* Great - it all worked! */
cli_shutdown(cli);
return NT_STATUS_OK;