s4-samr: merge samr_LookupDomain from s3 idl. (fixme: python)
authorGünther Deschner <gd@samba.org>
Fri, 7 Nov 2008 01:42:45 +0000 (02:42 +0100)
committerGünther Deschner <gd@samba.org>
Mon, 10 Nov 2008 20:46:30 +0000 (21:46 +0100)
Guenther

14 files changed:
librpc/idl/samr.idl
source4/libnet/libnet_domain.c
source4/libnet/libnet_join.c
source4/libnet/libnet_passwd.c
source4/rpc_server/samr/dcesrv_samr.c
source4/torture/libnet/libnet_domain.c
source4/torture/libnet/libnet_group.c
source4/torture/libnet/libnet_user.c
source4/torture/libnet/utils.c
source4/torture/rpc/samba3rpc.c
source4/torture/rpc/samr.c
source4/torture/rpc/samr_accessmask.c
source4/torture/rpc/samsync.c
source4/torture/rpc/testjoin.c

index b2c9103d97b50bddbe8c4284ea0ff833965c18c1..3ad4cd602fd24ea585361b377a9fe8d66f372fe7 100644 (file)
@@ -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
                );
 
 
index ccdfdaf13489bbe1df8f6fa74b61389168500814..adb826a2d17cab183d45a66eda7d13b730dab0d9 100644 (file)
@@ -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;
        }
index e6664b24631d84c58b9ebe289ebdcb2d693de5ac..b813bba3ea03668eeaef8423819b791fd7e82d5a 100644 (file)
@@ -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 */
index d1e6fe79f4075cc3866fe6f0a5147c97344f77b0..976606e72cf5f7cd3ef574fcdb02ed39ab9ae170 100644 (file)
@@ -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 */
index a8d161a5779d971ceab039187b4bd289e46f9508..106767c8ae96808ed1ec30d6177a3804c38e9421 100644 (file)
@@ -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;
 }
index 7d5be368c2cc9a3c0d339b9c65471b9473f7c12b..3c28d1a019480854897c84478f75832ee2545a0f 100644 (file)
 
 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");
index 74da6162c6a4be1dee9cdfd32db106d5d785fcda..9c9ecfd525ab0302743fd3aa0879b050b6025280 100644 (file)
@@ -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");
index 98116d50f0400e68182ada808bc574bf9fd2a8c7..18007dccadd0f2e6804e7c98bf2b47a994fa34a9 100644 (file)
@@ -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");
index 67ee056dbe25acd9b2bb42410991b1748f61f24f..942540c80e0b8877da3e09c7b9095ccb9b786972 100644 (file)
 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;
 }
 
index 80db2dcf0781d9b46ebe57a6dc3b14285a958ba7..bf61054b54e75056f87f8aee9d1fbc9cb236b5ae 100644 (file)
@@ -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;
 
index fbdcd73881055c6f548623d390c46289774d2f98..874eba74d1ea7f49996a66847176a41bc0520791 100644 (file)
@@ -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;
        }
 
index eb19c0caa497369df784ca1520437f5852b2addd..6b60b8314f2c87a5b406c2d338858b96e0bd637f 100644 (file)
@@ -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);
index ba5b9f78d7bd44d32d7aeaa8bdf690c4cb8cc645..64612e21e4b79dd92ca3d4b4396b245dd79e9da1 100644 (file)
@@ -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);
index 28ce18dfca65f1cf12bcd6356c5f3d465fd4a5b6..3b56d5b0ad9dbb615e2c6edff0a5315e7b539b4b 100644 (file)
@@ -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);