s4:torture/rpc: make use of dcerpc_binding_set_flags()
[samba.git] / source4 / torture / rpc / dsgetinfo.c
index acf93e878514f26bf2c79a756c535f767de2f444..b622f60f92b8f260b0faa79590f0bf11334a3d1d 100644 (file)
@@ -29,8 +29,7 @@
 #include "auth/gensec/gensec.h"
 #include "param/param.h"
 #include "dsdb/samdb/samdb.h"
-#include "lib/ldb_wrap.h"
-#include "torture/rpc/rpc.h"
+#include "torture/rpc/torture_rpc.h"
 #include "torture/drs/proto.h"
 
 
@@ -88,6 +87,9 @@ static const char *torture_get_ldap_base_dn(struct torture_context *tctx, struct
                return NULL;
        }
 
+       ldb_set_modules_dir(ldb,
+                           modules_path(ldb, "ldb"));
+
        ret = ldb_connect(ldb, ldap_url, 0, NULL);
        if (ret != LDB_SUCCESS) {
                torture_comment(tctx, "Failed to make LDB connection to target");
@@ -125,7 +127,11 @@ static struct DsGetinfoTest *test_create_context(struct torture_context *tctx)
                printf("Bad binding string %s\n", binding);
                return NULL;
        }
-       ctx->drsuapi_binding->flags |= DCERPC_SIGN | DCERPC_SEAL;
+       status = dcerpc_binding_set_flags(ctx->drsuapi_binding, DCERPC_SIGN | DCERPC_SEAL, 0);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("dcerpc_binding_set_flags - %s\n", nt_errstr(status));
+               return NULL;
+       }
 
        /* ctx->admin ...*/
        ctx->admin.credentials                          = cmdline_credentials;
@@ -170,9 +176,6 @@ static bool _test_DsBind(struct torture_context *tctx,
        status = dcerpc_drsuapi_DsBind_r(b->drs_handle, ctx, &b->req);
        if (!NT_STATUS_IS_OK(status)) {
                const char *errstr = nt_errstr(status);
-               if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
-                       errstr = dcerpc_errstr(ctx, b->drs_pipe->last_fault_code);
-               }
                printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr);
                ret = false;
        } else if (!W_ERROR_IS_OK(b->req.out.result)) {
@@ -345,7 +348,7 @@ static bool test_getinfo(struct torture_context *tctx,
                r.out.info_type         = &info_type;
 
                status = dcerpc_drsuapi_DsReplicaGetInfo_r(b, tctx, &r);
-               if (!NT_STATUS_IS_OK(status) && p->last_fault_code == DCERPC_FAULT_INVALID_TAG) {
+               if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
                        torture_comment(tctx,
                                        "DsReplicaGetInfo level %d and/or infotype %d not supported by server\n",
                                        array[i].level, array[i].infotype);
@@ -419,14 +422,12 @@ static bool torture_dsgetinfo_tcase_teardown(struct torture_context *tctx, void
 void torture_drs_rpc_dsgetinfo_tcase(struct torture_suite *suite)
 {
        typedef bool (*run_func) (struct torture_context *test, void *tcase_data);
-
-       struct torture_test *test;
-       struct torture_tcase *tcase = torture_suite_add_tcase(suite, "DSGETINFO");
+       struct torture_tcase *tcase = torture_suite_add_tcase(suite, "dsgetinfo");
 
        torture_tcase_set_fixture(tcase,
                                  torture_dsgetinfo_tcase_setup,
                                  torture_dsgetinfo_tcase_teardown);
 
-       test = torture_tcase_add_simple_test(tcase, "DsGetReplicaInfo", (run_func)test_getinfo);
+       torture_tcase_add_simple_test(tcase, "DsGetReplicaInfo", (run_func)test_getinfo);
 }