mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
SAMR lookupdomain rpc client patches from amber palekar <amber@nu3.net>
This commit is contained in:
parent
18685d137e
commit
67bc6bccc2
@ -1464,3 +1464,49 @@ NTSTATUS cli_samr_get_dom_pwinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Lookup Domain Name */
|
||||
|
||||
NTSTATUS cli_samr_lookup_domain(struct cli_state *cli, TALLOC_CTX *mem_ctx,
|
||||
POLICY_HND *user_pol, char *domain_name,
|
||||
DOM_SID *sid)
|
||||
{
|
||||
prs_struct qbuf, rbuf;
|
||||
SAMR_Q_LOOKUP_DOMAIN q;
|
||||
SAMR_R_LOOKUP_DOMAIN r;
|
||||
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
||||
|
||||
ZERO_STRUCT(q);
|
||||
ZERO_STRUCT(r);
|
||||
|
||||
/* Initialise parse structures */
|
||||
|
||||
prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
|
||||
prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
|
||||
|
||||
/* Marshall data and send request */
|
||||
|
||||
init_samr_q_lookup_domain(&q, user_pol, domain_name);
|
||||
|
||||
if (!samr_io_q_lookup_domain("", &q, &qbuf, 0) ||
|
||||
!rpc_api_pipe_req(cli, SAMR_LOOKUP_DOMAIN, &qbuf, &rbuf))
|
||||
goto done;
|
||||
|
||||
/* Unmarshall response */
|
||||
|
||||
if (!samr_io_r_lookup_domain("", &r, &rbuf, 0))
|
||||
goto done;
|
||||
|
||||
/* Return output parameters */
|
||||
|
||||
result = r.status;
|
||||
|
||||
if (NT_STATUS_IS_OK(result))
|
||||
sid_copy(sid, &r.dom_sid.sid);
|
||||
|
||||
done:
|
||||
prs_mem_free(&qbuf);
|
||||
prs_mem_free(&rbuf);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1487,6 +1487,49 @@ static NTSTATUS cmd_samr_get_dom_pwinfo(struct cli_state *cli,
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Look up domain name */
|
||||
|
||||
static NTSTATUS cmd_samr_lookup_domain(struct cli_state *cli,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
int argc, const char **argv)
|
||||
{
|
||||
POLICY_HND connect_pol, domain_pol;
|
||||
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
||||
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
||||
fstring domain_name,sid_string;
|
||||
DOM_SID sid;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("Usage: %s domain_name\n", argv[0]);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
sscanf(argv[1], "%s", domain_name);
|
||||
|
||||
result = try_samr_connects(cli, mem_ctx, access_mask, &connect_pol);
|
||||
|
||||
if (!NT_STATUS_IS_OK(result))
|
||||
goto done;
|
||||
|
||||
result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
|
||||
access_mask, &domain_sid, &domain_pol);
|
||||
|
||||
if (!NT_STATUS_IS_OK(result))
|
||||
goto done;
|
||||
|
||||
result = cli_samr_lookup_domain(
|
||||
cli, mem_ctx, &connect_pol, domain_name, &sid);
|
||||
|
||||
sid_to_string(sid_string,&sid);
|
||||
|
||||
if (NT_STATUS_IS_OK(result))
|
||||
printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n",
|
||||
domain_name,sid_string);
|
||||
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* List of commands exported by this module */
|
||||
|
||||
@ -1513,5 +1556,6 @@ struct cmd_set samr_commands[] = {
|
||||
{ "samquerysecobj", RPC_RTYPE_NTSTATUS, cmd_samr_query_sec_obj, NULL, PI_SAMR, "Query SAMR security object", "" },
|
||||
{ "getdompwinfo", RPC_RTYPE_NTSTATUS, cmd_samr_get_dom_pwinfo, NULL, PI_SAMR, "Retrieve domain password info", "" },
|
||||
|
||||
{ "lookupdomain", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_domain, NULL, PI_SAMR, "Lookup Domain Name", "" },
|
||||
{ NULL }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user