Finish removal of iconv_convenience in public API's.
[bbaumbach/samba-autobuild/.git] / source4 / torture / rpc / samba3rpc.c
index 4de8f6778c087486ade18ab8f1939e2b22fc0f67..d09e80283a076a48c8817628186421cf6864fd18 100644 (file)
@@ -22,7 +22,7 @@
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
 #include "libcli/raw/raw_proto.h"
-#include "libcli/rap/rap.h"
+#include "../librpc/gen_ndr/rap.h"
 #include "torture/util.h"
 #include "torture/rap/proto.h"
 #include "librpc/gen_ndr/ndr_lsa_c.h"
@@ -33,7 +33,7 @@
 #include "librpc/gen_ndr/ndr_winreg_c.h"
 #include "librpc/gen_ndr/ndr_wkssvc_c.h"
 #include "lib/cmdline/popt_common.h"
-#include "torture/rpc/rpc.h"
+#include "torture/rpc/torture_rpc.h"
 #include "libcli/libcli.h"
 #include "libcli/smb_composite/smb_composite.h"
 #include "libcli/auth/libcli_auth.h"
@@ -84,7 +84,6 @@ bool torture_bind_authcontext(struct torture_context *torture)
                                        cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
                                        torture->ev, &options, &session_options,
-                                       lp_iconv_convenience(torture->lp_ctx),
                                        lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                torture_comment(torture, "smbcli_full_connection failed: %s\n",
@@ -92,8 +91,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
                goto done;
        }
 
-       lsa_pipe = dcerpc_pipe_init(mem_ctx, cli->transport->socket->event.ctx,
-                                   lp_iconv_convenience(torture->lp_ctx));
+       lsa_pipe = dcerpc_pipe_init(mem_ctx, cli->transport->socket->event.ctx);
        if (lsa_pipe == NULL) {
                torture_comment(torture, "dcerpc_pipe_init failed\n");
                goto done;
@@ -128,6 +126,11 @@ bool torture_bind_authcontext(struct torture_context *torture)
                         nt_errstr(status));
                goto done;
        }
+       if (!NT_STATUS_IS_OK(openpolicy.out.result)) {
+               torture_comment(torture, "dcerpc_lsa_OpenPolicy2 failed: %s\n",
+                        nt_errstr(openpolicy.out.result));
+               goto done;
+       }
 
        close_handle.in.handle = &handle;
        close_handle.out.handle = &handle;
@@ -138,6 +141,11 @@ bool torture_bind_authcontext(struct torture_context *torture)
                         nt_errstr(status));
                goto done;
        }
+       if (!NT_STATUS_IS_OK(close_handle.out.result)) {
+               torture_comment(torture, "dcerpc_lsa_Close failed: %s\n",
+                        nt_errstr(close_handle.out.result));
+               goto done;
+       }
 
        session2 = smbcli_session_init(cli->transport, mem_ctx, false, session_options);
        if (session2 == NULL) {
@@ -214,8 +222,7 @@ static bool bindtest(struct torture_context *tctx,
        }
 
        lsa_pipe = dcerpc_pipe_init(mem_ctx,
-                                   cli->transport->socket->event.ctx,
-                                   lp_iconv_convenience(tctx->lp_ctx));
+                                   cli->transport->socket->event.ctx); 
        if (lsa_pipe == NULL) {
                torture_comment(tctx, "dcerpc_pipe_init failed\n");
                goto done;
@@ -251,6 +258,11 @@ static bool bindtest(struct torture_context *tctx,
                         nt_errstr(status));
                goto done;
        }
+       if (!NT_STATUS_IS_OK(openpolicy.out.result)) {
+               torture_comment(tctx, "dcerpc_lsa_OpenPolicy2 failed: %s\n",
+                        nt_errstr(openpolicy.out.result));
+               goto done;
+       }
 
        query.in.handle = &handle;
        query.in.level = LSA_POLICY_INFO_DOMAIN;
@@ -262,6 +274,11 @@ static bool bindtest(struct torture_context *tctx,
                         nt_errstr(status));
                goto done;
        }
+       if (!NT_STATUS_IS_OK(query.out.result)) {
+               torture_comment(tctx, "dcerpc_lsa_QueryInfoPolicy failed: %s\n",
+                        nt_errstr(query.out.result));
+               goto done;
+       }
 
        close_handle.in.handle = &handle;
        close_handle.out.handle = &handle;
