s4-samr: merge samr_EnumDomains from s3 idl. (fixme: python)
[bbaumbach/samba-autobuild/.git] / source4 / torture / rpc / samba3rpc.c
index 25ff7d0ea9b4052c8ec5360836e2d73f18c69495..3b26799021028ca2b62080b2a57a402e9dc4ff51 100644 (file)
@@ -89,9 +89,13 @@ bool torture_bind_authcontext(struct torture_context *torture)
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
                                        lp_smb_ports(torture->lp_ctx),
-                                       "IPC$", NULL, cmdline_credentials,
+                                       "IPC$", NULL, 
+                                       lp_socket_options(torture->lp_ctx),
+                                       cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
-                                       torture->ev, &options, &session_options);
+                                       torture->ev, &options, &session_options,
+                                       lp_iconv_convenience(torture->lp_ctx),
+                                       lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -159,6 +163,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
        setup.in.capabilities = cli->transport->negotiate.capabilities;
        setup.in.workgroup = "";
        setup.in.credentials = anon_creds;
+       setup.in.gensec_settings = lp_gensec_settings(torture, torture->lp_ctx);
 
        status = smb_composite_sesssetup(session2, &setup);
        if (!NT_STATUS_IS_OK(status)) {
@@ -207,6 +212,7 @@ static bool bindtest(struct smbcli_state *cli,
        struct lsa_ObjectAttribute objectattr;
        struct lsa_OpenPolicy2 openpolicy;
        struct lsa_QueryInfoPolicy query;
+       union lsa_PolicyInformation *info = NULL;
        struct policy_handle handle;
        struct lsa_Close close_handle;
 
@@ -231,7 +237,7 @@ static bool bindtest(struct smbcli_state *cli,
        }
 
        status = dcerpc_bind_auth(lsa_pipe, &ndr_table_lsarpc,
-                                 credentials, lp_ctx, auth_type, auth_level,
+                                 credentials, lp_gensec_settings(lp_ctx, lp_ctx), auth_type, auth_level,
                                  NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("dcerpc_bind_auth failed: %s\n", nt_errstr(status));
@@ -255,6 +261,7 @@ static bool bindtest(struct smbcli_state *cli,
 
        query.in.handle = &handle;
        query.in.level = LSA_POLICY_INFO_DOMAIN;
+       query.out.info = &info;
 
        status = dcerpc_lsa_QueryInfoPolicy(lsa_pipe, mem_ctx, &query);
        if (!NT_STATUS_IS_OK(status)) {
@@ -305,9 +312,13 @@ bool torture_bind_samba3(struct torture_context *torture)
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
                                        lp_smb_ports(torture->lp_ctx),
-                                       "IPC$", NULL, cmdline_credentials,
+                                       "IPC$", NULL, 
+                                       lp_socket_options(torture->lp_ctx),
+                                       cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
-                                       torture->ev, &options, &session_options);
+                                       torture->ev, &options, &session_options,
+                                       lp_iconv_convenience(torture->lp_ctx),
+                                       lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -344,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;
@@ -354,7 +365,10 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
        struct samr_Connect2 conn;
        struct samr_EnumDomains enumdom;
        uint32_t resume_handle = 0;
+       uint32_t num_entries = 0;
+       struct samr_SamArray *sam = NULL;
        struct samr_LookupDomain l;
+       struct dom_sid2 *sid = NULL;
        int dom_idx;
        struct lsa_String domain_name;
        struct lsa_String user_name;
@@ -380,7 +394,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
 
        if (admin_creds != NULL) {
                status = dcerpc_bind_auth(samr_pipe, &ndr_table_samr,
-                                         admin_creds, lp_ctx, auth_type, auth_level,
+                                         admin_creds, lp_gensec_settings(lp_ctx, lp_ctx), auth_type, auth_level,
                                          NULL);
                if (!NT_STATUS_IS_OK(status)) {
                        d_printf("dcerpc_bind_auth failed: %s\n",
@@ -412,6 +426,8 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
        enumdom.in.resume_handle = &resume_handle;
        enumdom.in.buf_size = (uint32_t)-1;
        enumdom.out.resume_handle = &resume_handle;
+       enumdom.out.num_entries = &num_entries;
+       enumdom.out.sam = &sam;
 
        status = dcerpc_samr_EnumDomains(samr_pipe, mem_ctx, &enumdom);
        if (!NT_STATUS_IS_OK(status)) {
@@ -419,20 +435,21 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
                goto fail;
        }
 
-       if (enumdom.out.num_entries != 2) {
+       if (*enumdom.out.num_entries != 2) {
                d_printf("samr_EnumDomains returned %d entries, expected 2\n",
-                        enumdom.out.num_entries);
+                        *enumdom.out.num_entries);
                status = NT_STATUS_UNSUCCESSFUL;
                goto fail;
        }
 
-       dom_idx = strequal(enumdom.out.sam->entries[0].name.string,
+       dom_idx = strequal(sam->entries[0].name.string,
                           "builtin") ? 1:0;
 
        l.in.connect_handle = &conn_handle;
-       domain_name.string = enumdom.out.sam->entries[dom_idx].name.string;
+       domain_name.string = 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)) {
@@ -442,7 +459,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);
@@ -466,10 +483,13 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
        if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
                struct samr_LookupNames ln;
                struct samr_OpenUser ou;
+               struct samr_Ids rids, types;
 
                ln.in.domain_handle = &domain_handle;
                ln.in.num_names = 1;
                ln.in.names = &user_name;
+               ln.out.rids = &rids;
+               ln.out.types = &types;
 
                status = dcerpc_samr_LookupNames(samr_pipe, mem_ctx, &ln);
                if (!NT_STATUS_IS_OK(status)) {
@@ -480,7 +500,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
 
                ou.in.domain_handle = &domain_handle;
                ou.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
-               user_rid = ou.in.rid = ln.out.rids.ids[0];
+               user_rid = ou.in.rid = ln.out.rids->ids[0];
                ou.out.user_handle = user_handle;
 
                status = dcerpc_samr_OpenUser(samr_pipe, mem_ctx, &ou);
@@ -498,8 +518,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;
 
@@ -916,7 +936,7 @@ static bool auth2(struct smbcli_state *cli,
        generate_random_buffer(netr_cli_creds.data,
                               sizeof(netr_cli_creds.data));
        r.in.credentials = &netr_cli_creds;
-       r.out.credentials = &netr_srv_creds;
+       r.out.return_credentials = &netr_srv_creds;
 
        status = dcerpc_netr_ServerReqChallenge(net_pipe, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
@@ -930,7 +950,7 @@ static bool auth2(struct smbcli_state *cli,
 
        creds_state = talloc(mem_ctx, struct creds_CredentialState);
        creds_client_init(creds_state, r.in.credentials,
-                         r.out.credentials, &mach_pw,
+                         r.out.return_credentials, &mach_pw,
                          &netr_cred, negotiate_flags);
 
        a.in.server_name = talloc_asprintf(
@@ -942,7 +962,7 @@ static bool auth2(struct smbcli_state *cli,
        a.in.negotiate_flags = &negotiate_flags;
        a.out.negotiate_flags = &negotiate_flags;
        a.in.credentials = &netr_cred;
-       a.out.credentials = &netr_cred;
+       a.out.return_credentials = &netr_cred;
 
        status = dcerpc_netr_ServerAuthenticate2(net_pipe, mem_ctx, &a);
        if (!NT_STATUS_IS_OK(status)) {
@@ -951,7 +971,7 @@ static bool auth2(struct smbcli_state *cli,
                goto done;
        }
 
-       if (!creds_client_check(creds_state, a.out.credentials)) {
+       if (!creds_client_check(creds_state, a.out.return_credentials)) {
                d_printf("creds_client_check failed\n");
                goto done;
        }
@@ -1009,7 +1029,7 @@ static bool schan(struct smbcli_state *cli,
 #if 1
        net_pipe->conn->flags |= (DCERPC_SIGN | DCERPC_SEAL);
        status = dcerpc_bind_auth(net_pipe, &ndr_table_netlogon,
-                                 wks_creds, lp_ctx, DCERPC_AUTH_TYPE_SCHANNEL,
+                                 wks_creds, lp_gensec_settings(lp_ctx, lp_ctx), DCERPC_AUTH_TYPE_SCHANNEL,
                                  DCERPC_AUTH_LEVEL_PRIVACY,
                                  NULL);
 #else
@@ -1029,6 +1049,10 @@ static bool schan(struct smbcli_state *cli,
                struct netr_NetworkInfo ninfo;
                struct netr_PasswordInfo pinfo;
                struct netr_LogonSamLogon r;
+               union netr_LogonLevel logon;
+               union netr_Validation validation;
+               uint8_t authoritative;
+               struct netr_Authenticator return_authenticator;
 
                flags = CLI_CRED_LANMAN_AUTH | CLI_CRED_NTLM_AUTH |
                        CLI_CRED_NTLMv2_AUTH;
@@ -1071,6 +1095,8 @@ static bool schan(struct smbcli_state *cli,
                ninfo.lm.length = lm_resp.length;
                ninfo.lm.data = lm_resp.data;
 
+               logon.network = &ninfo;
+
                r.in.server_name = talloc_asprintf(
                        mem_ctx, "\\\\%s", dcerpc_server_name(net_pipe));
                ZERO_STRUCT(netr_auth2);
@@ -1080,8 +1106,10 @@ static bool schan(struct smbcli_state *cli,
                r.in.return_authenticator = &netr_auth2;
                r.in.logon_level = 2;
                r.in.validation_level = i;
-               r.in.logon.network = &ninfo;
-               r.out.return_authenticator = NULL;
+               r.in.logon = &logon;
+               r.out.validation = &validation;
+               r.out.authoritative = &authoritative;
+               r.out.return_authenticator = &return_authenticator;
 
                status = dcerpc_netr_LogonSamLogon(net_pipe, mem_ctx, &r);
                if (!NT_STATUS_IS_OK(status)) {
@@ -1109,9 +1137,11 @@ static bool schan(struct smbcli_state *cli,
                                   sizeof(pinfo.ntpassword.hash),
                                   &session_key);
 
+               logon.password = &pinfo;
+
                r.in.logon_level = 1;
-               r.in.logon.password = &pinfo;
-               r.out.return_authenticator = NULL;
+               r.in.logon = &logon;
+               r.out.return_authenticator = &return_authenticator;
 
                status = dcerpc_netr_LogonSamLogon(net_pipe, mem_ctx, &r);
                if (!NT_STATUS_IS_OK(status)) {
@@ -1132,6 +1162,8 @@ static bool schan(struct smbcli_state *cli,
                struct netr_ServerPasswordSet s;
                char *password = generate_random_str(wks_creds, 8);
                struct creds_CredentialState *creds_state;
+               struct netr_Authenticator credential, return_authenticator;
+               struct samr_Password new_password;
 
                s.in.server_name = talloc_asprintf(
                        mem_ctx, "\\\\%s", dcerpc_server_name(net_pipe));
@@ -1139,11 +1171,15 @@ static bool schan(struct smbcli_state *cli,
                s.in.account_name = talloc_asprintf(
                        mem_ctx, "%s$", s.in.computer_name);
                s.in.secure_channel_type = SEC_CHAN_WKSTA;
-               E_md4hash(password, s.in.new_password.hash);
+               s.in.credential = &credential;
+               s.in.new_password = &new_password;
+               s.out.return_authenticator = &return_authenticator;
+
+               E_md4hash(password, new_password.hash);
 
                creds_state = cli_credentials_get_netlogon_creds(wks_creds);
-               creds_des_encrypt(creds_state, &s.in.new_password);
-               creds_client_authenticator(creds_state, &s.in.credential);
+               creds_des_encrypt(creds_state, &new_password);
+               creds_client_authenticator(creds_state, &credential);
 
                status = dcerpc_netr_ServerPasswordSet(net_pipe, mem_ctx, &s);
                if (!NT_STATUS_IS_OK(status)) {
@@ -1152,7 +1188,7 @@ static bool schan(struct smbcli_state *cli,
                }
 
                if (!creds_client_check(creds_state,
-                                       &s.out.return_authenticator.cred)) {
+                                       &s.out.return_authenticator->cred)) {
                        printf("Credential chaining failed\n");
                }
 
@@ -1224,9 +1260,13 @@ bool torture_netlogon_samba3(struct torture_context *torture)
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
                                        lp_smb_ports(torture->lp_ctx),
-                                       "IPC$", NULL, anon_creds, 
+                                       "IPC$", NULL, 
+                                       lp_socket_options(torture->lp_ctx),
+                                       anon_creds, 
                                        lp_resolve_context(torture->lp_ctx),
-                                       torture->ev, &options, &session_options);
+                                       torture->ev, &options, &session_options,
+                                       lp_iconv_convenience(torture->lp_ctx),
+                                       lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1313,9 +1353,11 @@ static bool test_join3(struct torture_context *tctx,
        status = smbcli_full_connection(tctx, &cli,
                                        torture_setting_string(tctx, "host", NULL),
                                        lp_smb_ports(tctx->lp_ctx),
-                                       "IPC$", NULL, smb_creds, 
-                                       lp_resolve_context(tctx->lp_ctx),
-                                       tctx->ev, &options, &session_options);
+                                       "IPC$", NULL, lp_socket_options(tctx->lp_ctx),
+                                       smb_creds, lp_resolve_context(tctx->lp_ctx),
+                                       tctx->ev, &options, &session_options,
+                                       lp_iconv_convenience(tctx->lp_ctx),
+                                       lp_gensec_settings(tctx, tctx->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1496,6 +1538,7 @@ static struct dom_sid *name2sid(TALLOC_CTX *mem_ctx,
        struct policy_handle handle;
        struct lsa_LookupNames l;
        struct lsa_TransSidArray sids;
+       struct lsa_RefDomainList *domains = NULL;
        struct lsa_String lsa_name;
        uint32_t count = 0;
        struct dom_sid *result;
@@ -1542,6 +1585,7 @@ static struct dom_sid *name2sid(TALLOC_CTX *mem_ctx,
        l.in.count = &count;
        l.out.count = &count;
        l.out.sids = &sids;
+       l.out.domains = &domains;
 
        status = dcerpc_lsa_LookupNames(p, tmp_ctx, &l);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1551,7 +1595,7 @@ static struct dom_sid *name2sid(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       result = dom_sid_add_rid(mem_ctx, l.out.domains->domains[0].sid,
+       result = dom_sid_add_rid(mem_ctx, domains->domains[0].sid,
                                 l.out.sids->sids[0].rid);
 
        c.in.handle = &handle;
@@ -1579,7 +1623,8 @@ static struct dom_sid *whoami(TALLOC_CTX *mem_ctx,
        struct dcerpc_pipe *lsa;
        struct lsa_GetUserName r;
        NTSTATUS status;
-       struct lsa_StringPointer authority_name_p;
+       struct lsa_String *authority_name_p = NULL;
+       struct lsa_String *account_name_p = NULL;
        struct dom_sid *result;
 
        status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\lsarpc",
@@ -1591,12 +1636,14 @@ static struct dom_sid *whoami(TALLOC_CTX *mem_ctx,
        }
 
        r.in.system_name = "\\";
-       r.in.account_name = NULL;
-       authority_name_p.string = NULL;
+       r.in.account_name = &account_name_p;
        r.in.authority_name = &authority_name_p;
+       r.out.account_name = &account_name_p;
 
        status = dcerpc_lsa_GetUserName(lsa, mem_ctx, &r);
 
+       authority_name_p = *r.out.authority_name;
+
        if (!NT_STATUS_IS_OK(status)) {
                printf("(%s) GetUserName failed - %s\n",
                       __location__, nt_errstr(status));
@@ -1604,8 +1651,8 @@ static struct dom_sid *whoami(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       result = name2sid(mem_ctx, lsa, r.out.account_name->string,
-                         r.out.authority_name->string->string);
+       result = name2sid(mem_ctx, lsa, account_name_p->string,
+                         authority_name_p->string);
 
        talloc_free(lsa);
        return result;
@@ -1690,9 +1737,11 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
        status = smbcli_full_connection(
                mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
                lp_smb_ports(torture->lp_ctx),
-               "IPC$", NULL, cmdline_credentials, 
+               "IPC$", NULL, lp_socket_options(torture->lp_ctx), cmdline_credentials, 
                lp_resolve_context(torture->lp_ctx),
-               torture->ev, &options, &session_options);
+               torture->ev, &options, &session_options,
+               lp_iconv_convenience(torture->lp_ctx),
+               lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
@@ -1716,10 +1765,12 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
 
        status = smbcli_full_connection(
                mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
-               lp_smb_ports(torture->lp_ctx),
-               "IPC$", NULL, anon_creds, 
+               lp_smb_ports(torture->lp_ctx), "IPC$", NULL, 
+               lp_socket_options(torture->lp_ctx), anon_creds, 
                lp_resolve_context(torture->lp_ctx),
-               torture->ev, &options, &session_options);
+               torture->ev, &options, &session_options,
+               lp_iconv_convenience(torture->lp_ctx),
+               lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) anon smbcli_full_connection failed: %s\n",
                         __location__, nt_errstr(status));
@@ -1783,6 +1834,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
                setup.in.capabilities = cli->transport->negotiate.capabilities;
                setup.in.workgroup = "";
                setup.in.credentials = user_creds;
+               setup.in.gensec_settings = lp_gensec_settings(torture, torture->lp_ctx);
 
                status = smb_composite_sesssetup(session2, &setup);
                if (!NT_STATUS_IS_OK(status)) {
@@ -1837,6 +1889,7 @@ static bool test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 {
        NTSTATUS status;
        struct srvsvc_NetShareGetInfo r;
+       union srvsvc_NetShareInfo info;
        uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007, 1501 };
        int i;
        bool ret = true;
@@ -1844,12 +1897,11 @@ static bool test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s",
                                          dcerpc_server_name(p));
        r.in.share_name = sharename;
+       r.out.info = &info;
 
        for (i=0;i<ARRAY_SIZE(levels);i++) {
                r.in.level = levels[i];
 
-               ZERO_STRUCT(r.out);
-
                printf("testing NetShareGetInfo level %u on share '%s'\n", 
                       r.in.level, r.in.share_name);
 
@@ -1878,38 +1930,87 @@ static bool test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 {
        NTSTATUS status;
        struct srvsvc_NetShareEnum r;
+       struct srvsvc_NetShareInfoCtr info_ctr;
        struct srvsvc_NetShareCtr0 c0;
+       struct srvsvc_NetShareCtr1 c1;
+       struct srvsvc_NetShareCtr2 c2;
+       struct srvsvc_NetShareCtr501 c501;
+       struct srvsvc_NetShareCtr502 c502;
+       struct srvsvc_NetShareCtr1004 c1004;
+       struct srvsvc_NetShareCtr1005 c1005;
+       struct srvsvc_NetShareCtr1006 c1006;
+       struct srvsvc_NetShareCtr1007 c1007;
+       uint32_t totalentries = 0;
        uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007 };
        int i;
        bool ret = true;
 
+       ZERO_STRUCT(info_ctr);
+
        r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
-       r.in.ctr.ctr0 = &c0;
-       r.in.ctr.ctr0->count = 0;
-       r.in.ctr.ctr0->array = NULL;
+       r.in.info_ctr = &info_ctr;
        r.in.max_buffer = (uint32_t)-1;
        r.in.resume_handle = NULL;
+       r.out.totalentries = &totalentries;
+       r.out.info_ctr = &info_ctr;
 
        for (i=0;i<ARRAY_SIZE(levels);i++) {
-               r.in.level = levels[i];
-
-               ZERO_STRUCT(r.out);
+               info_ctr.level = levels[i];
+
+               switch (info_ctr.level) {
+               case 0:
+                       ZERO_STRUCT(c0);
+                       info_ctr.ctr.ctr0 = &c0;
+                       break;
+               case 1:
+                       ZERO_STRUCT(c1);
+                       info_ctr.ctr.ctr1 = &c1;
+                       break;
+               case 2:
+                       ZERO_STRUCT(c2);
+                       info_ctr.ctr.ctr2 = &c2;
+                       break;
+               case 501:
+                       ZERO_STRUCT(c501);
+                       info_ctr.ctr.ctr501 = &c501;
+                       break;
+               case 502:
+                       ZERO_STRUCT(c502);
+                       info_ctr.ctr.ctr502 = &c502;
+                       break;
+               case 1004:
+                       ZERO_STRUCT(c1004);
+                       info_ctr.ctr.ctr1004 = &c1004;
+                       break;
+               case 1005:
+                       ZERO_STRUCT(c1005);
+                       info_ctr.ctr.ctr1005 = &c1005;
+                       break;
+               case 1006:
+                       ZERO_STRUCT(c1006);
+                       info_ctr.ctr.ctr1006 = &c1006;
+                       break;
+               case 1007:
+                       ZERO_STRUCT(c1007);
+                       info_ctr.ctr.ctr1007 = &c1007;
+                       break;
+               }
 
-               printf("testing NetShareEnum level %u\n", r.in.level);
+               printf("testing NetShareEnum level %u\n", info_ctr.level);
                status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r);
                if (!NT_STATUS_IS_OK(status)) {
                        printf("NetShareEnum level %u failed - %s\n",
-                              r.in.level, nt_errstr(status));
+                              info_ctr.level, nt_errstr(status));
                        ret = false;
                        continue;
                }
                if (!W_ERROR_IS_OK(r.out.result)) {
                        printf("NetShareEnum level %u failed - %s\n",
-                              r.in.level, win_errstr(r.out.result));
+                              info_ctr.level, win_errstr(r.out.result));
                        continue;
                }
-               if (r.in.level == 0) {
-                       struct srvsvc_NetShareCtr0 *ctr = r.out.ctr.ctr0;
+               if (info_ctr.level == 0) {
+                       struct srvsvc_NetShareCtr0 *ctr = r.out.info_ctr->ctr.ctr0;
                        if (ctr->count > 0) {
                                *one_sharename = ctr->array[0].name;
                        }
@@ -2032,7 +2133,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
        generate_random_buffer(netr_cli_creds.data,
                               sizeof(netr_cli_creds.data));
        r.in.credentials = &netr_cli_creds;
-       r.out.credentials = &netr_srv_creds;
+       r.out.return_credentials = &netr_srv_creds;
 
        status = dcerpc_netr_ServerReqChallenge(net_pipe, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
@@ -2046,7 +2147,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
 
        creds_state = talloc(mem_ctx, struct creds_CredentialState);
        creds_client_init(creds_state, r.in.credentials,
-                         r.out.credentials, &mach_pw,
+                         r.out.return_credentials, &mach_pw,
                          &netr_cred, negotiate_flags);
 
        a.in.server_name = talloc_asprintf(
@@ -2058,7 +2159,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
        a.in.negotiate_flags = &negotiate_flags;
        a.out.negotiate_flags = &negotiate_flags;
        a.in.credentials = &netr_cred;
-       a.out.credentials = &netr_cred;
+       a.out.return_credentials = &netr_cred;
 
        status = dcerpc_netr_ServerAuthenticate2(net_pipe, mem_ctx, &a);
 
@@ -2085,6 +2186,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx,
        struct dcerpc_pipe *p;
        NTSTATUS status;
        struct srvsvc_NetShareGetInfo r;
+       union srvsvc_NetShareInfo info;
        struct security_descriptor *result;
 
        if (!(tmp_ctx = talloc_new(mem_ctx))) {
@@ -2115,6 +2217,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx,
                                          dcerpc_server_name(p));
        r.in.share_name = sharename;
        r.in.level = 502;
+       r.out.info = &info;
 
        status = dcerpc_srvsvc_NetShareGetInfo(p, tmp_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
@@ -2124,7 +2227,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       result = talloc_steal(mem_ctx, r.out.info.info502->sd);
+       result = talloc_steal(mem_ctx, info.info502->sd_buf.sd);
        talloc_free(tmp_ctx);
        return result;
 }
@@ -2141,6 +2244,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        struct sec_desc_buf i;
        struct srvsvc_NetShareSetInfo r;
+       union srvsvc_NetShareInfo info;
        uint32_t error = 0;
 
        if (!(tmp_ctx = talloc_new(mem_ctx))) {
@@ -2172,12 +2276,13 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx,
        r.in.share_name = sharename;
        r.in.level = 1501;
        i.sd = sd;
-       r.in.info.info1501 = &i;
+       info.info1501 = &i;
+       r.in.info = &info;
        r.in.parm_error = &error;
 
        status = dcerpc_srvsvc_NetShareSetInfo(p, tmp_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               d_printf("srvsvc_NetShareGetInfo failed: %s\n",
+               d_printf("srvsvc_NetShareSetInfo failed: %s\n",
                         nt_errstr(status));
        }
 
@@ -2382,8 +2487,10 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture)
 
                for (i=0; i<ARRAY_SIZE(levels); i++) {
                        struct lsa_QueryInfoPolicy r;
+                       union lsa_PolicyInformation *info = NULL;
                        r.in.handle = &lsa_handle;
                        r.in.level = levels[i];
+                       r.out.info = &info;
                        status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r);
                        if (!NT_STATUS_IS_OK(status)) {
                                d_printf("(%s) dcerpc_lsa_QueryInfoPolicy %d "
@@ -2393,7 +2500,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture)
                                return false;
                        }
                        if (levels[i] == 5) {
-                               domain_sid = r.out.info->account_domain.sid;
+                               domain_sid = info->account_domain.sid;
                        }
                }
        }
@@ -2436,8 +2543,10 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct loadparm_context *lp_ctx,
        NTSTATUS status;
        struct dcerpc_pipe *p;
        struct srvsvc_NetShareEnum r;
+       struct srvsvc_NetShareInfoCtr info_ctr;
        struct srvsvc_NetShareCtr1 c1_in;
        struct srvsvc_NetShareCtr1 *c1;
+       uint32_t totalentries = 0;
        int i;
 
        mem_ctx = talloc_new(ctx);
@@ -2454,25 +2563,29 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct loadparm_context *lp_ctx,
                return status;
        }
 
+       ZERO_STRUCT(c1_in);
+       info_ctr.level = 1;
+       info_ctr.ctr.ctr1 = &c1_in;
+
        r.in.server_unc = talloc_asprintf(
                mem_ctx, "\\\\%s", dcerpc_server_name(p));
-       r.in.level = 1;
-       ZERO_STRUCT(c1_in);
-       r.in.ctr.ctr1 = &c1_in;
+       r.in.info_ctr = &info_ctr;
        r.in.max_buffer = (uint32_t)-1;
        r.in.resume_handle = NULL;
+       r.out.totalentries = &totalentries;
+       r.out.info_ctr = &info_ctr;
 
        status = dcerpc_srvsvc_NetShareEnum(p, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("NetShareEnum level %u failed - %s\n",
-                        r.in.level, nt_errstr(status));
+                        info_ctr.level, nt_errstr(status));
                talloc_free(mem_ctx);
                return status;
        }
 
        *printers = NULL;
        *num_printers = 0;
-       c1 = r.out.ctr.ctr1;
+       c1 = r.out.info_ctr->ctr.ctr1;
        for (i=0; i<c1->count; i++) {
                if (c1->array[i].type != STYPE_PRINTQ) {
                        continue;
@@ -3072,11 +3185,12 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx,
                              struct loadparm_context *lp_ctx,
                              struct smbcli_state *cli,
                              const char *share,
-                             struct srvsvc_NetShareInfo502 **info)
+                             struct srvsvc_NetShareInfo502 **info502)
 {
        struct smbcli_tree *ipc;
        struct dcerpc_pipe *p;
        struct srvsvc_NetShareGetInfo r;
+       union srvsvc_NetShareInfo info;
        NTSTATUS status;
 
        if (!(p = dcerpc_pipe_init(cli,
@@ -3109,15 +3223,16 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx,
                                          dcerpc_server_name(p));
        r.in.share_name = share;
        r.in.level = 502;
+       r.out.info = &info;
 
        status = dcerpc_srvsvc_NetShareGetInfo(p, p, &r);
        if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
-               d_printf("(%s) OpenHKLM failed: %s, %s\n", __location__,
+               d_printf("(%s) srvsvc_NetShareGetInfo failed: %s, %s\n", __location__,
                         nt_errstr(status), win_errstr(r.out.result));
                goto fail;
        }
 
-       *info = talloc_move(mem_ctx, &r.out.info.info502);
+       *info502 = talloc_move(mem_ctx, &info.info502);
        return NT_STATUS_OK;
 
  fail: