diff options
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_rpc.c | 24 | ||||
-rw-r--r-- | source3/utils/net_rpc_join.c | 11 |
2 files changed, 16 insertions, 19 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index f6b6d3a095..a3fdb69bd8 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -849,11 +849,11 @@ static NTSTATUS rpc_user_password_internals(struct net_context *c, { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; POLICY_HND connect_pol, domain_pol, user_pol; - uchar pwbuf[516]; const char *user; const char *new_password; char *prompt = NULL; union samr_UserInfo info; + struct samr_CryptPassword crypt_pwd; if (argc < 1 || c->display_usage) { rpc_user_usage(c, argc, argv); @@ -922,12 +922,11 @@ static NTSTATUS rpc_user_password_internals(struct net_context *c, /* Set password on account */ - encode_pw_buffer(pwbuf, new_password, STR_UNICODE); + init_samr_CryptPassword(new_password, + &cli->user_session_key, + &crypt_pwd); - init_samr_user_info24(&info.info24, pwbuf, 24); - - SamOEMhashBlob(info.info24.password.data, 516, - &cli->user_session_key); + init_samr_user_info24(&info.info24, crypt_pwd.data, 24); result = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx, &user_pol, @@ -5731,9 +5730,7 @@ static NTSTATUS rpc_trustdom_add_internals(struct net_context *c, struct samr_LogonHours hours; struct lsa_BinaryString parameters; const int units_per_week = 168; - uchar pwbuf[516]; - - encode_pw_buffer(pwbuf, argv[1], STR_UNICODE); + struct samr_CryptPassword crypt_pwd; ZERO_STRUCT(notime); ZERO_STRUCT(hours); @@ -5747,6 +5744,10 @@ static NTSTATUS rpc_trustdom_add_internals(struct net_context *c, hours.units_per_week = units_per_week; memset(hours.bits, 0xFF, units_per_week); + init_samr_CryptPassword(argv[1], + &cli->user_session_key, + &crypt_pwd); + init_samr_user_info23(&info.info23, notime, notime, notime, notime, notime, notime, @@ -5755,10 +5756,7 @@ static NTSTATUS rpc_trustdom_add_internals(struct net_context *c, 0, 0, ACB_DOMTRUST, SAMR_FIELD_ACCT_FLAGS, hours, 0, 0, 0, 0, 0, 0, 0, - pwbuf, 24); - - SamOEMhashBlob(info.info23.password.data, 516, - &cli->user_session_key); + crypt_pwd.data, 24); result = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx, &user_pol, diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index f63cb14b7e..5bc38f979f 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -148,7 +148,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) /* Password stuff */ char *clear_trust_password = NULL; - uchar pwbuf[516]; + struct samr_CryptPassword crypt_pwd; uchar md4_trust_password[16]; union samr_UserInfo set_info; @@ -337,14 +337,13 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) E_md4hash(clear_trust_password, md4_trust_password); } - encode_pw_buffer(pwbuf, clear_trust_password, STR_UNICODE); - /* Set password on machine account */ - init_samr_user_info24(&set_info.info24, pwbuf, 24); + init_samr_CryptPassword(clear_trust_password, + &cli->user_session_key, + &crypt_pwd); - SamOEMhashBlob(set_info.info24.password.data, 516, - &cli->user_session_key); + init_samr_user_info24(&set_info.info24, crypt_pwd.data, 24); CHECK_RPC_ERR(rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx, &user_pol, |