summaryrefslogtreecommitdiffstats
path: root/source4/torture/rpc/wkssvc.c
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-11-29 23:09:37 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:46:53 +0100
commitb32cbeafb2f9815cad30942bafa72895ff67b490 (patch)
treedd8afb858d62414aa6b39075f0a22bb94882f433 /source4/torture/rpc/wkssvc.c
parent91da59fe0f4a2434ab35470651d38f2e530be971 (diff)
downloadsamba-b32cbeafb2f9815cad30942bafa72895ff67b490.tar.gz
samba-b32cbeafb2f9815cad30942bafa72895ff67b490.tar.xz
samba-b32cbeafb2f9815cad30942bafa72895ff67b490.zip
r26211: Add very basic test_NetrJoinDomain2() test which can join xp workstations into
an AD domain. Guenther (This used to be commit 3fd5f3628cb015f61455b4ad87bf8adb8d2392b8)
Diffstat (limited to 'source4/torture/rpc/wkssvc.c')
-rw-r--r--source4/torture/rpc/wkssvc.c100
1 files changed, 99 insertions, 1 deletions
diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c
index 861c1051c6..5e0be1f5b5 100644
--- a/source4/torture/rpc/wkssvc.c
+++ b/source4/torture/rpc/wkssvc.c
@@ -1006,6 +1006,38 @@ static bool test_NetrGetJoinInformation(struct torture_context *tctx,
return true;
}
+static bool test_GetJoinInformation(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ enum wkssvc_NetJoinStatus *join_status_p,
+ const char **name)
+{
+ NTSTATUS status;
+ struct wkssvc_NetrGetJoinInformation r;
+ enum wkssvc_NetJoinStatus join_status;
+ const char *name_buffer = "";
+
+ r.in.server_name = dcerpc_server_name(p);
+ r.in.name_buffer = r.out.name_buffer = &name_buffer;
+ r.out.name_type = &join_status;
+
+ status = dcerpc_wkssvc_NetrGetJoinInformation(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status,
+ "NetrGetJoinInformation failed");
+ torture_assert_werr_ok(tctx, r.out.result,
+ "NetrGetJoinInformation failed");
+
+ if (join_status_p) {
+ *join_status_p = join_status;
+ }
+
+ if (*name) {
+ *name = talloc_strdup(tctx, name_buffer);
+ }
+
+ return true;
+
+}
+
static bool test_NetrGetJoinableOus(struct torture_context *tctx,
struct dcerpc_pipe *p)
{
@@ -1086,7 +1118,6 @@ static bool test_NetrUnjoinDomain(struct torture_context *tctx,
return true;
}
-
static bool test_NetrJoinDomain(struct torture_context *tctx,
struct dcerpc_pipe *p)
{
@@ -1160,6 +1191,69 @@ static bool encode_wkssvc_join_password_buffer(struct torture_context *tctx,
return true;
}
+static bool test_NetrJoinDomain2(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ NTSTATUS status;
+ struct wkssvc_NetrJoinDomain2 r;
+ const char *domain_admin_account = NULL;
+ const char *domain_admin_password = NULL;
+ struct wkssvc_PasswordBuffer pwd_buf;
+ enum wkssvc_NetJoinStatus join_status;
+ const char *join_name = NULL;
+ WERROR expected_err = WERR_OK;
+
+ /* FIXME: this test assumes to join workstations / servers and does not
+ * handle DCs (WERR_SETUP_DOMAIN_CONTROLLER) */
+
+ if (!test_GetJoinInformation(tctx, p, &join_status, &join_name))
+ {
+ return false;
+ }
+
+ switch (join_status) {
+ case NetSetupDomainName:
+ expected_err = WERR_SETUP_ALREADY_JOINED;
+ break;
+ case NetSetupUnknownStatus:
+ case NetSetupUnjoined:
+ case NetSetupWorkgroupName:
+ break;
+ }
+
+ domain_admin_account = lp_parm_string(global_loadparm, NULL,
+ "torture",
+ "domain_admin_account");
+
+ domain_admin_password = lp_parm_string(global_loadparm, NULL,
+ "torture",
+ "domain_admin_password");
+
+ if (!encode_wkssvc_join_password_buffer(tctx, p,
+ domain_admin_password,
+ &pwd_buf))
+ {
+ return false;
+ }
+
+ r.in.server_name = dcerpc_server_name(p);
+ r.in.domain_name = lp_realm(global_loadparm);
+ r.in.account_ou = NULL;
+ r.in.admin_account = domain_admin_account;
+ r.in.encrypted_password = &pwd_buf;
+ r.in.join_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE |
+ WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE;
+
+ torture_comment(tctx, "testing NetrJoinDomain2 (assuming non-DC)\n");
+
+ status = dcerpc_wkssvc_NetrJoinDomain2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status,
+ "NetrJoinDomain2 failed");
+ torture_assert_werr_equal(tctx, r.out.result, expected_err,
+ "NetrJoinDomain2 failed");
+ return true;
+}
+
struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite;
@@ -1218,6 +1312,10 @@ struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx)
torture_rpc_tcase_add_test(tcase, "NetrEnumerateComputerNames",
test_NetrEnumerateComputerNames);
+ test = torture_rpc_tcase_add_test(tcase, "NetrJoinDomain2",
+ test_NetrJoinDomain2);
+ test->dangerous = true;
+
torture_rpc_tcase_add_test(tcase, "NetrJoinDomain",
test_NetrJoinDomain);
test->dangerous = true;