mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s4-samr: merge samr_LookupDomain from s3 idl. (fixme: python)
Guenther
This commit is contained in:
parent
61391d0ade
commit
bb1d7684d2
@ -266,7 +266,7 @@ import "misc.idl", "lsa.idl", "security.idl";
|
||||
NTSTATUS samr_LookupDomain (
|
||||
[in,ref] policy_handle *connect_handle,
|
||||
[in,ref] lsa_String *domain_name,
|
||||
[out,unique] dom_sid2 *sid
|
||||
[out,ref] dom_sid2 **sid
|
||||
);
|
||||
|
||||
|
||||
|
@ -40,6 +40,7 @@ struct domain_open_samr_state {
|
||||
uint32_t access_mask;
|
||||
struct policy_handle connect_handle;
|
||||
struct policy_handle domain_handle;
|
||||
struct dom_sid2 *domain_sid;
|
||||
|
||||
/* information about the progress */
|
||||
void (*monitor_fn)(struct monitor_msg*);
|
||||
@ -159,6 +160,8 @@ static void continue_domain_open_connect(struct rpc_request *req)
|
||||
/* prepare for samr_LookupDomain call */
|
||||
r->in.connect_handle = &s->connect_handle;
|
||||
r->in.domain_name = &s->domain_name;
|
||||
r->out.sid = talloc(s, struct dom_sid2 *);
|
||||
if (composite_nomem(r->out.sid, c)) return;
|
||||
|
||||
lookup_req = dcerpc_samr_LookupDomain_send(s->pipe, c, r);
|
||||
if (composite_nomem(lookup_req, c)) return;
|
||||
@ -209,7 +212,7 @@ static void continue_domain_open_lookup(struct rpc_request *req)
|
||||
/* prepare for samr_OpenDomain call */
|
||||
r->in.connect_handle = &s->connect_handle;
|
||||
r->in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
r->in.sid = s->lookup.out.sid;
|
||||
r->in.sid = *s->lookup.out.sid;
|
||||
r->out.domain_handle = &s->domain_handle;
|
||||
|
||||
opendom_req = dcerpc_samr_OpenDomain_send(s->pipe, c, r);
|
||||
@ -361,7 +364,7 @@ NTSTATUS libnet_DomainOpenSamr_recv(struct composite_context *c, struct libnet_c
|
||||
libnet functions */
|
||||
ctx->samr.connect_handle = s->connect_handle;
|
||||
ctx->samr.handle = s->domain_handle;
|
||||
ctx->samr.sid = talloc_steal(ctx, s->lookup.out.sid);
|
||||
ctx->samr.sid = talloc_steal(ctx, *s->lookup.out.sid);
|
||||
ctx->samr.name = talloc_steal(ctx, s->domain_name.string);
|
||||
ctx->samr.access_mask = s->access_mask;
|
||||
}
|
||||
|
@ -561,9 +561,11 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru
|
||||
if (!connect_with_info->out.domain_sid) {
|
||||
struct lsa_String name;
|
||||
struct samr_LookupDomain l;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
name.string = connect_with_info->out.domain_name;
|
||||
l.in.connect_handle = &p_handle;
|
||||
l.in.domain_name = &name;
|
||||
l.out.sid = &sid;
|
||||
|
||||
status = dcerpc_samr_LookupDomain(samr_pipe, tmp_ctx, &l);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -573,7 +575,7 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru
|
||||
talloc_free(tmp_ctx);
|
||||
return status;
|
||||
}
|
||||
connect_with_info->out.domain_sid = l.out.sid;
|
||||
connect_with_info->out.domain_sid = *l.out.sid;
|
||||
}
|
||||
|
||||
/* prepare samr_OpenDomain */
|
||||
|
@ -531,6 +531,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
|
||||
struct samr_Connect sc;
|
||||
struct policy_handle p_handle;
|
||||
struct samr_LookupDomain ld;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct lsa_String d_name;
|
||||
struct samr_OpenDomain od;
|
||||
struct policy_handle d_handle;
|
||||
@ -573,6 +574,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
|
||||
d_name.string = r->samr.in.domain_name;
|
||||
ld.in.connect_handle = &p_handle;
|
||||
ld.in.domain_name = &d_name;
|
||||
ld.out.sid = &sid;
|
||||
|
||||
/* 3. do a samr_LookupDomain to get the domain sid */
|
||||
status = dcerpc_samr_LookupDomain(c.out.dcerpc_pipe, mem_ctx, &ld);
|
||||
@ -587,7 +589,7 @@ static NTSTATUS libnet_SetPassword_samr(struct libnet_context *ctx, TALLOC_CTX *
|
||||
ZERO_STRUCT(d_handle);
|
||||
od.in.connect_handle = &p_handle;
|
||||
od.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
od.in.sid = ld.out.sid;
|
||||
od.in.sid = *ld.out.sid;
|
||||
od.out.domain_handle = &d_handle;
|
||||
|
||||
/* 4. do a samr_OpenDomain to get a domain handle */
|
||||
|
@ -277,7 +277,7 @@ static NTSTATUS dcesrv_samr_LookupDomain(struct dcesrv_call_state *dce_call, TAL
|
||||
int ret;
|
||||
struct ldb_dn *partitions_basedn;
|
||||
|
||||
r->out.sid = NULL;
|
||||
*r->out.sid = NULL;
|
||||
|
||||
DCESRV_PULL_HANDLE(h, r->in.connect_handle, SAMR_HANDLE_CONNECT);
|
||||
|
||||
@ -319,7 +319,7 @@ static NTSTATUS dcesrv_samr_LookupDomain(struct dcesrv_call_state *dce_call, TAL
|
||||
return NT_STATUS_NO_SUCH_DOMAIN;
|
||||
}
|
||||
|
||||
r->out.sid = sid;
|
||||
*r->out.sid = sid;
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
@ -35,12 +35,13 @@
|
||||
|
||||
static bool test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
struct policy_handle *handle, struct lsa_String *domname,
|
||||
uint32_t *access_mask, struct dom_sid **sid)
|
||||
uint32_t *access_mask, struct dom_sid **sid_p)
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct policy_handle h, domain_handle;
|
||||
struct samr_Connect r1;
|
||||
struct samr_LookupDomain r2;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct samr_OpenDomain r3;
|
||||
|
||||
printf("connecting\n");
|
||||
@ -59,6 +60,7 @@ static bool test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
r2.in.connect_handle = &h;
|
||||
r2.in.domain_name = domname;
|
||||
r2.out.sid = &sid;
|
||||
|
||||
printf("domain lookup on %s\n", domname->string);
|
||||
|
||||
@ -70,7 +72,7 @@ static bool test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
r3.in.connect_handle = &h;
|
||||
r3.in.access_mask = *access_mask;
|
||||
r3.in.sid = *sid = r2.out.sid;
|
||||
r3.in.sid = *sid_p = *r2.out.sid;
|
||||
r3.out.domain_handle = &domain_handle;
|
||||
|
||||
printf("opening domain\n");
|
||||
|
@ -142,6 +142,7 @@ static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
struct policy_handle h, domain_handle;
|
||||
struct samr_Connect r1;
|
||||
struct samr_LookupDomain r2;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct samr_OpenDomain r3;
|
||||
|
||||
printf("connecting\n");
|
||||
@ -158,6 +159,7 @@ static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
r2.in.connect_handle = &h;
|
||||
r2.in.domain_name = domname;
|
||||
r2.out.sid = &sid;
|
||||
|
||||
printf("domain lookup on %s\n", domname->string);
|
||||
|
||||
@ -169,7 +171,7 @@ static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
r3.in.connect_handle = &h;
|
||||
r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
r3.in.sid = r2.out.sid;
|
||||
r3.in.sid = *r2.out.sid;
|
||||
r3.out.domain_handle = &domain_handle;
|
||||
|
||||
printf("opening domain\n");
|
||||
|
@ -95,6 +95,7 @@ static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
struct policy_handle h, domain_handle;
|
||||
struct samr_Connect r1;
|
||||
struct samr_LookupDomain r2;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct samr_OpenDomain r3;
|
||||
|
||||
printf("connecting\n");
|
||||
@ -111,6 +112,7 @@ static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
r2.in.connect_handle = &h;
|
||||
r2.in.domain_name = domname;
|
||||
r2.out.sid = &sid;
|
||||
|
||||
printf("domain lookup on %s\n", domname->string);
|
||||
|
||||
@ -122,7 +124,7 @@ static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
r3.in.connect_handle = &h;
|
||||
r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
r3.in.sid = r2.out.sid;
|
||||
r3.in.sid = *r2.out.sid;
|
||||
r3.out.domain_handle = &domain_handle;
|
||||
|
||||
printf("opening domain\n");
|
||||
|
@ -32,12 +32,13 @@
|
||||
bool test_opendomain(struct torture_context *tctx,
|
||||
struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
struct policy_handle *handle, struct lsa_String *domname,
|
||||
struct dom_sid2 *sid)
|
||||
struct dom_sid2 *sid_p)
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct policy_handle h, domain_handle;
|
||||
struct samr_Connect r1;
|
||||
struct samr_LookupDomain r2;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct samr_OpenDomain r3;
|
||||
|
||||
torture_comment(tctx, "connecting\n");
|
||||
@ -51,6 +52,7 @@ bool test_opendomain(struct torture_context *tctx,
|
||||
|
||||
r2.in.connect_handle = &h;
|
||||
r2.in.domain_name = domname;
|
||||
r2.out.sid = &sid;
|
||||
|
||||
torture_comment(tctx, "domain lookup on %s\n", domname->string);
|
||||
|
||||
@ -59,7 +61,7 @@ bool test_opendomain(struct torture_context *tctx,
|
||||
|
||||
r3.in.connect_handle = &h;
|
||||
r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
r3.in.sid = r2.out.sid;
|
||||
r3.in.sid = *r2.out.sid;
|
||||
r3.out.domain_handle = &domain_handle;
|
||||
|
||||
torture_comment(tctx, "opening domain\n");
|
||||
@ -68,7 +70,7 @@ bool test_opendomain(struct torture_context *tctx,
|
||||
torture_assert_ntstatus_ok(tctx, status, "OpenDomain failed");
|
||||
*handle = domain_handle;
|
||||
|
||||
*sid = *r2.out.sid;
|
||||
*sid_p = **r2.out.sid;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
|
||||
char **domain,
|
||||
struct dcerpc_pipe **result_pipe,
|
||||
struct policy_handle **result_handle,
|
||||
struct dom_sid **sid)
|
||||
struct dom_sid **sid_p)
|
||||
{
|
||||
struct dcerpc_pipe *samr_pipe;
|
||||
NTSTATUS status;
|
||||
@ -366,6 +366,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
|
||||
struct samr_EnumDomains enumdom;
|
||||
uint32_t resume_handle = 0;
|
||||
struct samr_LookupDomain l;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
int dom_idx;
|
||||
struct lsa_String domain_name;
|
||||
struct lsa_String user_name;
|
||||
@ -444,6 +445,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
|
||||
domain_name.string = enumdom.out.sam->entries[dom_idx].name.string;
|
||||
*domain = talloc_strdup(mem_ctx, domain_name.string);
|
||||
l.in.domain_name = &domain_name;
|
||||
l.out.sid = &sid;
|
||||
|
||||
status = dcerpc_samr_LookupDomain(samr_pipe, mem_ctx, &l);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -453,7 +455,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
|
||||
|
||||
o.in.connect_handle = &conn_handle;
|
||||
o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
o.in.sid = l.out.sid;
|
||||
o.in.sid = *l.out.sid;
|
||||
o.out.domain_handle = &domain_handle;
|
||||
|
||||
status = dcerpc_samr_OpenDomain(samr_pipe, mem_ctx, &o);
|
||||
@ -512,8 +514,8 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
|
||||
|
||||
*result_pipe = samr_pipe;
|
||||
*result_handle = user_handle;
|
||||
if (sid != NULL) {
|
||||
*sid = dom_sid_add_rid(mem_ctx, l.out.sid, user_rid);
|
||||
if (sid_p != NULL) {
|
||||
*sid_p = dom_sid_add_rid(mem_ctx, *l.out.sid, user_rid);
|
||||
}
|
||||
return NT_STATUS_OK;
|
||||
|
||||
|
@ -4538,6 +4538,7 @@ static bool test_LookupDomain(struct dcerpc_pipe *p, struct torture_context *tct
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct samr_LookupDomain r;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct lsa_String n1;
|
||||
struct lsa_String n2;
|
||||
bool ret = true;
|
||||
@ -4547,6 +4548,7 @@ static bool test_LookupDomain(struct dcerpc_pipe *p, struct torture_context *tct
|
||||
/* check for correct error codes */
|
||||
r.in.connect_handle = handle;
|
||||
r.in.domain_name = &n2;
|
||||
r.out.sid = &sid;
|
||||
n2.string = NULL;
|
||||
|
||||
status = dcerpc_samr_LookupDomain(p, tctx, &r);
|
||||
@ -4569,7 +4571,7 @@ static bool test_LookupDomain(struct dcerpc_pipe *p, struct torture_context *tct
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if (!test_OpenDomain(p, tctx, handle, r.out.sid, which_ops)) {
|
||||
if (!test_OpenDomain(p, tctx, handle, *r.out.sid, which_ops)) {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
|
@ -390,6 +390,7 @@ static bool test_samr_accessmask_LookupDomain(struct torture_context *tctx,
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct samr_LookupDomain ld;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct policy_handle ch;
|
||||
struct lsa_String dn;
|
||||
int i;
|
||||
@ -415,6 +416,7 @@ static bool test_samr_accessmask_LookupDomain(struct torture_context *tctx,
|
||||
|
||||
ld.in.connect_handle = &ch;
|
||||
ld.in.domain_name = &dn;
|
||||
ld.out.sid = &sid;
|
||||
dn.string = lp_workgroup(tctx->lp_ctx);
|
||||
|
||||
status = dcerpc_samr_LookupDomain(p, tctx, &ld);
|
||||
@ -474,6 +476,7 @@ static bool test_samr_accessmask_OpenDomain(struct torture_context *tctx,
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct samr_LookupDomain ld;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct samr_OpenDomain od;
|
||||
struct policy_handle ch;
|
||||
struct policy_handle dh;
|
||||
@ -491,6 +494,7 @@ static bool test_samr_accessmask_OpenDomain(struct torture_context *tctx,
|
||||
|
||||
ld.in.connect_handle = &ch;
|
||||
ld.in.domain_name = &dn;
|
||||
ld.out.sid = &sid;
|
||||
dn.string = lp_workgroup(tctx->lp_ctx);
|
||||
status = dcerpc_samr_LookupDomain(p, tctx, &ld);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -520,7 +524,7 @@ static bool test_samr_accessmask_OpenDomain(struct torture_context *tctx,
|
||||
|
||||
od.in.connect_handle = &ch;
|
||||
od.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
od.in.sid = ld.out.sid;
|
||||
od.in.sid = *ld.out.sid;
|
||||
od.out.domain_handle = &dh;
|
||||
|
||||
status = dcerpc_samr_OpenDomain(p, tctx, &od);
|
||||
|
@ -151,17 +151,19 @@ struct samsync_trusted_domain {
|
||||
static struct policy_handle *samsync_open_domain(TALLOC_CTX *mem_ctx,
|
||||
struct samsync_state *samsync_state,
|
||||
const char *domain,
|
||||
struct dom_sid **sid)
|
||||
struct dom_sid **sid_p)
|
||||
{
|
||||
struct lsa_String name;
|
||||
struct samr_OpenDomain o;
|
||||
struct samr_LookupDomain l;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct policy_handle *domain_handle = talloc(mem_ctx, struct policy_handle);
|
||||
NTSTATUS nt_status;
|
||||
|
||||
name.string = domain;
|
||||
l.in.connect_handle = samsync_state->connect_handle;
|
||||
l.in.domain_name = &name;
|
||||
l.out.sid = &sid;
|
||||
|
||||
nt_status = dcerpc_samr_LookupDomain(samsync_state->p_samr, mem_ctx, &l);
|
||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||
@ -171,11 +173,11 @@ static struct policy_handle *samsync_open_domain(TALLOC_CTX *mem_ctx,
|
||||
|
||||
o.in.connect_handle = samsync_state->connect_handle;
|
||||
o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
o.in.sid = l.out.sid;
|
||||
o.in.sid = *l.out.sid;
|
||||
o.out.domain_handle = domain_handle;
|
||||
|
||||
if (sid) {
|
||||
*sid = l.out.sid;
|
||||
*sid_p = *l.out.sid;
|
||||
}
|
||||
|
||||
nt_status = dcerpc_samr_OpenDomain(samsync_state->p_samr, mem_ctx, &o);
|
||||
|
@ -116,6 +116,7 @@ struct test_join *torture_create_testuser(struct torture_context *torture,
|
||||
struct samr_CreateUser2 r;
|
||||
struct samr_OpenDomain o;
|
||||
struct samr_LookupDomain l;
|
||||
struct dom_sid2 *sid = NULL;
|
||||
struct samr_GetUserPwInfo pwp;
|
||||
struct samr_PwInfo info;
|
||||
struct samr_SetUserInfo s;
|
||||
@ -176,6 +177,7 @@ struct test_join *torture_create_testuser(struct torture_context *torture,
|
||||
name.string = domain;
|
||||
l.in.connect_handle = &handle;
|
||||
l.in.domain_name = &name;
|
||||
l.out.sid = &sid;
|
||||
|
||||
status = dcerpc_samr_LookupDomain(join->p, join, &l);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -183,14 +185,14 @@ struct test_join *torture_create_testuser(struct torture_context *torture,
|
||||
goto failed;
|
||||
}
|
||||
|
||||
talloc_steal(join, l.out.sid);
|
||||
join->dom_sid = l.out.sid;
|
||||
talloc_steal(join, *l.out.sid);
|
||||
join->dom_sid = *l.out.sid;
|
||||
join->dom_netbios_name = talloc_strdup(join, domain);
|
||||
if (!join->dom_netbios_name) goto failed;
|
||||
|
||||
o.in.connect_handle = &handle;
|
||||
o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
||||
o.in.sid = l.out.sid;
|
||||
o.in.sid = *l.out.sid;
|
||||
o.out.domain_handle = &domain_handle;
|
||||
|
||||
status = dcerpc_samr_OpenDomain(join->p, join, &o);
|
||||
|
Loading…
Reference in New Issue
Block a user