@@ -272,6 +289,12 @@ static bool bindtest(struct torture_context *tctx,
                         nt_errstr(status));
                goto done;
        }
+       if (!NT_STATUS_IS_OK(close_handle.out.result)) {
+               torture_comment(tctx, "dcerpc_lsa_Close failed: %s\n",
+                        nt_errstr(close_handle.out.result));
+               goto done;
+       }
+
 
        ret = true;
  done:
@@ -310,7 +333,6 @@ static bool torture_bind_samba3(struct torture_context *torture)
                                        cmdline_credentials,
                                        lp_resolve_context(torture->lp_ctx),
                                        torture->ev, &options, &session_options,
-                                       lp_iconv_convenience(torture->lp_ctx),
                                        lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                torture_comment(torture, "smbcli_full_connection failed: %s\n",
@@ -371,8 +393,7 @@ static bool get_usr_handle(struct torture_context *tctx,
        uint32_t user_rid,access_granted;
 
        samr_pipe = dcerpc_pipe_init(mem_ctx,
-                                    cli->transport->socket->event.ctx,
-                                    lp_iconv_convenience(tctx->lp_ctx));
+                                    cli->transport->socket->event.ctx);
        torture_assert(tctx, samr_pipe, "dcerpc_pipe_init failed");
 
        samr_handle = samr_pipe->binding_handle;
@@ -402,6 +423,8 @@ static bool get_usr_handle(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx,
                dcerpc_samr_Connect2_r(samr_handle, mem_ctx, &conn),
                "samr_Connect2 failed");
+       torture_assert_ntstatus_ok(tctx, conn.out.result,
+               "samr_Connect2 failed");
 
        enumdom.in.connect_handle = &conn_handle;
        enumdom.in.resume_handle = &resume_handle;
@@ -413,6 +436,8 @@ static bool get_usr_handle(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx,
                dcerpc_samr_EnumDomains_r(samr_handle, mem_ctx, &enumdom),
                "samr_EnumDomains failed");
+       torture_assert_ntstatus_ok(tctx, enumdom.out.result,
+               "samr_EnumDomains failed");
 
        torture_assert_int_equal(tctx, *enumdom.out.num_entries, 2,
                "samr_EnumDomains returned unexpected num_entries");
@@ -429,6 +454,8 @@ static bool get_usr_handle(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx,
                dcerpc_samr_LookupDomain_r(samr_handle, mem_ctx, &l),
                "samr_LookupDomain failed");
+       torture_assert_ntstatus_ok(tctx, l.out.result,
+               "samr_LookupDomain failed");
 
        o.in.connect_handle = &conn_handle;
        o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -438,6 +465,8 @@ static bool get_usr_handle(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx,
                dcerpc_samr_OpenDomain_r(samr_handle, mem_ctx, &o),
                "samr_OpenDomain failed");
+       torture_assert_ntstatus_ok(tctx, o.out.result,
+               "samr_OpenDomain failed");
 
        c.in.domain_handle = &domain_handle;
        user_name.string = username;
@@ -449,9 +478,11 @@ static bool get_usr_handle(struct torture_context *tctx,
        c.out.access_granted = &access_granted;
        c.out.rid = &user_rid;
 
-       status = dcerpc_samr_CreateUser2_r(samr_handle, mem_ctx, &c);
+       torture_assert_ntstatus_ok(tctx,
+               dcerpc_samr_CreateUser2_r(samr_handle, mem_ctx, &c),
+               "samr_CreateUser2 failed");
 
-       if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
+       if (NT_STATUS_EQUAL(c.out.result, NT_STATUS_USER_EXISTS)) {
                struct samr_LookupNames ln;
                struct samr_OpenUser ou;
                struct samr_Ids rids, types;
@@ -465,6 +496,8 @@ static bool get_usr_handle(struct torture_context *tctx,
                torture_assert_ntstatus_ok(tctx,
                        dcerpc_samr_LookupNames_r(samr_handle, mem_ctx, &ln),
                        "samr_LookupNames failed");
+               torture_assert_ntstatus_ok(tctx, ln.out.result,
+                       "samr_LookupNames failed");
 
                ou.in.domain_handle = &domain_handle;
                ou.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -475,6 +508,8 @@ static bool get_usr_handle(struct torture_context *tctx,
                        dcerpc_samr_OpenUser_r(samr_handle, mem_ctx, &ou),
                        "samr_OpenUser failed");
                status = ou.out.result;
+       } else {
+               status = c.out.result;
        }
 
        torture_assert_ntstatus_ok(tctx, status,
@@ -557,6 +592,11 @@ static bool create_user(struct torture_context *tctx,
                                 nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(sui2.out.result)) {
+                       torture_comment(tctx, "samr_SetUserInfo(23) failed: %s\n",
+                                nt_errstr(sui2.out.result));
+                       goto done;
+               }
 
                u_info.info16.acct_flags = ACB_NORMAL;
                sui.in.user_handle = wks_handle;
@@ -564,7 +604,7 @@ static bool create_user(struct torture_context *tctx,
                sui.in.level = 16;
 
                status = dcerpc_samr_SetUserInfo_r(samr_handle, tmp_ctx, &sui);
-               if (!NT_STATUS_IS_OK(status)) {
+               if (!NT_STATUS_IS_OK(status) || !NT_STATUS_IS_OK(sui.out.result)) {
                        torture_comment(tctx, "samr_SetUserInfo(16) failed\n");
                        goto done;
                }
@@ -574,7 +614,7 @@ static bool create_user(struct torture_context *tctx,
                qui.out.info = &info;
 
                status = dcerpc_samr_QueryUserInfo_r(samr_handle, tmp_ctx, &qui);
-               if (!NT_STATUS_IS_OK(status)) {
+               if (!NT_STATUS_IS_OK(status) || !NT_STATUS_IS_OK(qui.out.result)) {
                        torture_comment(tctx, "samr_QueryUserInfo(21) failed\n");
                        goto done;
                }
@@ -592,7 +632,7 @@ static bool create_user(struct torture_context *tctx,
                sui.in.level = 21;
 
                status = dcerpc_samr_SetUserInfo_r(samr_handle, tmp_ctx, &sui);
-               if (!NT_STATUS_IS_OK(status)) {
+               if (!NT_STATUS_IS_OK(status) || !NT_STATUS_IS_OK(sui.out.result)) {
                        torture_comment(tctx, "samr_SetUserInfo(21) failed\n");
                        goto done;
                }
@@ -650,6 +690,11 @@ static bool delete_user(struct torture_context *tctx,
                        torture_comment(tctx, "samr_DeleteUser failed %s\n", nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(d.out.result)) {
+                       torture_comment(tctx, "samr_DeleteUser failed %s\n", nt_errstr(d.out.result));
+                       goto done;
+               }
+
        }
 
        ret = true;
@@ -710,6 +755,12 @@ static bool join3(struct torture_context *tctx,
                                  nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(q.out.result)) {
+                       torture_warning(tctx, "QueryUserInfo failed: %s\n",
+                                 nt_errstr(q.out.result));
+                       goto done;
+               }
+
 
                last_password_change = info->info21.last_password_change;
        }
@@ -769,6 +820,11 @@ static bool join3(struct torture_context *tctx,
                                 nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(sui2.out.result)) {
+                       torture_comment(tctx, "samr_SetUserInfo2(25) failed: %s\n",
+                                nt_errstr(sui2.out.result));
+                       goto done;
+               }
        } else {
                struct samr_SetUserInfo2 sui2;
                struct samr_SetUserInfo sui;
@@ -798,6 +854,11 @@ static bool join3(struct torture_context *tctx,
                                 nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(sui2.out.result)) {
+                       torture_comment(tctx, "samr_SetUserInfo(24) failed: %s\n",
+                                nt_errstr(sui2.out.result));
+                       goto done;
+               }
 
                u_info.info16.acct_flags = ACB_WSTRUST;
                sui.in.user_handle = wks_handle;
@@ -805,7 +866,7 @@ static bool join3(struct torture_context *tctx,
                sui.in.level = 16;
 
                status = dcerpc_samr_SetUserInfo_r(samr_handle, mem_ctx, &sui);
-               if (!NT_STATUS_IS_OK(status)) {
+               if (!NT_STATUS_IS_OK(status) || !NT_STATUS_IS_OK(sui.out.result)) {
                        torture_comment(tctx, "samr_SetUserInfo(16) failed\n");
                        goto done;
                }
@@ -825,6 +886,11 @@ static bool join3(struct torture_context *tctx,
                                  nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(q.out.result)) {
+                       torture_warning(tctx, "QueryUserInfo failed: %s\n",
+                                 nt_errstr(q.out.result));
+                       goto done;
+               }
 
                if (use_level25) {
                        if (last_password_change
@@ -882,8 +948,7 @@ static bool auth2(struct torture_context *tctx,
        }
 
        net_pipe = dcerpc_pipe_init(mem_ctx,
-                                   cli->transport->socket->event.ctx,
-                                   lp_iconv_convenience(tctx->lp_ctx));
+                                   cli->transport->socket->event.ctx);
        if (net_pipe == NULL) {
                torture_comment(tctx, "dcerpc_pipe_init failed\n");
                goto done;
@@ -922,6 +987,11 @@ static bool auth2(struct torture_context *tctx,
                         nt_errstr(status));
                goto done;
        }
+       if (!NT_STATUS_IS_OK(r.out.result)) {
+               torture_comment(tctx, "netr_ServerReqChallenge failed: %s\n",
+                        nt_errstr(r.out.result));
+               goto done;
+       }
 
        negotiate_flags = NETLOGON_NEG_AUTH2_FLAGS;
        E_md4hash(cli_credentials_get_password(wks_cred), mach_pw.hash);
@@ -950,6 +1020,11 @@ static bool auth2(struct torture_context *tctx,
                         nt_errstr(status));
                goto done;
        }
+       if (!NT_STATUS_IS_OK(a.out.result)) {
+               torture_comment(tctx, "netr_ServerServerAuthenticate2 failed: %s\n",
+                        nt_errstr(a.out.result));
+               goto done;
+       }
 
        if (!netlogon_creds_client_check(creds_state, a.out.return_credentials)) {
                torture_comment(tctx, "creds_client_check failed\n");
@@ -989,8 +1064,7 @@ static bool schan(struct torture_context *tctx,
        }
 
        net_pipe = dcerpc_pipe_init(mem_ctx,
-                                   cli->transport->socket->event.ctx,
-                                   lp_iconv_convenience(tctx->lp_ctx));
+                                   cli->transport->socket->event.ctx);
        if (net_pipe == NULL) {
                torture_comment(tctx, "dcerpc_pipe_init failed\n");
                goto done;
@@ -1099,6 +1173,11 @@ static bool schan(struct torture_context *tctx,
                                 nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(r.out.result)) {
+                       torture_comment(tctx, "netr_LogonSamLogon failed: %s\n",
+                                nt_errstr(r.out.result));
+                       goto done;
+               }
 
                if ((r.out.return_authenticator == NULL) ||
                    (!netlogon_creds_client_check(creds_state,
@@ -1131,6 +1210,11 @@ static bool schan(struct torture_context *tctx,
                                 nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(r.out.result)) {
+                       torture_comment(tctx, "netr_LogonSamLogon failed: %s\n",
+                                nt_errstr(r.out.result));
+                       goto done;
+               }
 
                if ((r.out.return_authenticator == NULL) ||
                    (!netlogon_creds_client_check(creds_state,
@@ -1168,6 +1252,10 @@ static bool schan(struct torture_context *tctx,
                        torture_comment(tctx, "ServerPasswordSet - %s\n", nt_errstr(status));
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(s.out.result)) {
+                       torture_comment(tctx, "ServerPasswordSet - %s\n", nt_errstr(s.out.result));
+                       goto done;
+               }
 
                if (!netlogon_creds_client_check(creds_state,
                                                 &s.out.return_authenticator->cred)) {
@@ -1247,7 +1335,6 @@ static bool torture_netlogon_samba3(struct torture_context *torture)
                                        anon_creds,
                                        lp_resolve_context(torture->lp_ctx),
                                        torture->ev, &options, &session_options,
-                                       lp_iconv_convenience(torture->lp_ctx),
                                        lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                torture_comment(torture, "smbcli_full_connection failed: %s\n",
@@ -1337,7 +1424,6 @@ static bool test_join3(struct torture_context *tctx,
                                        "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));
        torture_assert_ntstatus_ok(tctx, status,
                "smbcli_full_connection failed");
@@ -1446,8 +1532,7 @@ static NTSTATUS pipe_bind_smb(struct torture_context *tctx,
        NTSTATUS status;
 
        if (!(result = dcerpc_pipe_init(
-                     mem_ctx, tree->session->transport->socket->event.ctx,
-                     lp_iconv_convenience(tctx->lp_ctx)))) {
+                     mem_ctx, tree->session->transport->socket->event.ctx))) {
                return NT_STATUS_NO_MEMORY;
        }
 
@@ -1522,6 +1607,11 @@ static struct dom_sid *name2sid(struct torture_context *tctx,
                talloc_free(tmp_ctx);
                return NULL;
        }
+       if (!NT_STATUS_IS_OK(r.out.result)) {
+               torture_comment(tctx, "OpenPolicy2 failed - %s\n", nt_errstr(r.out.result));
+               talloc_free(tmp_ctx);
+               return NULL;
+       }
 
        sids.count = 0;
        sids.sids = NULL;
@@ -1545,6 +1635,12 @@ static struct dom_sid *name2sid(struct torture_context *tctx,
                talloc_free(tmp_ctx);
                return NULL;
        }
+       if (!NT_STATUS_IS_OK(l.out.result)) {
+               torture_comment(tctx, "LookupNames of %s failed - %s\n", lsa_name.string,
+                      nt_errstr(l.out.result));
+               talloc_free(tmp_ctx);
+               return NULL;
+       }
 
        result = dom_sid_add_rid(mem_ctx, domains->domains[0].sid,
                                 l.out.sids->sids[0].rid);
@@ -1558,6 +1654,11 @@ static struct dom_sid *name2sid(struct torture_context *tctx,
                talloc_free(tmp_ctx);
                return NULL;
        }
+       if (!NT_STATUS_IS_OK(c.out.result)) {
+               torture_comment(tctx, "dcerpc_lsa_Close failed - %s\n", nt_errstr(c.out.result));
+               talloc_free(tmp_ctx);
+               return NULL;
+       }
 
        talloc_free(tmp_ctx);
        return result;
@@ -1603,6 +1704,12 @@ static struct dom_sid *whoami(struct torture_context *tctx,
                talloc_free(lsa);
                return NULL;
        }
+       if (!NT_STATUS_IS_OK(r.out.result)) {
+               torture_warning(tctx, "GetUserName failed - %s\n",
+                      nt_errstr(r.out.result));
+               talloc_free(lsa);
+               return NULL;
+       }
 
        result = name2sid(tctx, mem_ctx, lsa, account_name_p->string,
                          authority_name_p->string);
@@ -1692,10 +1799,8 @@ static bool torture_samba3_rpc_getusername(struct torture_context *torture)
                mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
                lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, lp_socket_options(torture->lp_ctx), cmdline_credentials,
-               lp_resolve_context(torture->lp_ctx),
-               torture->ev, &options, &session_options,
-               lp_iconv_convenience(torture->lp_ctx),
-               lp_gensec_settings(torture, torture->lp_ctx));
+               lp_resolve_context(torture->lp_ctx), torture->ev, &options,
+               &session_options, lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                torture_warning(torture, "smbcli_full_connection failed: %s\n",
                         nt_errstr(status));
@@ -1722,7 +1827,6 @@ static bool torture_samba3_rpc_getusername(struct torture_context *torture)
                lp_socket_options(torture->lp_ctx), anon_creds,
                lp_resolve_context(torture->lp_ctx),
                torture->ev, &options, &session_options,
-               lp_iconv_convenience(torture->lp_ctx),
                lp_gensec_settings(torture, torture->lp_ctx));
        if (!NT_STATUS_IS_OK(status)) {
                torture_warning(torture, "anon smbcli_full_connection failed: %s\n",
@@ -1853,7 +1957,7 @@ static bool test_NetShareGetInfo(struct torture_context *tctx,
        for (i=0;i<ARRAY_SIZE(levels);i++) {
                r.in.level = levels[i];
 
-               torture_comment(tctx, "testing NetShareGetInfo level %u on share '%s'\n",
+               torture_comment(tctx, "Testing NetShareGetInfo level %u on share '%s'\n",
                       r.in.level, r.in.share_name);
 
                status = dcerpc_srvsvc_NetShareGetInfo_r(b, tctx, &r);
@@ -1949,7 +2053,7 @@ static bool test_NetShareEnum(struct torture_context *tctx,
                        break;
                }
 
-               torture_comment(tctx, "testing NetShareEnum level %u\n", info_ctr.level);
+               torture_comment(tctx, "Testing NetShareEnum level %u\n", info_ctr.level);
 
                status = dcerpc_srvsvc_NetShareEnum_r(b, tctx, &r);
                if (!NT_STATUS_IS_OK(status)) {
@@ -2037,8 +2141,7 @@ static bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
        }
 
        if (!(net_pipe = dcerpc_pipe_init(
-                     mem_ctx, cli->transport->socket->event.ctx,
-                     lp_iconv_convenience(torture->lp_ctx)))) {
+                     mem_ctx, cli->transport->socket->event.ctx))) {
                torture_comment(torture, "dcerpc_pipe_init failed\n");
                goto done;
        }
@@ -2076,6 +2179,11 @@ static bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
                         nt_errstr(status));
                goto done;
        }
+       if (!NT_STATUS_IS_OK(r.out.result)) {
+               torture_comment(torture, "netr_ServerReqChallenge failed: %s\n",
+                        nt_errstr(r.out.result));
+               goto done;
+       }
 
        negotiate_flags = NETLOGON_NEG_AUTH2_FLAGS;
        E_md4hash("foobar", mach_pw.hash);
@@ -2100,11 +2208,13 @@ static bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
 
 
        status = dcerpc_netr_ServerAuthenticate2_r(net_handle, mem_ctx, &a);
-
-       if (!NT_STATUS_EQUAL(status, NT_STATUS_NO_TRUST_SAM_ACCOUNT)) {
+       if (!NT_STATUS_IS_OK(status)) {
+               goto done;
+       }
+       if (!NT_STATUS_EQUAL(a.out.result, NT_STATUS_NO_TRUST_SAM_ACCOUNT)) {
                torture_comment(torture, "dcerpc_netr_ServerAuthenticate2 returned %s, "
                         "expected NT_STATUS_NO_TRUST_SAM_ACCOUNT\n",
-                        nt_errstr(status));
+                        nt_errstr(a.out.result));
                goto done;
        }
 
@@ -2166,6 +2276,12 @@ static struct security_descriptor *get_sharesec(struct torture_context *tctx,
                talloc_free(tmp_ctx);
                return NULL;
        }
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               torture_comment(tctx, "srvsvc_NetShareGetInfo failed: %s\n",
+                        win_errstr(r.out.result));
+               talloc_free(tmp_ctx);
+               return NULL;
+       }
 
        result = talloc_steal(mem_ctx, info.info502->sd_buf.sd);
        talloc_free(tmp_ctx);
@@ -2227,7 +2343,11 @@ static NTSTATUS set_sharesec(struct torture_context *tctx,
                torture_comment(tctx, "srvsvc_NetShareSetInfo failed: %s\n",
                         nt_errstr(status));
        }
-
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               torture_comment(tctx, "srvsvc_NetShareSetInfo failed: %s\n",
+                       win_errstr(r.out.result));
+               status = werror_to_ntstatus(r.out.result);
+       }
        talloc_free(tmp_ctx);
        return status;
 }
@@ -2395,6 +2515,8 @@ static bool torture_samba3_rpc_lsa(struct torture_context *torture)
                torture_assert_ntstatus_ok(torture,
                        dcerpc_lsa_OpenPolicy2_r(b, torture, &o),
                        "dcerpc_lsa_OpenPolicy2 failed");
+               torture_assert_ntstatus_ok(torture, o.out.result,
+                       "dcerpc_lsa_OpenPolicy2 failed");
        }
 
        {
@@ -2411,6 +2533,8 @@ static bool torture_samba3_rpc_lsa(struct torture_context *torture)
                        torture_assert_ntstatus_ok(torture,
                                dcerpc_lsa_QueryInfoPolicy_r(b, torture, &r),
                                talloc_asprintf(torture, "dcerpc_lsa_QueryInfoPolicy level %d failed", levels[i]));
+                       torture_assert_ntstatus_ok(torture, r.out.result,
+                               talloc_asprintf(torture, "dcerpc_lsa_QueryInfoPolicy level %d failed", levels[i]));
                }
        }
 
@@ -2418,7 +2542,6 @@ static bool torture_samba3_rpc_lsa(struct torture_context *torture)
 }
 
 static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
-                              struct smb_iconv_convenience *iconv_convenience,
                               char **name)
 {
        struct rap_WserverGetInfo r;
@@ -2428,7 +2551,7 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
        r.in.level = 0;
        r.in.bufsize = 0xffff;
 
-       status = smbcli_rap_netservergetinfo(tree, iconv_convenience, mem_ctx, &r);
+       status = smbcli_rap_netservergetinfo(tree, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -2454,7 +2577,7 @@ static bool rap_get_servername(struct torture_context *tctx,
                "IPC$ connection failed");
 
        torture_assert_ntstatus_ok(tctx,
-               get_servername(tctx, cli->tree, lp_iconv_convenience(tctx->lp_ctx), servername),
+               get_servername(tctx, cli->tree, servername),
                "get_servername failed");
 
        talloc_free(cli);
@@ -2490,6 +2613,8 @@ static bool find_printers(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx,
                dcerpc_srvsvc_NetShareEnum_r(b, tctx, &r),
                "NetShareEnum level 1 failed");
+       torture_assert_werr_ok(tctx, r.out.result,
+               "NetShareEnum level 1 failed");
 
        *printers = NULL;
        *num_printers = 0;
@@ -2766,6 +2891,8 @@ static bool torture_samba3_rpc_wkssvc(struct torture_context *torture)
                torture_assert_ntstatus_ok(torture,
                        dcerpc_wkssvc_NetWkstaGetInfo_r(b, torture, &r),
                        "dcerpc_wkssvc_NetWksGetInfo failed");
+               torture_assert_werr_ok(torture, r.out.result,
+                       "dcerpc_wkssvc_NetWksGetInfo failed");
 
                torture_assert_str_equal(torture, servername, r.out.info->info100->server_name,
                        "servername RAP / DCERPC inconsistency");
@@ -2903,6 +3030,8 @@ static bool test_Open3(struct torture_context *tctx,
        torture_assert_ntstatus_ok(tctx,
                open_fn(b, tctx, &r),
                talloc_asprintf(tctx, "%s failed", name));
+       torture_assert_werr_ok(tctx, r.out.result,
+               talloc_asprintf(tctx, "%s failed", name));
 
        enumkeys(tctx, b, &handle, 4);
 
@@ -3097,7 +3226,7 @@ static bool torture_samba3_setconfig(struct torture_context *tctx,
                "OpenKey failed");
 
        torture_assert(tctx,
-               reg_string_to_val(tctx, lp_iconv_convenience(tctx->lp_ctx), "REG_SZ", value, &type, &val),
+               reg_string_to_val(tctx, "REG_SZ", value, &type, &val),
                "reg_string_to_val failed");
 
        s.in.handle = &key_handle;
@@ -3181,6 +3310,8 @@ bool torture_samba3_getaliasmembership_0(struct torture_context *torture)
        torture_assert_ntstatus_ok(torture,
                dcerpc_samr_Connect2_r(b, torture, &c),
                "");
+       torture_assert_ntstatus_ok(torture, c.out.result,
+               "");
        dom_sid_parse("S-1-5-32", &sid);
        o.in.connect_handle = &samr;
        o.in.access_mask = SAMR_DOMAIN_ACCESS_LOOKUP_ALIAS;
@@ -3189,6 +3320,8 @@ bool torture_samba3_getaliasmembership_0(struct torture_context *torture)
        torture_assert_ntstatus_ok(torture,
                dcerpc_samr_OpenDomain_r(b, torture, &o),
                "");
+       torture_assert_ntstatus_ok(torture, o.out.result,
+               "");
        dom_sid_parse("S-1-2-3-4-5", &sid);
        ptr.sid = &sid;
        sids.num_sids = 1;
@@ -3199,6 +3332,8 @@ bool torture_samba3_getaliasmembership_0(struct torture_context *torture)
        torture_assert_ntstatus_ok(torture,
                dcerpc_samr_GetAliasMembership_r(b, torture, &g),
                "");
+       torture_assert_ntstatus_ok(torture, g.out.result,
+               "");
        if (rids.ids == NULL) {
                /* This is the piece to test here */
                torture_fail(torture,