union samr_UserInfo info;
unsigned int orig_timeout;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
+ DATA_BLOB session_key = data_blob_null;
if (argc != 2) {
d_printf("%s\n%s",
init_lsa_String(&lsa_acct_name, acct_name);
+ 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;
+ }
+
/* Get samr policy handle */
status = dcerpc_samr_Connect2(b, mem_ctx,
pipe_hnd->desthost,
ZERO_STRUCT(info.info23);
init_samr_CryptPassword(argv[1],
- &cli->user_session_key,
+ &session_key,
&crypt_pwd);
info.info23.info.fields_present = SAMR_FIELD_ACCT_FLAGS |
done:
SAFE_FREE(acct_name);
+ data_blob_clear_free(&session_key);
return status;
}
/* Password stuff */
+ DATA_BLOB session_key = data_blob_null;
char *clear_trust_password = NULL;
struct samr_CryptPassword crypt_pwd;
uchar md4_trust_password[16];
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;
+ }
+
CHECK_DCERPC_ERR(dcerpc_samr_Connect2(b, mem_ctx,
pipe_hnd->desthost,
SAMR_ACCESS_ENUM_DOMAINS
/* Set password on machine account */
init_samr_CryptPassword(clear_trust_password,
- &cli->user_session_key,
+ &session_key,
&crypt_pwd);
set_info.info24.password = crypt_pwd;
cli_shutdown(cli);
TALLOC_FREE(clear_trust_password);
+ data_blob_clear_free(&session_key);
return retval;
}
struct cli_state **cli,
struct rpc_pipe_client **pipe_hnd,
struct policy_handle *pol_hnd,
- struct dom_data *dom_data)
+ struct dom_data *dom_data,
+ DATA_BLOB *session_key)
{
NTSTATUS status;
NTSTATUS result;
return status;
}
+ status = cli_get_session_key(mem_ctx, *pipe_hnd, session_key);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("Error getting session_key of LSA pipe. Error was %s\n",
+ nt_errstr(status)));
+ return status;
+ }
+
return NT_STATUS_OK;
}
int success = -1;
struct cli_state *cli[2] = {NULL, NULL};
struct rpc_pipe_client *pipe_hnd[2] = {NULL, NULL};
+ DATA_BLOB session_key[2];
struct policy_handle pol_hnd[2];
struct lsa_TrustDomainInfoAuthInfoInternal authinfo;
DATA_BLOB auth_blob;
struct dom_data dom_data[2];
void (*usage)(void);
+ ZERO_STRUCT(session_key);
+
switch (op) {
case TRUST_CREATE:
usage = print_trust_usage;
}
status = connect_and_get_info(mem_ctx, net_ctx, &cli[0], &pipe_hnd[0],
- &pol_hnd[0], &dom_data[0]);
+ &pol_hnd[0], &dom_data[0], &session_key[0]);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("connect_and_get_info failed with error [%s]\n",
nt_errstr(status)));
if (other_net_ctx != NULL) {
status = connect_and_get_info(mem_ctx, other_net_ctx,
&cli[1], &pipe_hnd[1],
- &pol_hnd[1], &dom_data[1]);
+ &pol_hnd[1], &dom_data[1],
+ &session_key[1]);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("connect_and_get_info failed with error [%s]\n",
nt_errstr(status)));
arcfour_crypt_blob(authinfo.auth_blob.data,
authinfo.auth_blob.size,
- &cli[0]->user_session_key);
+ &session_key[0]);
status = create_trust(mem_ctx, pipe_hnd[0]->binding_handle,
&pol_hnd[0],
arcfour_crypt_blob(authinfo.auth_blob.data,
authinfo.auth_blob.size,
- &cli[1]->user_session_key);
+ &session_key[1]);
status = create_trust(mem_ctx,
pipe_hnd[1]->binding_handle,
success = 0;
done:
+ data_blob_clear_free(&session_key[0]);
+ data_blob_clear_free(&session_key[1]);
cli_shutdown(cli[0]);
cli_shutdown(cli[1]);
talloc_destroy(mem_ctx);