2 Unix SMB/CIFS implementation.
4 libnet_BecomeDC() tests
6 Copyright (C) Stefan (metze) Metzmacher 2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "lib/cmdline/popt_common.h"
25 #include "torture/torture.h"
26 #include "torture/rpc/rpc.h"
27 #include "libnet/libnet.h"
28 #include "lib/events/events.h"
30 #define TORTURE_NETBIOS_NAME "smbtorturedc"
32 static NTSTATUS test_become_dc_check_options(void *private_data,
33 const struct libnet_BecomeDC_CheckOptions *o)
35 DEBUG(0,("Become DC of Domain[%s]/[%s]\n",
36 o->domain->netbios_name, o->domain->dns_name));
38 DEBUG(0,("Promotion Partner is Server[%s] from Site[%s]\n",
39 o->source_dsa->dns_name, o->source_dsa->site_name));
41 DEBUG(0,("Options:crossRef behavior_version[%u]\n"
42 "\tschema object_version[%u]\n"
43 "\tdomain behavior_version[%u]\n"
44 "\tdomain w2k3_update_revision[%u]\n",
45 o->forest->crossref_behavior_version,
46 o->forest->schema_object_version,
47 o->domain->behavior_version,
48 o->domain->w2k3_update_revision));
53 static NTSTATUS test_become_dc_prepare_db(void *private_data,
54 const struct libnet_BecomeDC_PrepareDB *p)
56 struct test_join *tj = talloc_get_type(private_data, struct test_join);
58 DEBUG(0,("New Server[%s] in Site[%s]\n",
59 p->dest_dsa->dns_name, p->dest_dsa->site_name));
61 DEBUG(0,("DSA Instance [%s]\n"
63 "\tinvocationId[%s]\n",
64 p->dest_dsa->ntds_dn_str,
65 GUID_string(tj, &p->dest_dsa->ntds_guid),
66 GUID_string(tj, &p->dest_dsa->invocation_id)));
68 DEBUG(0,("Schema Partition[%s]\n",
69 p->forest->schema_dn_str));
71 DEBUG(0,("Config Partition[%s]\n",
72 p->forest->config_dn_str));
74 DEBUG(0,("Domain Partition[%s]\n",
80 static NTSTATUS test_become_dc_store_chunk(void *private_data,
81 const struct libnet_BecomeDC_StoreChunk *c)
83 DEBUG(0,("Partition[%s]\n",
84 c->partition->nc.dn));
89 BOOL torture_net_become_dc(struct torture_context *torture)
93 struct libnet_context *ctx;
94 struct libnet_BecomeDC b;
95 struct libnet_UnbecomeDC u;
97 struct cli_credentials *machine_account;
99 /* Join domain as a member server. */
100 tj = torture_join_domain(TORTURE_NETBIOS_NAME,
104 DEBUG(0, ("%s failed to join domain as workstation\n",
105 TORTURE_NETBIOS_NAME));
109 ctx = libnet_context_init(event_context_init(torture));
110 ctx->cred = cmdline_credentials;
113 b.in.domain_dns_name = torture_join_dom_dns_name(tj);
114 b.in.domain_netbios_name = torture_join_dom_netbios_name(tj);
115 b.in.domain_sid = torture_join_sid(tj);
116 b.in.source_dsa_address = lp_parm_string(-1, "torture", "host");
117 b.in.dest_dsa_netbios_name = TORTURE_NETBIOS_NAME;
119 b.in.callbacks.private_data = tj;
120 b.in.callbacks.check_options = test_become_dc_check_options;
121 b.in.callbacks.prepare_db = test_become_dc_prepare_db;
122 b.in.callbacks.schema_chunk = test_become_dc_store_chunk;
123 b.in.callbacks.config_chunk = test_become_dc_store_chunk;
124 b.in.callbacks.domain_chunk = test_become_dc_store_chunk;
126 status = libnet_BecomeDC(ctx, ctx, &b);
127 if (!NT_STATUS_IS_OK(status)) {
128 printf("libnet_BecomeDC() failed - %s\n", nt_errstr(status));
133 u.in.domain_dns_name = torture_join_dom_dns_name(tj);
134 u.in.domain_netbios_name = torture_join_dom_netbios_name(tj);
135 u.in.source_dsa_address = lp_parm_string(-1, "torture", "host");
136 u.in.dest_dsa_netbios_name = TORTURE_NETBIOS_NAME;
138 status = libnet_UnbecomeDC(ctx, ctx, &u);
139 if (!NT_STATUS_IS_OK(status)) {
140 printf("libnet_UnbecomeDC() failed - %s\n", nt_errstr(status));
145 torture_leave_domain(tj);