2 Unix SMB/CIFS implementation.
4 libnet_BecomeDC() tests
6 Copyright (C) Stefan Metzmacher <metze@samba.org> 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 3 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, see <http://www.gnu.org/licenses/>.
23 #include "lib/cmdline/popt_common.h"
24 #include "torture/torture.h"
25 #include "torture/rpc/rpc.h"
26 #include "libnet/libnet.h"
27 #include "lib/events/events.h"
28 #include "dsdb/samdb/samdb.h"
29 #include "lib/util/dlinklist.h"
30 #include "lib/ldb/include/ldb.h"
31 #include "lib/ldb/include/ldb_errors.h"
32 #include "librpc/ndr/libndr.h"
33 #include "librpc/gen_ndr/ndr_drsuapi.h"
34 #include "librpc/gen_ndr/ndr_drsblobs.h"
35 #include "librpc/gen_ndr/ndr_misc.h"
36 #include "system/time.h"
37 #include "lib/ldb_wrap.h"
38 #include "auth/auth.h"
39 #include "param/param.h"
40 #include "torture/util.h"
41 #include "param/provision.h"
43 struct test_become_dc_state {
44 struct libnet_context *ctx;
45 struct torture_context *tctx;
46 const char *netbios_name;
48 struct cli_credentials *machine_account;
49 struct dsdb_schema *self_made_schema;
50 const struct dsdb_schema *schema;
52 struct ldb_context *ldb;
55 uint32_t object_count;
56 struct drsuapi_DsReplicaObjectListItemEx *first_object;
57 struct drsuapi_DsReplicaObjectListItemEx *last_object;
60 const char *targetdir;
62 struct loadparm_context *lp_ctx;
65 static NTSTATUS test_become_dc_prepare_db(void *private_data,
66 const struct libnet_BecomeDC_PrepareDB *p)
68 struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
69 struct provision_settings settings;
70 struct provision_result result;
73 settings.site_name = p->dest_dsa->site_name;
74 settings.root_dn_str = p->forest->root_dn_str;
75 settings.domain_dn_str = p->domain->dn_str;
76 settings.config_dn_str = p->forest->config_dn_str;
77 settings.schema_dn_str = p->forest->schema_dn_str;
78 settings.server_dn_str = torture_join_server_dn_str(s->tj);
79 settings.invocation_id = &p->dest_dsa->invocation_id;
80 settings.netbios_name = p->dest_dsa->netbios_name;
81 settings.host_ip = NULL;
82 settings.realm = torture_join_dom_dns_name(s->tj);
83 settings.domain = torture_join_dom_netbios_name(s->tj);
84 settings.ntds_dn_str = p->dest_dsa->ntds_dn_str;
85 settings.machine_password = cli_credentials_get_password(s->machine_account);
86 settings.targetdir = s->targetdir;
88 status = provision_bare(s, s->lp_ctx, &settings, &result);
90 s->ldb = result.samdb;
91 s->lp_ctx = result.lp_ctx;
97 static NTSTATUS test_become_dc_check_options(void *private_data,
98 const struct libnet_BecomeDC_CheckOptions *o)
100 struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
102 DEBUG(0,("Become DC [%s] of Domain[%s]/[%s]\n",
104 o->domain->netbios_name, o->domain->dns_name));
106 DEBUG(0,("Promotion Partner is Server[%s] from Site[%s]\n",
107 o->source_dsa->dns_name, o->source_dsa->site_name));
109 DEBUG(0,("Options:crossRef behavior_version[%u]\n"
110 "\tschema object_version[%u]\n"
111 "\tdomain behavior_version[%u]\n"
112 "\tdomain w2k3_update_revision[%u]\n",
113 o->forest->crossref_behavior_version,
114 o->forest->schema_object_version,
115 o->domain->behavior_version,
116 o->domain->w2k3_update_revision));
121 static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
122 const struct libnet_BecomeDC_StoreChunk *c)
125 const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
126 uint32_t total_object_count;
127 uint32_t object_count;
128 struct drsuapi_DsReplicaObjectListItemEx *first_object;
129 struct drsuapi_DsReplicaObjectListItemEx *cur;
130 uint32_t linked_attributes_count;
131 struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
132 const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
133 struct dsdb_extended_replicated_objects *objs;
134 struct repsFromTo1 *s_dsa;
136 struct ldb_message *msg;
137 struct ldb_val prefixMap_val;
138 struct ldb_message_element *prefixMap_el;
139 struct ldb_val schemaInfo_val;
145 DEBUG(0,("Analyze and apply schema objects\n"));
147 s_dsa = talloc_zero(s, struct repsFromTo1);
148 NT_STATUS_HAVE_NO_MEMORY(s_dsa);
149 s_dsa->other_info = talloc(s_dsa, struct repsFromTo1OtherInfo);
150 NT_STATUS_HAVE_NO_MEMORY(s_dsa->other_info);
152 switch (c->ctr_level) {
154 mapping_ctr = &c->ctr1->mapping_ctr;
155 total_object_count = c->ctr1->total_object_count;
156 object_count = s->schema_part.object_count;
157 first_object = s->schema_part.first_object;
158 linked_attributes_count = 0;
159 linked_attributes = NULL;
160 s_dsa->highwatermark = c->ctr1->new_highwatermark;
161 s_dsa->source_dsa_obj_guid = c->ctr1->source_dsa_guid;
162 s_dsa->source_dsa_invocation_id = c->ctr1->source_dsa_invocation_id;
163 uptodateness_vector = NULL; /* TODO: map it */
166 mapping_ctr = &c->ctr6->mapping_ctr;
167 total_object_count = c->ctr6->total_object_count;
168 object_count = s->schema_part.object_count;
169 first_object = s->schema_part.first_object;
170 linked_attributes_count = 0; /* TODO: ! */
171 linked_attributes = NULL; /* TODO: ! */;
172 s_dsa->highwatermark = c->ctr6->new_highwatermark;
173 s_dsa->source_dsa_obj_guid = c->ctr6->source_dsa_guid;
174 s_dsa->source_dsa_invocation_id = c->ctr6->source_dsa_invocation_id;
175 uptodateness_vector = c->ctr6->uptodateness_vector;
178 return NT_STATUS_INVALID_PARAMETER;
181 s_dsa->replica_flags = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
182 | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
183 | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS;
184 memset(s_dsa->schedule, 0x11, sizeof(s_dsa->schedule));
186 tmp_dns_name = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid);
187 NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
188 tmp_dns_name = talloc_asprintf_append_buffer(tmp_dns_name, "._msdcs.%s", c->forest->dns_name);
189 NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
190 s_dsa->other_info->dns_name = tmp_dns_name;
192 for (cur = first_object; cur; cur = cur->next_object) {
193 bool is_attr = false;
194 bool is_class = false;
196 for (i=0; i < cur->object.attribute_ctr.num_attributes; i++) {
197 struct drsuapi_DsReplicaAttribute *a;
199 const char *oid = NULL;
201 a = &cur->object.attribute_ctr.attributes[i];
202 status = dsdb_map_int2oid(s->self_made_schema, a->attid, s, &oid);
203 if (!W_ERROR_IS_OK(status)) {
204 return werror_to_ntstatus(status);
208 case DRSUAPI_ATTRIBUTE_objectClass:
209 for (j=0; j < a->value_ctr.num_values; j++) {
210 uint32_t val = 0xFFFFFFFF;
212 if (a->value_ctr.values[i].blob
213 && a->value_ctr.values[i].blob->length == 4) {
214 val = IVAL(a->value_ctr.values[i].blob->data,0);
217 if (val == DRSUAPI_OBJECTCLASS_attributeSchema) {
220 if (val == DRSUAPI_OBJECTCLASS_classSchema) {
232 struct dsdb_attribute *sa;
234 sa = talloc_zero(s->self_made_schema, struct dsdb_attribute);
235 NT_STATUS_HAVE_NO_MEMORY(sa);
237 status = dsdb_attribute_from_drsuapi(s->self_made_schema, &cur->object, s, sa);
238 if (!W_ERROR_IS_OK(status)) {
239 return werror_to_ntstatus(status);
242 DLIST_ADD_END(s->self_made_schema->attributes, sa, struct dsdb_attribute *);
246 struct dsdb_class *sc;
248 sc = talloc_zero(s->self_made_schema, struct dsdb_class);
249 NT_STATUS_HAVE_NO_MEMORY(sc);
251 status = dsdb_class_from_drsuapi(s->self_made_schema, &cur->object, s, sc);
252 if (!W_ERROR_IS_OK(status)) {
253 return werror_to_ntstatus(status);
256 DLIST_ADD_END(s->self_made_schema->classes, sc, struct dsdb_class *);
260 /* attach the schema to the ldb */
261 ret = dsdb_set_schema(s->ldb, s->self_made_schema);
262 if (ret != LDB_SUCCESS) {
263 return NT_STATUS_FOOBAR;
265 /* we don't want to access the self made schema anymore */
266 s->self_made_schema = NULL;
267 s->schema = dsdb_get_schema(s->ldb);
269 status = dsdb_extended_replicated_objects_commit(s->ldb,
274 linked_attributes_count,
280 if (!W_ERROR_IS_OK(status)) {
281 DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
282 return werror_to_ntstatus(status);
285 if (lp_parm_bool(s->tctx->lp_ctx, NULL, "become dc", "dump objects", false)) {
286 for (i=0; i < objs->num_objects; i++) {
287 struct ldb_ldif ldif;
288 fprintf(stdout, "#\n");
289 ldif.changetype = LDB_CHANGETYPE_NONE;
290 ldif.msg = objs->objects[i].msg;
291 ldb_ldif_write_file(s->ldb, stdout, &ldif);
292 NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data);
296 msg = ldb_msg_new(objs);
297 NT_STATUS_HAVE_NO_MEMORY(msg);
298 msg->dn = objs->partition_dn;
300 status = dsdb_get_oid_mappings_ldb(s->schema, msg, &prefixMap_val, &schemaInfo_val);
301 if (!W_ERROR_IS_OK(status)) {
302 DEBUG(0,("Failed dsdb_get_oid_mappings_ldb(%s)\n", win_errstr(status)));
303 return werror_to_ntstatus(status);
306 /* we only add prefixMap here, because schemaInfo is a replicated attribute and already applied */
307 ret = ldb_msg_add_value(msg, "prefixMap", &prefixMap_val, &prefixMap_el);
308 if (ret != LDB_SUCCESS) {
309 return NT_STATUS_FOOBAR;
311 prefixMap_el->flags = LDB_FLAG_MOD_REPLACE;
313 ret = ldb_modify(s->ldb, msg);
314 if (ret != LDB_SUCCESS) {
315 DEBUG(0,("Failed to add prefixMap and schemaInfo %s\n", ldb_strerror(ret)));
316 return NT_STATUS_FOOBAR;
323 talloc_free(s->ldb); /* this also free's the s->schema, because dsdb_set_schema() steals it */
326 sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb");
327 DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", sam_ldb_path));
328 s->ldb = ldb_wrap_connect(s, s->tctx->ev, s->tctx->lp_ctx, sam_ldb_path,
329 system_session(s, s->tctx->lp_ctx),
332 DEBUG(0,("Failed to open '%s'\n",
334 return NT_STATUS_INTERNAL_DB_ERROR;
337 ok = samdb_set_ntds_invocation_id(s->ldb, &c->dest_dsa->invocation_id);
339 DEBUG(0,("Failed to set cached ntds invocationId\n"));
340 return NT_STATUS_FOOBAR;
342 ok = samdb_set_ntds_objectGUID(s->ldb, &c->dest_dsa->ntds_guid);
344 DEBUG(0,("Failed to set cached ntds objectGUID\n"));
345 return NT_STATUS_FOOBAR;
348 s->schema = dsdb_get_schema(s->ldb);
350 DEBUG(0,("Failed to get loaded dsdb_schema\n"));
351 return NT_STATUS_FOOBAR;
357 static NTSTATUS test_become_dc_schema_chunk(void *private_data,
358 const struct libnet_BecomeDC_StoreChunk *c)
360 struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
362 const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
363 uint32_t total_object_count;
364 uint32_t object_count;
365 struct drsuapi_DsReplicaObjectListItemEx *first_object;
366 struct drsuapi_DsReplicaObjectListItemEx *cur;
368 switch (c->ctr_level) {
370 mapping_ctr = &c->ctr1->mapping_ctr;
371 total_object_count = c->ctr1->total_object_count;
372 object_count = c->ctr1->object_count;
373 first_object = c->ctr1->first_object;
376 mapping_ctr = &c->ctr6->mapping_ctr;
377 total_object_count = c->ctr6->total_object_count;
378 object_count = c->ctr6->object_count;
379 first_object = c->ctr6->first_object;
382 return NT_STATUS_INVALID_PARAMETER;
385 if (total_object_count) {
386 DEBUG(0,("Schema-DN[%s] objects[%u/%u]\n",
387 c->partition->nc.dn, object_count, total_object_count));
389 DEBUG(0,("Schema-DN[%s] objects[%u]\n",
390 c->partition->nc.dn, object_count));
394 s->self_made_schema = dsdb_new_schema(s, lp_iconv_convenience(s->lp_ctx));
396 NT_STATUS_HAVE_NO_MEMORY(s->self_made_schema);
398 status = dsdb_load_oid_mappings_drsuapi(s->self_made_schema, mapping_ctr);
399 if (!W_ERROR_IS_OK(status)) {
400 return werror_to_ntstatus(status);
403 s->schema = s->self_made_schema;
405 status = dsdb_verify_oid_mappings_drsuapi(s->schema, mapping_ctr);
406 if (!W_ERROR_IS_OK(status)) {
407 return werror_to_ntstatus(status);
411 if (!s->schema_part.first_object) {
412 s->schema_part.object_count = object_count;
413 s->schema_part.first_object = talloc_steal(s, first_object);
415 s->schema_part.object_count += object_count;
416 s->schema_part.last_object->next_object = talloc_steal(s->schema_part.last_object,
419 for (cur = first_object; cur->next_object; cur = cur->next_object) {}
420 s->schema_part.last_object = cur;
422 if (c->partition->highwatermark.tmp_highest_usn == c->partition->highwatermark.highest_usn) {
423 return test_apply_schema(s, c);
429 static NTSTATUS test_become_dc_store_chunk(void *private_data,
430 const struct libnet_BecomeDC_StoreChunk *c)
432 struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
434 const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
435 uint32_t total_object_count;
436 uint32_t object_count;
437 struct drsuapi_DsReplicaObjectListItemEx *first_object;
438 uint32_t linked_attributes_count;
439 struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
440 const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
441 struct dsdb_extended_replicated_objects *objs;
442 struct repsFromTo1 *s_dsa;
446 s_dsa = talloc_zero(s, struct repsFromTo1);
447 NT_STATUS_HAVE_NO_MEMORY(s_dsa);
448 s_dsa->other_info = talloc(s_dsa, struct repsFromTo1OtherInfo);
449 NT_STATUS_HAVE_NO_MEMORY(s_dsa->other_info);
451 switch (c->ctr_level) {
453 mapping_ctr = &c->ctr1->mapping_ctr;
454 total_object_count = c->ctr1->total_object_count;
455 object_count = c->ctr1->object_count;
456 first_object = c->ctr1->first_object;
457 linked_attributes_count = 0;
458 linked_attributes = NULL;
459 s_dsa->highwatermark = c->ctr1->new_highwatermark;
460 s_dsa->source_dsa_obj_guid = c->ctr1->source_dsa_guid;
461 s_dsa->source_dsa_invocation_id = c->ctr1->source_dsa_invocation_id;
462 uptodateness_vector = NULL; /* TODO: map it */
465 mapping_ctr = &c->ctr6->mapping_ctr;
466 total_object_count = c->ctr6->total_object_count;
467 object_count = c->ctr6->object_count;
468 first_object = c->ctr6->first_object;
469 linked_attributes_count = c->ctr6->linked_attributes_count;
470 linked_attributes = c->ctr6->linked_attributes;
471 s_dsa->highwatermark = c->ctr6->new_highwatermark;
472 s_dsa->source_dsa_obj_guid = c->ctr6->source_dsa_guid;
473 s_dsa->source_dsa_invocation_id = c->ctr6->source_dsa_invocation_id;
474 uptodateness_vector = c->ctr6->uptodateness_vector;
477 return NT_STATUS_INVALID_PARAMETER;
480 s_dsa->replica_flags = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
481 | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
482 | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS;
483 memset(s_dsa->schedule, 0x11, sizeof(s_dsa->schedule));
485 tmp_dns_name = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid);
486 NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
487 tmp_dns_name = talloc_asprintf_append_buffer(tmp_dns_name, "._msdcs.%s", c->forest->dns_name);
488 NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
489 s_dsa->other_info->dns_name = tmp_dns_name;
491 if (total_object_count) {
492 DEBUG(0,("Partition[%s] objects[%u/%u]\n",
493 c->partition->nc.dn, object_count, total_object_count));
495 DEBUG(0,("Partition[%s] objects[%u]\n",
496 c->partition->nc.dn, object_count));
499 status = dsdb_extended_replicated_objects_commit(s->ldb,
504 linked_attributes_count,
510 if (!W_ERROR_IS_OK(status)) {
511 DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
512 return werror_to_ntstatus(status);
515 if (lp_parm_bool(s->tctx->lp_ctx, NULL, "become dc", "dump objects", false)) {
516 for (i=0; i < objs->num_objects; i++) {
517 struct ldb_ldif ldif;
518 fprintf(stdout, "#\n");
519 ldif.changetype = LDB_CHANGETYPE_NONE;
520 ldif.msg = objs->objects[i].msg;
521 ldb_ldif_write_file(s->ldb, stdout, &ldif);
522 NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data);
528 for (i=0; i < linked_attributes_count; i++) {
529 const struct dsdb_attribute *sa;
531 if (!linked_attributes[i].identifier) {
532 return NT_STATUS_FOOBAR;
535 if (!linked_attributes[i].value.blob) {
536 return NT_STATUS_FOOBAR;
539 sa = dsdb_attribute_by_attributeID_id(s->schema,
540 linked_attributes[i].attid);
542 return NT_STATUS_FOOBAR;
545 if (lp_parm_bool(s->tctx->lp_ctx, NULL, "become dc", "dump objects", false)) {
546 DEBUG(0,("# %s\n", sa->lDAPDisplayName));
547 NDR_PRINT_DEBUG(drsuapi_DsReplicaLinkedAttribute, &linked_attributes[i]);
549 linked_attributes[i].value.blob->data,
550 linked_attributes[i].value.blob->length);
557 bool torture_net_become_dc(struct torture_context *torture)
561 struct libnet_BecomeDC b;
562 struct libnet_UnbecomeDC u;
563 struct test_become_dc_state *s;
564 struct ldb_message *msg;
569 char *location = NULL;
570 torture_assert_ntstatus_ok(torture, torture_temp_dir(torture, "libnet_BecomeDC", &location),
571 "torture_temp_dir should return NT_STATUS_OK" );
573 s = talloc_zero(torture, struct test_become_dc_state);
574 if (!s) return false;
577 s->lp_ctx = torture->lp_ctx;
579 s->netbios_name = lp_parm_string(torture->lp_ctx, NULL, "become dc", "smbtorture dc");
580 if (!s->netbios_name || !s->netbios_name[0]) {
581 s->netbios_name = "smbtorturedc";
584 s->targetdir = location;
586 /* Join domain as a member server. */
587 s->tj = torture_join_domain(torture, s->netbios_name,
589 &s->machine_account);
591 DEBUG(0, ("%s failed to join domain as workstation\n",
596 s->ctx = libnet_context_init(torture->ev, torture->lp_ctx);
597 s->ctx->cred = cmdline_credentials;
599 s->ldb = ldb_init(s, torture->ev);
602 b.in.domain_dns_name = torture_join_dom_dns_name(s->tj);
603 b.in.domain_netbios_name = torture_join_dom_netbios_name(s->tj);
604 b.in.domain_sid = torture_join_sid(s->tj);
605 b.in.source_dsa_address = torture_setting_string(torture, "host", NULL);
606 b.in.dest_dsa_netbios_name = s->netbios_name;
608 b.in.callbacks.private_data = s;
609 b.in.callbacks.check_options = test_become_dc_check_options;
610 b.in.callbacks.prepare_db = test_become_dc_prepare_db;
611 b.in.callbacks.schema_chunk = test_become_dc_schema_chunk;
612 b.in.callbacks.config_chunk = test_become_dc_store_chunk;
613 b.in.callbacks.domain_chunk = test_become_dc_store_chunk;
615 status = libnet_BecomeDC(s->ctx, s, &b);
616 if (!NT_STATUS_IS_OK(status)) {
617 printf("libnet_BecomeDC() failed - %s\n", nt_errstr(status));
622 msg = ldb_msg_new(s);
624 printf("ldb_msg_new() failed\n");
628 msg->dn = ldb_dn_new(msg, s->ldb, "@ROOTDSE");
630 printf("ldb_msg_new(@ROOTDSE) failed\n");
635 ldb_ret = ldb_msg_add_string(msg, "isSynchronized", "TRUE");
636 if (ldb_ret != LDB_SUCCESS) {
637 printf("ldb_msg_add_string(msg, isSynchronized, TRUE) failed: %d\n", ldb_ret);
642 for (i=0; i < msg->num_elements; i++) {
643 msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
646 printf("mark ROOTDSE with isSynchronized=TRUE\n");
647 ldb_ret = ldb_modify(s->ldb, msg);
648 if (ldb_ret != LDB_SUCCESS) {
649 printf("ldb_modify() failed: %d\n", ldb_ret);
655 talloc_free(s->ldb); /* this also free's the s->schema, because dsdb_set_schema() steals it */
658 sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb");
659 DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", sam_ldb_path));
660 s->ldb = ldb_wrap_connect(s, s->tctx->ev, s->lp_ctx, sam_ldb_path,
661 system_session(s, s->lp_ctx),
664 DEBUG(0,("Failed to open '%s'\n",
670 s->schema = dsdb_get_schema(s->ldb);
672 DEBUG(0,("Failed to get loaded dsdb_schema\n"));
677 /* Make sure we get this from the command line */
678 if (lp_parm_bool(torture->lp_ctx, NULL, "become dc", "do not unjoin", false)) {
685 u.in.domain_dns_name = torture_join_dom_dns_name(s->tj);
686 u.in.domain_netbios_name = torture_join_dom_netbios_name(s->tj);
687 u.in.source_dsa_address = torture_setting_string(torture, "host", NULL);
688 u.in.dest_dsa_netbios_name = s->netbios_name;
690 status = libnet_UnbecomeDC(s->ctx, s, &u);
691 if (!NT_STATUS_IS_OK(status)) {
692 printf("libnet_UnbecomeDC() failed - %s\n", nt_errstr(status));
697 torture_leave_domain(torture, s->tj);