#include "includes.h"
#include "utils/net.h"
+#include "rpc_client/cli_pipe.h"
#include "../libcli/auth/libcli_auth.h"
#include "../librpc/gen_ndr/ndr_samr_c.h"
#include "rpc_client/cli_samr.h"
#include "rpc_client/init_samr.h"
-#include "../librpc/gen_ndr/cli_lsa.h"
+#include "../librpc/gen_ndr/ndr_lsa_c.h"
#include "rpc_client/cli_lsarpc.h"
#include "../librpc/gen_ndr/ndr_netlogon_c.h"
#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
#include "lib/netapi/netapi_net.h"
#include "rpc_client/init_lsa.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
+#include "libsmb/clirap.h"
+#include "nsswitch/libwbclient/wbclient.h"
+#include "passdb.h"
static int net_mode_share;
static NTSTATUS sync_files(struct copy_clistate *cp_clistate, const char *mask);
{
struct rpc_pipe_client *lsa_pipe = NULL;
struct policy_handle pol;
- NTSTATUS result = NT_STATUS_OK;
+ NTSTATUS status, result;
union lsa_PolicyInformation *info = NULL;
+ struct dcerpc_binding_handle *b;
- result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+ status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
&lsa_pipe);
- if (!NT_STATUS_IS_OK(result)) {
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, _("Could not initialise lsa pipe\n"));
- return result;
+ return status;
}
- result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false,
+ b = lsa_pipe->binding_handle;
+
+ status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false,
SEC_FLAG_MAXIMUM_ALLOWED,
&pol);
- if (!NT_STATUS_IS_OK(result)) {
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "open_policy %s: %s\n",
_("failed"),
- nt_errstr(result));
- return result;
+ nt_errstr(status));
+ return status;
}
- result = rpccli_lsa_QueryInfoPolicy(lsa_pipe, mem_ctx,
+ status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
&pol,
LSA_POLICY_INFO_ACCOUNT_DOMAIN,
- &info);
+ &info,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "lsaquery %s: %s\n",
+ _("failed"),
+ nt_errstr(status));
+ return status;
+ }
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "lsaquery %s: %s\n",
_("failed"),
*domain_name = info->account_domain.name.string;
*domain_sid = info->account_domain.sid;
- rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol);
+ dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
TALLOC_FREE(lsa_pipe);
return NT_STATUS_OK;
if (!NT_STATUS_IS_OK(result)) {
DEBUG(0,("rpc_oldjoin_internals: netlogon pipe open to machine %s failed. "
"error was %s\n",
- cli->desthost,
+ cli_state_remote_name(cli),
nt_errstr(result) ));
return result;
}
sec_channel_type = get_sec_channel_type(NULL);
}
- fstrcpy(trust_passwd, global_myname());
+ fstrcpy(trust_passwd, lp_netbios_name());
strlower_m(trust_passwd);
/*
E_md4hash(trust_passwd, orig_trust_passwd_hash);
result = trust_pw_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup,
- global_myname(),
+ lp_netbios_name(),
orig_trust_passwd_hash,
sec_channel_type);
return -1;
}
- if (strlen(global_myname()) > 15) {
+ if (strlen(lp_netbios_name()) > 15) {
d_printf(_("Our netbios name can be at most 15 chars long, "
"\"%s\" is %u chars long\n"),
- global_myname(), (unsigned int)strlen(global_myname()));
+ lp_netbios_name(), (unsigned int)strlen(lp_netbios_name()));
return -1;
}
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
enum lsa_SidType *types = NULL;
struct rpc_pipe_client *pipe_hnd = NULL;
struct policy_handle lsa_pol;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS status, result;
+ struct dcerpc_binding_handle *b;
- result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+ status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
&pipe_hnd);
- if (!NT_STATUS_IS_OK(result)) {
+ if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, false,
+ b = pipe_hnd->binding_handle;
+
+ status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, false,
SEC_FLAG_MAXIMUM_ALLOWED, &lsa_pol);
- if (!NT_STATUS_IS_OK(result)) {
+ if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- result = rpccli_lsa_lookup_names(pipe_hnd, mem_ctx, &lsa_pol, 1,
+ status = rpccli_lsa_lookup_names(pipe_hnd, mem_ctx, &lsa_pol, 1,
&name, NULL, 1, &sids, &types);
- if (NT_STATUS_IS_OK(result)) {
+ if (NT_STATUS_IS_OK(status)) {
sid_copy(sid, &sids[0]);
*type = types[0];
}
- rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol);
+ dcerpc_lsa_Close(b, mem_ctx, &lsa_pol, &result);
done:
if (pipe_hnd) {
TALLOC_FREE(pipe_hnd);
}
- if (!NT_STATUS_IS_OK(result) && (StrnCaseCmp(name, "S-", 2) == 0)) {
+ if (!NT_STATUS_IS_OK(status) && (strncasecmp_m(name, "S-", 2) == 0)) {
/* Try as S-1-5-whatever */
if (string_to_sid(&tmp_sid, name)) {
sid_copy(sid, &tmp_sid);
*type = SID_NAME_UNKNOWN;
- result = NT_STATUS_OK;
+ status = NT_STATUS_OK;
}
}
- return result;
+ return status;
}
static NTSTATUS rpc_add_groupmem(struct rpc_pipe_client *pipe_hnd,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ discard_const_p(struct dom_sid2, &global_sid_Builtin),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
struct policy_handle *domain_pol,
uint32 rid)
{
- NTSTATUS result;
+ NTSTATUS result, status;
struct policy_handle group_pol;
uint32 num_members, *group_rids;
int i;
struct samr_RidAttrArray *rids = NULL;
struct lsa_Strings names;
struct samr_Ids types;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
fstring sid_str;
sid_to_fstring(sid_str, domain_sid);
- result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenGroup(b, mem_ctx,
domain_pol,
MAXIMUM_ALLOWED_ACCESS,
rid,
- &group_pol);
-
- if (!NT_STATUS_IS_OK(result))
+ &group_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
return result;
+ }
- result = rpccli_samr_QueryGroupMember(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_QueryGroupMember(b, mem_ctx,
&group_pol,
- &rids);
-
- if (!NT_STATUS_IS_OK(result))
+ &rids,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
return result;
+ }
num_members = rids->count;
group_rids = rids->rids;
if (num_members < this_time)
this_time = num_members;
- result = rpccli_samr_LookupRids(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_LookupRids(b, mem_ctx,
domain_pol,
this_time,
group_rids,
&names,
- &types);
-
- if (!NT_STATUS_IS_OK(result))
+ &types,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
return result;
+ }
/* We only have users as members, but make the output
the same as the output of alias members */
struct policy_handle *domain_pol,
uint32 rid)
{
- NTSTATUS result;
+ NTSTATUS result, status;
struct rpc_pipe_client *lsa_pipe;
struct policy_handle alias_pol, lsa_pol;
uint32 num_members;
enum lsa_SidType *types;
int i;
struct lsa_SidArray sid_array;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
- result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenAlias(b, mem_ctx,
domain_pol,
MAXIMUM_ALLOWED_ACCESS,
rid,
- &alias_pol);
-
- if (!NT_STATUS_IS_OK(result))
+ &alias_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
return result;
+ }
- result = rpccli_samr_GetMembersInAlias(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_GetMembersInAlias(b, mem_ctx,
&alias_pol,
- &sid_array);
-
+ &sid_array,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, _("Couldn't list alias members\n"));
+ return status;
+ }
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, _("Couldn't list alias members\n"));
return result;
return result;
}
- alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, num_members);
+ alias_sids = talloc_zero_array(mem_ctx, struct dom_sid, num_members);
if (!alias_sids) {
d_fprintf(stderr, _("Out of memory\n"));
TALLOC_FREE(lsa_pipe);
int argc,
const char **argv)
{
- NTSTATUS result;
+ NTSTATUS result, status;
struct policy_handle connect_pol, domain_pol;
struct samr_Ids rids, rid_types;
struct lsa_String lsa_acct_name;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
/* Get sam policy handle */
- result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_Connect2(b, mem_ctx,
pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
-
- if (!NT_STATUS_IS_OK(result))
+ &connect_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
return result;
+ }
/* Get domain policy handle */
- result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
- &domain_pol);
-
- if (!NT_STATUS_IS_OK(result))
+ discard_const_p(struct dom_sid2, domain_sid),
+ &domain_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
return result;
+ }
init_lsa_String(&lsa_acct_name, argv[0]); /* sure? */
- result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_LookupNames(b, mem_ctx,
&domain_pol,
1,
&lsa_acct_name,
&rids,
- &rid_types);
+ &rid_types,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
if (!NT_STATUS_IS_OK(result)) {
struct dom_sid sid_Builtin;
- rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);
+ dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
sid_copy(&sid_Builtin, &global_sid_Builtin);
- result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
&sid_Builtin,
- &domain_pol);
-
+ &domain_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, _("Couldn't find group %s\n"),
argv[0]);
return result;
}
- result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_LookupNames(b, mem_ctx,
&domain_pol,
1,
&lsa_acct_name,
&rids,
- &rid_types);
-
+ &rid_types,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, _("Couldn't find group %s\n"),
argv[0]);
{
struct srvsvc_NetShareCtr1 *ctr1;
- ctr1 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr1);
+ ctr1 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr1);
W_ERROR_HAVE_NO_MEMORY(ctr1);
ctr1->count = 1;
{
struct srvsvc_NetShareCtr2 *ctr2;
- ctr2 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr2);
+ ctr2 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr2);
W_ERROR_HAVE_NO_MEMORY(ctr2);
ctr2->count = 1;
{
struct srvsvc_NetShareCtr502 *ctr502;
- ctr502 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr502);
+ ctr502 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr502);
W_ERROR_HAVE_NO_MEMORY(ctr502);
ctr502->count = 1;
{
NTSTATUS status;
- status = cli_tcon_andx(cli, netname, "A:", "", 0);
+ status = cli_tree_connect(cli, netname, "A:", "", 0);
if (!NT_STATUS_IS_OK(status)) {
d_printf(_("skipping [%s]: not a file share.\n"), netname);
return false;
DEBUG(3,("got mask: %s, name: %s\n", mask, f->name));
/* DIRECTORY */
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
DEBUG(3,("got dir: %s\n", f->name));
}
/* search below that directory */
- fstrcpy(new_mask, dir);
- fstrcat(new_mask, "\\*");
+ strlcpy(new_mask, dir, sizeof(new_mask));
+ strlcat(new_mask, "\\*", sizeof(new_mask));
old_dir = local_state->cwd;
local_state->cwd = dir;
DEBUG(3,("calling cli_list with mask: %s\n", mask));
- if ( !cli_resolve_path(talloc_tos(), "", NULL, cp_clistate->cli_share_src,
- mask, &targetcli, &targetpath ) ) {
+ status = cli_resolve_path(talloc_tos(), "", NULL,
+ cp_clistate->cli_share_src,
+ mask, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, _("cli_resolve_path %s failed with error: "
"%s\n"),
- mask, cli_errstr(cp_clistate->cli_share_src));
- return cli_nt_error(cp_clistate->cli_share_src);
+ mask, nt_errstr(status));
+ return status;
}
status = cli_list(targetcli, targetpath, cp_clistate->attribute,
cp_clistate.cli_share_src = NULL;
cp_clistate.cli_share_dst = NULL;
cp_clistate.cwd = NULL;
- cp_clistate.attribute = aSYSTEM | aHIDDEN | aDIR;
+ cp_clistate.attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
cp_clistate.c = c;
/* open share source */
nt_status = connect_to_service(c, &cp_clistate.cli_share_src,
- &cli->dest_ss, cli->desthost,
+ cli_state_remote_sockaddr(cli),
+ cli_state_remote_name(cli),
info502.name, "A:");
if (!NT_STATUS_IS_OK(nt_status))
goto done;
{
uint32 start_idx, max_entries, num_entries, i;
struct samr_SamArray *groups = NULL;
- NTSTATUS result;
+ NTSTATUS result, status;
struct policy_handle domain_pol;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
/* Get domain policy handle */
- result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenDomain(b, mem_ctx,
connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
- &domain_pol);
- if (!NT_STATUS_IS_OK(result))
+ discard_const_p(struct dom_sid2, domain_sid),
+ &domain_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
return result;
+ }
start_idx = 0;
max_entries = 250;
do {
- result = rpccli_samr_EnumDomainAliases(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_EnumDomainAliases(b, mem_ctx,
&domain_pol,
&start_idx,
&groups,
max_entries,
- &num_entries);
+ &num_entries,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
for (i = 0; i < num_entries; i++) {
struct policy_handle alias_pol;
struct full_alias alias;
struct lsa_SidArray sid_array;
int j;
+ NTSTATUS _result;
- result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenAlias(b, mem_ctx,
&domain_pol,
MAXIMUM_ALLOWED_ACCESS,
groups->entries[i].idx,
- &alias_pol);
- if (!NT_STATUS_IS_OK(result))
+ &alias_pol,
+ &_result);
+ if (!NT_STATUS_IS_OK(status)) {
goto done;
+ }
+ if (!NT_STATUS_IS_OK(_result)) {
+ status = _result;
+ goto done;
+ }
- result = rpccli_samr_GetMembersInAlias(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_GetMembersInAlias(b, mem_ctx,
&alias_pol,
- &sid_array);
- if (!NT_STATUS_IS_OK(result))
+ &sid_array,
+ &_result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+ if (!NT_STATUS_IS_OK(_result)) {
+ status = _result;
goto done;
+ }
alias.num_members = sid_array.num_sids;
- result = rpccli_samr_Close(pipe_hnd, mem_ctx, &alias_pol);
- if (!NT_STATUS_IS_OK(result))
+ status = dcerpc_samr_Close(b, mem_ctx, &alias_pol, &_result);
+ if (!NT_STATUS_IS_OK(status)) {
goto done;
+ }
+ if (!NT_STATUS_IS_OK(_result)) {
+ status = _result;
+ goto done;
+ }
alias.members = NULL;
}
} while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
- result = NT_STATUS_OK;
+ status = NT_STATUS_OK;
done:
- rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);
+ dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
- return result;
+ return status;
}
/*
int i;
NTSTATUS result;
struct policy_handle lsa_pol;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true,
SEC_FLAG_MAXIMUM_ALLOWED,
for (j=0; j<alias->num_members; j++)
DEBUG(1, ("%s\\%s (%d); ",
- domains[j] ? domains[j] : "*unknown*",
+ domains[j] ? domains[j] : "*unknown*",
names[j] ? names[j] : "*unknown*",types[j]));
DEBUG(1, ("\n"));
}
- rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol);
+ dcerpc_lsa_Close(b, mem_ctx, &lsa_pol, &result);
return NT_STATUS_OK;
}
int argc,
const char **argv)
{
- NTSTATUS result;
+ NTSTATUS result, status;
struct policy_handle connect_pol;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
- result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_Connect2(b, mem_ctx,
pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
-
- if (!NT_STATUS_IS_OK(result))
+ &connect_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
+ status = result;
goto done;
+ }
- result = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol,
+ status = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol,
&global_sid_Builtin);
-
- if (!NT_STATUS_IS_OK(result))
+ if (!NT_STATUS_IS_OK(status)) {
goto done;
+ }
- result = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol,
+ status = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol,
domain_sid);
- rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);
+ dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
done:
- return result;
+ return status;
}
static void init_user_token(struct security_token *token, struct dom_sid *user_sid)
enum wbcSidType type;
fstring full_name;
struct wbcDomainSid wsid;
- char *sid_str = NULL;
+ char sid_str[WBC_SID_STRING_BUFLEN];
struct dom_sid user_sid;
uint32_t num_groups;
gid_t *groups = NULL;
return false;
}
- wbc_status = wbcSidToString(&wsid, &sid_str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- return false;
- }
+ wbcSidToStringBuf(&wsid, sid_str, sizeof(sid_str));
if (type != WBC_SID_NAME_USER) {
- wbcFreeMemory(sid_str);
DEBUG(1, ("%s is not a user\n", full_name));
return false;
}
return false;
}
- wbcFreeMemory(sid_str);
- sid_str = NULL;
-
init_user_token(token, &user_sid);
/* And now the groups winbind knows about */
return false;
}
- wbc_status = wbcSidToString(&wsid, &sid_str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- wbcFreeMemory(groups);
- return false;
- }
+ wbcSidToStringBuf(&wsid, sid_str, sizeof(sid_str));
DEBUG(3, (" %s\n", sid_str));
string_to_sid(&sid, sid_str);
- wbcFreeMemory(sid_str);
- sid_str = NULL;
-
add_sid_to_token(token, &sid);
}
wbcFreeMemory(groups);
token = &((*tokens)[*num_tokens-1]);
- fstrcpy(token->name, line);
+ strlcpy(token->name, line, sizeof(token->name));
token->token.num_sids = 0;
token->token.sids = NULL;
continue;
}
-
+
return false;
}
netname));
}
- cnum = cli->cnum;
+ cnum = cli_state_get_tid(cli);
- if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, netname, "A:", "", 0))) {
+ if (!NT_STATUS_IS_OK(cli_tree_connect(cli, netname, "A:", "", 0))) {
return;
}
if (!NT_STATUS_IS_OK(cli_ntcreate(cli, "\\", 0, READ_CONTROL_ACCESS, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
- root_sd = cli_query_secdesc(cli, fnum, mem_ctx);
+ cli_query_secdesc(cli, fnum, mem_ctx, &root_sd);
}
for (i=0; i<num_tokens; i++) {
if (fnum != (uint16_t)-1)
cli_close(cli, fnum);
cli_tdis(cli);
- cli->cnum = cnum;
-
+ cli_state_set_tid(cli, cnum);
+
return;
}
if (!get_user_tokens(c, &num_tokens, &tokens)) {
DEBUG(0, ("Could not get the user/sid list\n"));
- return 0;
+ return -1;
}
for (i=0; i<num_tokens; i++) {
}
SAFE_FREE(tokens);
- return 1;
+ return 0;
}
int net_usersidlist_usage(struct net_context *c, int argc, const char **argv)
const char **argv)
{
struct policy_handle connect_pol, domain_pol, user_pol;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS status, result;
char *acct_name;
struct lsa_String lsa_acct_name;
uint32 acb_info;
uint32_t access_granted = 0;
union samr_UserInfo info;
unsigned int orig_timeout;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 2) {
d_printf("%s\n%s",
init_lsa_String(&lsa_acct_name, acct_name);
/* Get samr policy handle */
- result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_Connect2(b, mem_ctx,
pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ &connect_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
goto done;
}
/* Get domain policy handle */
- result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
- &domain_pol);
+ discard_const_p(struct dom_sid2, domain_sid),
+ &domain_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
goto done;
}
SAMR_USER_ACCESS_GET_ATTRIBUTES |
SAMR_USER_ACCESS_SET_ATTRIBUTES;
- result = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_CreateUser2(b, mem_ctx,
&domain_pol,
&lsa_acct_name,
acb_info,
acct_flags,
&user_pol,
&access_granted,
- &user_rid);
-
+ &user_rid,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
/* And restore our original timeout. */
rpccli_set_timeout(pipe_hnd, orig_timeout);
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
d_printf(_("net rpc trustdom add: create user %s failed %s\n"),
acct_name, nt_errstr(result));
goto done;
info.info23.info.acct_flags = ACB_DOMTRUST;
info.info23.password = crypt_pwd;
- result = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_SetUserInfo2(b, mem_ctx,
&user_pol,
23,
- &info);
+ &info,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
DEBUG(0,("Could not set trust account password: %s\n",
nt_errstr(result)));
goto done;
done:
SAFE_FREE(acct_name);
- return result;
+ return status;
}
/**
const char **argv)
{
struct policy_handle connect_pol, domain_pol, user_pol;
- NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS status, result;
char *acct_name;
struct dom_sid trust_acct_sid;
struct samr_Ids user_rids, name_types;
struct lsa_String lsa_acct_name;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
if (argc != 1) {
d_printf("%s\n%s",
strupper_m(acct_name);
/* Get samr policy handle */
- result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_Connect2(b, mem_ctx,
pipe_hnd->desthost,
MAXIMUM_ALLOWED_ACCESS,
- &connect_pol);
+ &connect_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
goto done;
}
/* Get domain policy handle */
- result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
- &domain_pol);
+ discard_const_p(struct dom_sid2, domain_sid),
+ &domain_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
goto done;
}
init_lsa_String(&lsa_acct_name, acct_name);
- result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_LookupNames(b, mem_ctx,
&domain_pol,
1,
&lsa_acct_name,
&user_rids,
- &name_types);
-
+ &name_types,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf(_("net rpc trustdom del: LookupNames on user %s "
+ "failed %s\n"),
+ acct_name, nt_errstr(status));
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
d_printf(_("net rpc trustdom del: LookupNames on user %s "
"failed %s\n"),
acct_name, nt_errstr(result) );
goto done;
}
- result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_OpenUser(b, mem_ctx,
&domain_pol,
MAXIMUM_ALLOWED_ACCESS,
user_rids.ids[0],
- &user_pol);
+ &user_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf(_("net rpc trustdom del: OpenUser on user %s failed "
+ "%s\n"),
+ acct_name, nt_errstr(status) );
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
d_printf(_("net rpc trustdom del: OpenUser on user %s failed "
"%s\n"),
acct_name, nt_errstr(result) );
/* remove the sid */
- result = rpccli_samr_RemoveMemberFromForeignDomain(pipe_hnd, mem_ctx,
+ status = dcerpc_samr_RemoveMemberFromForeignDomain(b, mem_ctx,
&user_pol,
- &trust_acct_sid);
+ &trust_acct_sid,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf(_("net rpc trustdom del: RemoveMemberFromForeignDomain"
+ " on user %s failed %s\n"),
+ acct_name, nt_errstr(status));
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ status = result;
d_printf(_("net rpc trustdom del: RemoveMemberFromForeignDomain"
" on user %s failed %s\n"),
acct_name, nt_errstr(result) );
goto done;
}
+
/* Delete user */
- result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx,
- &user_pol);
+ status = dcerpc_samr_DeleteUser(b, mem_ctx,
+ &user_pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf(_("net rpc trustdom del: DeleteUser on user %s failed "
+ "%s\n"),
+ acct_name, nt_errstr(status));
+ goto done;
+ }
if (!NT_STATUS_IS_OK(result)) {
+ result = status;
d_printf(_("net rpc trustdom del: DeleteUser on user %s failed "
"%s\n"),
acct_name, nt_errstr(result) );
}
done:
- return result;
+ return status;
}
/**
b = netr->binding_handle;
status = dcerpc_netr_GetDcName(b, mem_ctx,
- cli->desthost,
+ netr->desthost,
domain_name,
&buffer,
&result);
struct rpc_pipe_client *pipe_hnd = NULL;
struct policy_handle connect_hnd;
TALLOC_CTX *mem_ctx;
- NTSTATUS nt_status;
+ NTSTATUS nt_status, result;
struct dom_sid *domain_sid;
char* domain_name;
char* acct_name;
fstring pdc_name;
union lsa_PolicyInformation *info = NULL;
+ struct dcerpc_binding_handle *b;
/*
* Connect to \\server\ipc$ as 'our domain' account with password
return -1;
}
+ b = pipe_hnd->binding_handle;
+
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, KEY_QUERY_VALUE,
&connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
/* Querying info level 5 */
- nt_status = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
&connect_hnd,
LSA_POLICY_INFO_ACCOUNT_DOMAIN,
- &info);
+ &info,
+ &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
nt_errstr(nt_status)));
talloc_destroy(mem_ctx);
return -1;
}
+ if (NT_STATUS_IS_ERR(result)) {
+ DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
+ nt_errstr(result)));
+ cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
+ return -1;
+ }
domain_sid = info->account_domain.sid;
* Close the pipes and clean up
*/
- nt_status = rpccli_lsa_Close(pipe_hnd, mem_ctx, &connect_hnd);
+ nt_status = dcerpc_lsa_Close(b, mem_ctx, &connect_hnd, &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't close LSA pipe. Error was %s\n",
nt_errstr(nt_status)));
struct dom_sid dom_sid,
const char *trusted_dom_name)
{
- NTSTATUS nt_status;
+ NTSTATUS nt_status, result;
union lsa_TrustedDomainInfo *info = NULL;
char *cleartextpwd = NULL;
- uint8_t session_key[16];
- DATA_BLOB session_key_blob;
+ DATA_BLOB session_key;
DATA_BLOB data = data_blob_null;
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
- nt_status = rpccli_lsa_QueryTrustedDomainInfoBySid(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_lsa_QueryTrustedDomainInfoBySid(b, mem_ctx,
pol,
&dom_sid,
LSA_TRUSTED_DOMAIN_INFO_PASSWORD,
- &info);
+ &info,
+ &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0,("Could not query trusted domain info. Error was %s\n",
nt_errstr(nt_status)));
goto done;
}
+ if (NT_STATUS_IS_ERR(result)) {
+ nt_status = result;
+ DEBUG(0,("Could not query trusted domain info. Error was %s\n",
+ nt_errstr(result)));
+ goto done;
+ }
data = data_blob(info->password.password->data,
info->password.password->length);
- if (!rpccli_get_pwd_hash(pipe_hnd, session_key)) {
- DEBUG(0, ("Could not retrieve password hash\n"));
+ nt_status = cli_get_session_key(mem_ctx, pipe_hnd, &session_key);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ DEBUG(0, ("Could not retrieve session key: %s\n", nt_errstr(nt_status)));
goto done;
}
- session_key_blob = data_blob_const(session_key, sizeof(session_key));
- cleartextpwd = sess_decrypt_string(mem_ctx, &data, &session_key_blob);
+ cleartextpwd = sess_decrypt_string(mem_ctx, &data, &session_key);
+ data_blob_free(&session_key);
if (cleartextpwd == NULL) {
DEBUG(0,("retrieved NULL password\n"));
TALLOC_CTX* mem_ctx;
struct cli_state *cli = NULL;
struct rpc_pipe_client *pipe_hnd = NULL;
- NTSTATUS nt_status;
+ NTSTATUS nt_status, result;
const char *domain_name = NULL;
- struct dom_sid *queried_dom_sid;
struct policy_handle connect_hnd;
union lsa_PolicyInformation *info = NULL;
int i;
struct lsa_DomainList dom_list;
fstring pdc_name;
+ struct dcerpc_binding_handle *b;
if (c->display_usage) {
d_printf( "%s\n"
* or to remote one given in command line
*/
- if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
+ if (strcasecmp_m(c->opt_workgroup, lp_workgroup())) {
domain_name = c->opt_workgroup;
c->opt_target_workgroup = c->opt_workgroup;
} else {
- fstrcpy(pdc_name, global_myname());
+ fstrcpy(pdc_name, lp_netbios_name());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
c->opt_target_workgroup = domain_name;
};
return -1;
};
+ b = pipe_hnd->binding_handle;
+
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, KEY_QUERY_VALUE,
&connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
};
/* query info level 5 to obtain sid of a domain being queried */
- nt_status = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
&connect_hnd,
LSA_POLICY_INFO_ACCOUNT_DOMAIN,
- &info);
+ &info,
+ &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
talloc_destroy(mem_ctx);
return -1;
}
-
- queried_dom_sid = info->account_domain.sid;
+ if (NT_STATUS_IS_ERR(result)) {
+ DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
+ nt_errstr(result)));
+ cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
+ return -1;
+ }
/*
* Keep calling LsaEnumTrustdom over opened pipe until
d_printf(_("Vampire trusted domains:\n\n"));
do {
- nt_status = rpccli_lsa_EnumTrustDom(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
&connect_hnd,
&enum_ctx,
&dom_list,
- (uint32_t)-1);
+ (uint32_t)-1,
+ &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
nt_errstr(nt_status)));
talloc_destroy(mem_ctx);
return -1;
};
+ if (NT_STATUS_IS_ERR(result)) {
+ nt_status = result;
+ DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
+ nt_errstr(result)));
+ cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
+ return -1;
+ };
+
for (i = 0; i < dom_list.count; i++) {
print_trusted_domain(dom_list.domains[i].sid,
dom_list.domains[i].name.string);
- nt_status = vampire_trusted_domain(pipe_hnd, mem_ctx, &connect_hnd,
+ nt_status = vampire_trusted_domain(pipe_hnd, mem_ctx, &connect_hnd,
*dom_list.domains[i].sid,
dom_list.domains[i].name.string);
if (!NT_STATUS_IS_OK(nt_status)) {
} while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES));
/* close this connection before doing next one */
- nt_status = rpccli_lsa_Close(pipe_hnd, mem_ctx, &connect_hnd);
+ nt_status = dcerpc_lsa_Close(b, mem_ctx, &connect_hnd, &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't properly close lsa policy handle. Error was %s\n",
nt_errstr(nt_status)));
TALLOC_CTX* mem_ctx;
struct cli_state *cli = NULL, *remote_cli = NULL;
struct rpc_pipe_client *pipe_hnd = NULL;
- NTSTATUS nt_status;
+ NTSTATUS nt_status, result;
const char *domain_name = NULL;
struct dom_sid *queried_dom_sid;
int ascii_dom_name_len;
struct policy_handle connect_hnd;
union lsa_PolicyInformation *info = NULL;
+ struct dcerpc_binding_handle *b = NULL;
/* trusted domains listing variables */
unsigned int num_domains, enum_ctx = 0;
* or to remote one given in command line
*/
- if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
+ if (strcasecmp_m(c->opt_workgroup, lp_workgroup())) {
domain_name = c->opt_workgroup;
c->opt_target_workgroup = c->opt_workgroup;
} else {
- fstrcpy(pdc_name, global_myname());
+ fstrcpy(pdc_name, lp_netbios_name());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
c->opt_target_workgroup = domain_name;
};
return -1;
};
+ b = pipe_hnd->binding_handle;
+
nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, KEY_QUERY_VALUE,
&connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
talloc_destroy(mem_ctx);
return -1;
};
-
+
/* query info level 5 to obtain sid of a domain being queried */
- nt_status = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
&connect_hnd,
LSA_POLICY_INFO_ACCOUNT_DOMAIN,
- &info);
+ &info,
+ &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
talloc_destroy(mem_ctx);
return -1;
}
+ if (NT_STATUS_IS_ERR(result)) {
+ DEBUG(0, ("LSA Query Info failed. Returned error was %s\n",
+ nt_errstr(result)));
+ cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
+ return -1;
+ }
queried_dom_sid = info->account_domain.sid;
found_domain = false;
do {
- nt_status = rpccli_lsa_EnumTrustDom(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
&connect_hnd,
&enum_ctx,
&dom_list,
- (uint32_t)-1);
+ (uint32_t)-1,
+ &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
nt_errstr(nt_status)));
talloc_destroy(mem_ctx);
return -1;
};
+ if (NT_STATUS_IS_ERR(result)) {
+ DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n",
+ nt_errstr(result)));
+ cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
+ return -1;
+ };
+
for (i = 0; i < dom_list.count; i++) {
print_trusted_domain(dom_list.domains[i].sid,
}
/* close this connection before doing next one */
- nt_status = rpccli_lsa_Close(pipe_hnd, mem_ctx, &connect_hnd);
+ nt_status = dcerpc_lsa_Close(b, mem_ctx, &connect_hnd, &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't properly close lsa policy handle. Error was %s\n",
nt_errstr(nt_status)));
talloc_destroy(mem_ctx);
return -1;
};
-
+
TALLOC_FREE(pipe_hnd);
/*
* Listing trusting domains (stored in passdb backend, if local)
*/
-
+
d_printf(_("\nTrusting domains list:\n\n"));
/*
return -1;
};
+ b = pipe_hnd->binding_handle;
+
/* SamrConnect2 */
- nt_status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_samr_Connect2(b, mem_ctx,
pipe_hnd->desthost,
SAMR_ACCESS_LOOKUP_DOMAIN,
- &connect_hnd);
+ &connect_hnd,
+ &result);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n",
nt_errstr(nt_status)));
talloc_destroy(mem_ctx);
return -1;
};
+ if (!NT_STATUS_IS_OK(result)) {
+ nt_status = result;
+ DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n",
+ nt_errstr(result)));
+ cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
+ return -1;
+ };
/* SamrOpenDomain - we have to open domain policy handle in order to be
able to enumerate accounts*/
- nt_status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_hnd,
SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS,
queried_dom_sid,
- &domain_hnd);
+ &domain_hnd,
+ &result);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't open domain object. Error was %s\n",
nt_errstr(nt_status)));
talloc_destroy(mem_ctx);
return -1;
};
+ if (!NT_STATUS_IS_OK(result)) {
+ nt_status = result;
+ DEBUG(0, ("Couldn't open domain object. Error was %s\n",
+ nt_errstr(result)));
+ cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
+ return -1;
+ };
/*
* perform actual enumeration
enum_ctx = 0; /* reset enumeration context from last enumeration */
do {
- nt_status = rpccli_samr_EnumDomainUsers(pipe_hnd, mem_ctx,
+ nt_status = dcerpc_samr_EnumDomainUsers(b, mem_ctx,
&domain_hnd,
&enum_ctx,
ACB_DOMTRUST,
&trusts,
0xffff,
- &num_domains);
+ &num_domains,
+ &result);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't enumerate accounts. Error was: %s\n",
nt_errstr(nt_status)));
talloc_destroy(mem_ctx);
return -1;
};
+ if (NT_STATUS_IS_ERR(result)) {
+ nt_status = result;
+ DEBUG(0, ("Couldn't enumerate accounts. Error was: %s\n",
+ nt_errstr(result)));
+ cli_shutdown(cli);
+ talloc_destroy(mem_ctx);
+ return -1;
+ };
for (i = 0; i < num_domains; i++) {
- char *str = CONST_DISCARD(char *, trusts->entries[i].name.string);
+ char *str = discard_const_p(char, trusts->entries[i].name.string);
found_domain = true;
}
}
- } while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES));
+ } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
if (!found_domain) {
d_printf("none\n");
}
/* close opened samr and domain policy handles */
- nt_status = rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_hnd);
+ nt_status = dcerpc_samr_Close(b, mem_ctx, &domain_hnd, &result);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't properly close domain policy handle for domain %s\n", domain_name));
};
- nt_status = rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_hnd);
+ nt_status = dcerpc_samr_Close(b, mem_ctx, &connect_hnd, &result);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't properly close samr policy handle for domain %s\n", domain_name));
};
if (!net_find_server(c, NULL, flags, &server_ss, &server_name))
return false;
- if ((cli = cli_initialise()) == NULL) {
+ status = cli_connect_nb(server_name, &server_ss, 0, 0x20,
+ lp_netbios_name(), SMB_SIGNING_DEFAULT,
+ 0, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
-
- status = cli_connect(cli, server_name, &server_ss);
- if (!NT_STATUS_IS_OK(status))
- goto done;
- if (!attempt_netbios_session_request(&cli, global_myname(),
- server_name, &server_ss))
- goto done;
- status = cli_negprot(cli);
+ status = cli_negprot(cli, PROTOCOL_NT1);
if (!NT_STATUS_IS_OK(status))
goto done;
- if (cli->protocol < PROTOCOL_NT1)
+ if (cli_state_protocol(cli) < PROTOCOL_NT1)
goto done;
ret = true;
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_netlogon.syntax_id,
- NET_FLAGS_ANONYMOUS,
- rpc_vampire_internals,
- argc, argv);
+ return rpc_vampire_passdb(c, argc, argv);
}
return net_run_function(c, argc, argv, "net rpc vampire", func);
N_("net rpc shell\n"
" Open interactive shell on remote server")
},
+ {
+ "trust",
+ net_rpc_trust,
+ NET_TRANSPORT_RPC,
+ N_("Manage trusts"),
+ N_("net rpc trust\n"
+ " Manage trusts")
+ },
+ {
+ "conf",
+ net_rpc_conf,
+ NET_TRANSPORT_RPC,
+ N_("Configure a remote samba server"),
+ N_("net rpc conf\n"
+ " Configure a remote samba server")
+ },
{NULL, NULL, 0, NULL, NULL}
};