2006-12-13 02:23:50 +03:00
/*
Unix SMB / CIFS implementation .
libnet_BecomeDC ( ) tests
2007-03-14 22:10:21 +03:00
Copyright ( C ) Stefan Metzmacher < metze @ samba . org > 2006
2006-12-13 02:23:50 +03:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2006-12-13 02:23:50 +03:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2006-12-13 02:23:50 +03:00
*/
# include "includes.h"
# include "lib/cmdline/popt_common.h"
# include "torture/torture.h"
# include "torture/rpc/rpc.h"
# include "libnet/libnet.h"
# include "lib/events/events.h"
2006-12-23 00:31:57 +03:00
# include "dsdb/samdb/samdb.h"
2008-10-11 23:31:42 +04:00
# include "../lib/util/dlinklist.h"
2007-01-05 00:09:29 +03:00
# include "lib/ldb/include/ldb.h"
# include "lib/ldb/include/ldb_errors.h"
# include "librpc/ndr/libndr.h"
# include "librpc/gen_ndr/ndr_drsuapi.h"
# include "librpc/gen_ndr/ndr_drsblobs.h"
# include "librpc/gen_ndr/ndr_misc.h"
# include "system/time.h"
2007-11-16 22:12:00 +03:00
# include "lib/ldb_wrap.h"
2008-02-15 02:23:56 +03:00
# include "auth/auth.h"
2008-02-15 01:28:31 +03:00
# include "param/param.h"
2008-02-15 17:53:06 +03:00
# include "torture/util.h"
2008-04-09 05:23:13 +04:00
# include "param/provision.h"
2007-12-26 01:36:58 +03:00
struct test_become_dc_state {
struct libnet_context * ctx ;
struct torture_context * tctx ;
const char * netbios_name ;
struct test_join * tj ;
struct cli_credentials * machine_account ;
struct dsdb_schema * self_made_schema ;
const struct dsdb_schema * schema ;
struct ldb_context * ldb ;
struct {
uint32_t object_count ;
struct drsuapi_DsReplicaObjectListItemEx * first_object ;
struct drsuapi_DsReplicaObjectListItemEx * last_object ;
} schema_part ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
const char * targetdir ;
struct loadparm_context * lp_ctx ;
2007-12-26 01:36:58 +03:00
} ;
2008-02-15 02:23:56 +03:00
static NTSTATUS test_become_dc_prepare_db ( void * private_data ,
const struct libnet_BecomeDC_PrepareDB * p )
{
struct test_become_dc_state * s = talloc_get_type ( private_data , struct test_become_dc_state ) ;
2008-02-15 17:14:55 +03:00
struct provision_settings settings ;
2008-04-10 08:07:46 +04:00
struct provision_result result ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
NTSTATUS status ;
2008-02-15 17:14:55 +03:00
settings . site_name = p - > dest_dsa - > site_name ;
settings . root_dn_str = p - > forest - > root_dn_str ;
settings . domain_dn_str = p - > domain - > dn_str ;
settings . config_dn_str = p - > forest - > config_dn_str ;
settings . schema_dn_str = p - > forest - > schema_dn_str ;
2008-07-15 20:28:25 +04:00
settings . server_dn_str = torture_join_server_dn_str ( s - > tj ) ;
settings . invocation_id = & p - > dest_dsa - > invocation_id ;
2008-02-15 17:14:55 +03:00
settings . netbios_name = p - > dest_dsa - > netbios_name ;
2008-07-15 20:28:25 +04:00
settings . host_ip = NULL ;
2008-02-15 17:14:55 +03:00
settings . realm = torture_join_dom_dns_name ( s - > tj ) ;
settings . domain = torture_join_dom_netbios_name ( s - > tj ) ;
2008-07-15 20:28:25 +04:00
settings . ntds_dn_str = p - > dest_dsa - > ntds_dn_str ;
2008-02-15 17:14:55 +03:00
settings . machine_password = cli_credentials_get_password ( s - > machine_account ) ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
settings . targetdir = s - > targetdir ;
2008-04-10 08:07:46 +04:00
status = provision_bare ( s , s - > lp_ctx , & settings , & result ) ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
2008-04-11 13:37:23 +04:00
s - > ldb = result . samdb ;
s - > lp_ctx = result . lp_ctx ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
return NT_STATUS_OK ;
2008-02-15 02:23:56 +03:00
}
2007-12-26 01:36:58 +03:00
static NTSTATUS test_become_dc_check_options ( void * private_data ,
const struct libnet_BecomeDC_CheckOptions * o )
{
struct test_become_dc_state * s = talloc_get_type ( private_data , struct test_become_dc_state ) ;
DEBUG ( 0 , ( " Become DC [%s] of Domain[%s]/[%s] \n " ,
s - > netbios_name ,
o - > domain - > netbios_name , o - > domain - > dns_name ) ) ;
DEBUG ( 0 , ( " Promotion Partner is Server[%s] from Site[%s] \n " ,
o - > source_dsa - > dns_name , o - > source_dsa - > site_name ) ) ;
DEBUG ( 0 , ( " Options:crossRef behavior_version[%u] \n "
" \t schema object_version[%u] \n "
" \t domain behavior_version[%u] \n "
" \t domain w2k3_update_revision[%u] \n " ,
o - > forest - > crossref_behavior_version ,
o - > forest - > schema_object_version ,
o - > domain - > behavior_version ,
o - > domain - > w2k3_update_revision ) ) ;
return NT_STATUS_OK ;
}
2006-12-30 14:56:00 +03:00
static NTSTATUS test_apply_schema ( struct test_become_dc_state * s ,
const struct libnet_BecomeDC_StoreChunk * c )
{
WERROR status ;
2007-01-11 16:15:53 +03:00
const struct drsuapi_DsReplicaOIDMapping_Ctr * mapping_ctr ;
uint32_t object_count ;
struct drsuapi_DsReplicaObjectListItemEx * first_object ;
2006-12-30 14:56:00 +03:00
struct drsuapi_DsReplicaObjectListItemEx * cur ;
2007-01-11 16:15:53 +03:00
uint32_t linked_attributes_count ;
struct drsuapi_DsReplicaLinkedAttribute * linked_attributes ;
const struct drsuapi_DsReplicaCursor2CtrEx * uptodateness_vector ;
struct dsdb_extended_replicated_objects * objs ;
2007-01-12 19:02:10 +03:00
struct repsFromTo1 * s_dsa ;
char * tmp_dns_name ;
2007-01-14 18:49:06 +03:00
struct ldb_message * msg ;
struct ldb_val prefixMap_val ;
struct ldb_message_element * prefixMap_el ;
struct ldb_val schemaInfo_val ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
char * sam_ldb_path ;
2007-01-11 16:15:53 +03:00
uint32_t i ;
2007-01-12 20:26:55 +03:00
int ret ;
2007-01-14 21:03:26 +03:00
bool ok ;
DEBUG ( 0 , ( " Analyze and apply schema objects \n " ) ) ;
2006-12-30 14:56:00 +03:00
2007-01-12 19:02:10 +03:00
s_dsa = talloc_zero ( s , struct repsFromTo1 ) ;
NT_STATUS_HAVE_NO_MEMORY ( s_dsa ) ;
s_dsa - > other_info = talloc ( s_dsa , struct repsFromTo1OtherInfo ) ;
NT_STATUS_HAVE_NO_MEMORY ( s_dsa - > other_info ) ;
2007-01-11 16:15:53 +03:00
switch ( c - > ctr_level ) {
case 1 :
2007-01-12 19:02:10 +03:00
mapping_ctr = & c - > ctr1 - > mapping_ctr ;
object_count = s - > schema_part . object_count ;
first_object = s - > schema_part . first_object ;
linked_attributes_count = 0 ;
linked_attributes = NULL ;
s_dsa - > highwatermark = c - > ctr1 - > new_highwatermark ;
s_dsa - > source_dsa_obj_guid = c - > ctr1 - > source_dsa_guid ;
s_dsa - > source_dsa_invocation_id = c - > ctr1 - > source_dsa_invocation_id ;
uptodateness_vector = NULL ; /* TODO: map it */
2007-01-11 16:15:53 +03:00
break ;
case 6 :
2007-01-12 19:02:10 +03:00
mapping_ctr = & c - > ctr6 - > mapping_ctr ;
object_count = s - > schema_part . object_count ;
first_object = s - > schema_part . first_object ;
linked_attributes_count = 0 ; /* TODO: ! */
linked_attributes = NULL ; /* TODO: ! */ ;
s_dsa - > highwatermark = c - > ctr6 - > new_highwatermark ;
s_dsa - > source_dsa_obj_guid = c - > ctr6 - > source_dsa_guid ;
s_dsa - > source_dsa_invocation_id = c - > ctr6 - > source_dsa_invocation_id ;
uptodateness_vector = c - > ctr6 - > uptodateness_vector ;
2007-01-11 16:15:53 +03:00
break ;
default :
return NT_STATUS_INVALID_PARAMETER ;
}
2007-01-12 19:02:10 +03:00
s_dsa - > replica_flags = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
| DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
| DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS ;
memset ( s_dsa - > schedule , 0x11 , sizeof ( s_dsa - > schedule ) ) ;
tmp_dns_name = GUID_string ( s_dsa - > other_info , & s_dsa - > source_dsa_obj_guid ) ;
NT_STATUS_HAVE_NO_MEMORY ( tmp_dns_name ) ;
2007-09-15 03:21:00 +04:00
tmp_dns_name = talloc_asprintf_append_buffer ( tmp_dns_name , " ._msdcs.%s " , c - > forest - > dns_name ) ;
2007-01-12 19:02:10 +03:00
NT_STATUS_HAVE_NO_MEMORY ( tmp_dns_name ) ;
s_dsa - > other_info - > dns_name = tmp_dns_name ;
2007-01-11 16:15:53 +03:00
for ( cur = first_object ; cur ; cur = cur - > next_object ) {
2006-12-30 14:56:00 +03:00
bool is_attr = false ;
bool is_class = false ;
for ( i = 0 ; i < cur - > object . attribute_ctr . num_attributes ; i + + ) {
struct drsuapi_DsReplicaAttribute * a ;
uint32_t j ;
const char * oid = NULL ;
a = & cur - > object . attribute_ctr . attributes [ i ] ;
2007-01-14 18:35:10 +03:00
status = dsdb_map_int2oid ( s - > self_made_schema , a - > attid , s , & oid ) ;
2006-12-30 14:56:00 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return werror_to_ntstatus ( status ) ;
}
switch ( a - > attid ) {
case DRSUAPI_ATTRIBUTE_objectClass :
2007-01-03 12:58:14 +03:00
for ( j = 0 ; j < a - > value_ctr . num_values ; j + + ) {
2007-01-02 22:24:32 +03:00
uint32_t val = 0xFFFFFFFF ;
2007-01-02 19:39:32 +03:00
2007-01-03 12:58:14 +03:00
if ( a - > value_ctr . values [ i ] . blob
& & a - > value_ctr . values [ i ] . blob - > length = = 4 ) {
val = IVAL ( a - > value_ctr . values [ i ] . blob - > data , 0 ) ;
2007-01-02 22:24:32 +03:00
}
2006-12-30 14:56:00 +03:00
if ( val = = DRSUAPI_OBJECTCLASS_attributeSchema ) {
is_attr = true ;
}
if ( val = = DRSUAPI_OBJECTCLASS_classSchema ) {
is_class = true ;
}
}
2007-01-02 22:24:32 +03:00
2006-12-30 14:56:00 +03:00
break ;
default :
break ;
}
}
if ( is_attr ) {
struct dsdb_attribute * sa ;
2007-01-14 18:35:10 +03:00
sa = talloc_zero ( s - > self_made_schema , struct dsdb_attribute ) ;
2006-12-30 14:56:00 +03:00
NT_STATUS_HAVE_NO_MEMORY ( sa ) ;
2007-01-14 18:35:10 +03:00
status = dsdb_attribute_from_drsuapi ( s - > self_made_schema , & cur - > object , s , sa ) ;
2006-12-30 14:56:00 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return werror_to_ntstatus ( status ) ;
}
2007-01-14 18:35:10 +03:00
DLIST_ADD_END ( s - > self_made_schema - > attributes , sa , struct dsdb_attribute * ) ;
2006-12-30 14:56:00 +03:00
}
if ( is_class ) {
struct dsdb_class * sc ;
2007-01-14 18:35:10 +03:00
sc = talloc_zero ( s - > self_made_schema , struct dsdb_class ) ;
2006-12-30 14:56:00 +03:00
NT_STATUS_HAVE_NO_MEMORY ( sc ) ;
2007-01-14 18:35:10 +03:00
status = dsdb_class_from_drsuapi ( s - > self_made_schema , & cur - > object , s , sc ) ;
2006-12-30 14:56:00 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return werror_to_ntstatus ( status ) ;
}
2007-01-14 18:35:10 +03:00
DLIST_ADD_END ( s - > self_made_schema - > classes , sc , struct dsdb_class * ) ;
2006-12-30 14:56:00 +03:00
}
}
2007-01-14 18:35:10 +03:00
/* attach the schema to the ldb */
ret = dsdb_set_schema ( s - > ldb , s - > self_made_schema ) ;
2007-01-12 20:26:55 +03:00
if ( ret ! = LDB_SUCCESS ) {
return NT_STATUS_FOOBAR ;
}
2007-01-14 18:35:10 +03:00
/* we don't want to access the self made schema anymore */
s - > self_made_schema = NULL ;
s - > schema = dsdb_get_schema ( s - > ldb ) ;
2007-01-12 20:26:55 +03:00
2007-01-11 16:15:53 +03:00
status = dsdb_extended_replicated_objects_commit ( s - > ldb ,
c - > partition - > nc . dn ,
mapping_ctr ,
object_count ,
first_object ,
linked_attributes_count ,
linked_attributes ,
2007-01-12 19:02:10 +03:00
s_dsa ,
2007-01-11 16:15:53 +03:00
uptodateness_vector ,
2007-02-12 14:46:35 +03:00
c - > gensec_skey ,
2007-01-11 16:15:53 +03:00
s , & objs ) ;
if ( ! W_ERROR_IS_OK ( status ) ) {
DEBUG ( 0 , ( " Failed to commit objects: %s \n " , win_errstr ( status ) ) ) ;
return werror_to_ntstatus ( status ) ;
2007-01-06 02:00:46 +03:00
}
2007-12-07 03:16:50 +03:00
if ( lp_parm_bool ( s - > tctx - > lp_ctx , NULL , " become dc " , " dump objects " , false ) ) {
2007-01-11 16:15:53 +03:00
for ( i = 0 ; i < objs - > num_objects ; i + + ) {
struct ldb_ldif ldif ;
fprintf ( stdout , " # \n " ) ;
ldif . changetype = LDB_CHANGETYPE_NONE ;
ldif . msg = objs - > objects [ i ] . msg ;
ldb_ldif_write_file ( s - > ldb , stdout , & ldif ) ;
NDR_PRINT_DEBUG ( replPropertyMetaDataBlob , objs - > objects [ i ] . meta_data ) ;
}
2007-01-06 02:00:46 +03:00
}
2007-01-14 18:49:06 +03:00
msg = ldb_msg_new ( objs ) ;
NT_STATUS_HAVE_NO_MEMORY ( msg ) ;
msg - > dn = objs - > partition_dn ;
status = dsdb_get_oid_mappings_ldb ( s - > schema , msg , & prefixMap_val , & schemaInfo_val ) ;
if ( ! W_ERROR_IS_OK ( status ) ) {
DEBUG ( 0 , ( " Failed dsdb_get_oid_mappings_ldb(%s) \n " , win_errstr ( status ) ) ) ;
return werror_to_ntstatus ( status ) ;
}
2007-01-14 18:56:55 +03:00
/* we only add prefixMap here, because schemaInfo is a replicated attribute and already applied */
2007-01-14 18:49:06 +03:00
ret = ldb_msg_add_value ( msg , " prefixMap " , & prefixMap_val , & prefixMap_el ) ;
if ( ret ! = LDB_SUCCESS ) {
return NT_STATUS_FOOBAR ;
}
prefixMap_el - > flags = LDB_FLAG_MOD_REPLACE ;
ret = ldb_modify ( s - > ldb , msg ) ;
if ( ret ! = LDB_SUCCESS ) {
DEBUG ( 0 , ( " Failed to add prefixMap and schemaInfo %s \n " , ldb_strerror ( ret ) ) ) ;
return NT_STATUS_FOOBAR ;
}
2007-01-12 19:02:10 +03:00
talloc_free ( s_dsa ) ;
2007-01-11 16:15:53 +03:00
talloc_free ( objs ) ;
2007-01-14 21:03:26 +03:00
/* reopen the ldb */
talloc_free ( s - > ldb ) ; /* this also free's the s->schema, because dsdb_set_schema() steals it */
s - > schema = NULL ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
sam_ldb_path = talloc_asprintf ( s , " %s/%s " , s - > targetdir , " private/sam.ldb " ) ;
DEBUG ( 0 , ( " Reopen the SAM LDB with system credentials and a already stored schema: %s \n " , sam_ldb_path ) ) ;
2008-04-17 14:23:44 +04:00
s - > ldb = ldb_wrap_connect ( s , s - > tctx - > ev , s - > tctx - > lp_ctx , sam_ldb_path ,
2007-12-07 03:16:50 +03:00
system_session ( s , s - > tctx - > lp_ctx ) ,
2007-01-14 21:03:26 +03:00
NULL , 0 , NULL ) ;
if ( ! s - > ldb ) {
DEBUG ( 0 , ( " Failed to open '%s' \n " ,
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
sam_ldb_path ) ) ;
2007-01-14 21:03:26 +03:00
return NT_STATUS_INTERNAL_DB_ERROR ;
}
ok = samdb_set_ntds_invocation_id ( s - > ldb , & c - > dest_dsa - > invocation_id ) ;
if ( ! ok ) {
DEBUG ( 0 , ( " Failed to set cached ntds invocationId \n " ) ) ;
return NT_STATUS_FOOBAR ;
}
ok = samdb_set_ntds_objectGUID ( s - > ldb , & c - > dest_dsa - > ntds_guid ) ;
if ( ! ok ) {
DEBUG ( 0 , ( " Failed to set cached ntds objectGUID \n " ) ) ;
return NT_STATUS_FOOBAR ;
}
s - > schema = dsdb_get_schema ( s - > ldb ) ;
if ( ! s - > schema ) {
DEBUG ( 0 , ( " Failed to get loaded dsdb_schema \n " ) ) ;
return NT_STATUS_FOOBAR ;
}
2006-12-30 14:56:00 +03:00
return NT_STATUS_OK ;
}
2006-12-23 00:31:57 +03:00
static NTSTATUS test_become_dc_schema_chunk ( void * private_data ,
const struct libnet_BecomeDC_StoreChunk * c )
{
struct test_become_dc_state * s = talloc_get_type ( private_data , struct test_become_dc_state ) ;
WERROR status ;
const struct drsuapi_DsReplicaOIDMapping_Ctr * mapping_ctr ;
2008-07-15 18:59:09 +04:00
uint32_t nc_object_count ;
2006-12-23 00:31:57 +03:00
uint32_t object_count ;
struct drsuapi_DsReplicaObjectListItemEx * first_object ;
struct drsuapi_DsReplicaObjectListItemEx * cur ;
2008-07-16 15:02:54 +04:00
uint32_t nc_linked_attributes_count ;
uint32_t linked_attributes_count ;
2006-12-23 00:31:57 +03:00
switch ( c - > ctr_level ) {
case 1 :
2008-07-16 15:02:54 +04:00
mapping_ctr = & c - > ctr1 - > mapping_ctr ;
nc_object_count = c - > ctr1 - > extended_ret ; /* maybe w2k send this unexpected? */
object_count = c - > ctr1 - > object_count ;
first_object = c - > ctr1 - > first_object ;
nc_linked_attributes_count = 0 ;
linked_attributes_count = 0 ;
2006-12-23 00:31:57 +03:00
break ;
case 6 :
2008-07-16 15:02:54 +04:00
mapping_ctr = & c - > ctr6 - > mapping_ctr ;
nc_object_count = c - > ctr6 - > nc_object_count ;
object_count = c - > ctr6 - > object_count ;
first_object = c - > ctr6 - > first_object ;
nc_linked_attributes_count = c - > ctr6 - > nc_linked_attributes_count ;
linked_attributes_count = c - > ctr6 - > linked_attributes_count ;
2006-12-23 00:31:57 +03:00
break ;
default :
return NT_STATUS_INVALID_PARAMETER ;
}
2008-07-15 18:59:09 +04:00
if ( nc_object_count ) {
2008-07-16 15:02:54 +04:00
DEBUG ( 0 , ( " Schema-DN[%s] objects[%u/%u] linked_values[%u/%u] \n " ,
c - > partition - > nc . dn , object_count , nc_object_count ,
linked_attributes_count , nc_linked_attributes_count ) ) ;
2006-12-23 00:31:57 +03:00
} else {
2008-07-16 15:02:54 +04:00
DEBUG ( 0 , ( " Schema-DN[%s] objects[%u] linked_values[%u \n " ,
c - > partition - > nc . dn , object_count , linked_attributes_count ) ) ;
2006-12-23 00:31:57 +03:00
}
if ( ! s - > schema ) {
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
s - > self_made_schema = dsdb_new_schema ( s , lp_iconv_convenience ( s - > lp_ctx ) ) ;
2007-01-14 18:35:10 +03:00
NT_STATUS_HAVE_NO_MEMORY ( s - > self_made_schema ) ;
2006-12-23 00:31:57 +03:00
2007-01-14 18:35:10 +03:00
status = dsdb_load_oid_mappings_drsuapi ( s - > self_made_schema , mapping_ctr ) ;
2006-12-23 00:31:57 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return werror_to_ntstatus ( status ) ;
}
2007-01-14 18:35:10 +03:00
s - > schema = s - > self_made_schema ;
2006-12-28 15:50:39 +03:00
} else {
2007-01-13 18:29:47 +03:00
status = dsdb_verify_oid_mappings_drsuapi ( s - > schema , mapping_ctr ) ;
2006-12-28 15:50:39 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return werror_to_ntstatus ( status ) ;
}
2006-12-23 00:31:57 +03:00
}
2006-12-30 14:56:00 +03:00
if ( ! s - > schema_part . first_object ) {
2007-01-11 16:15:53 +03:00
s - > schema_part . object_count = object_count ;
2006-12-30 14:56:00 +03:00
s - > schema_part . first_object = talloc_steal ( s , first_object ) ;
} else {
2007-01-11 16:15:53 +03:00
s - > schema_part . object_count + = object_count ;
2006-12-30 14:56:00 +03:00
s - > schema_part . last_object - > next_object = talloc_steal ( s - > schema_part . last_object ,
first_object ) ;
}
for ( cur = first_object ; cur - > next_object ; cur = cur - > next_object ) { }
s - > schema_part . last_object = cur ;
2006-12-23 00:31:57 +03:00
2008-07-16 15:01:56 +04:00
if ( ! c - > partition - > more_data ) {
2006-12-30 14:56:00 +03:00
return test_apply_schema ( s , c ) ;
2006-12-23 00:31:57 +03:00
}
return NT_STATUS_OK ;
}
2006-12-21 00:54:06 +03:00
static NTSTATUS test_become_dc_store_chunk ( void * private_data ,
const struct libnet_BecomeDC_StoreChunk * c )
{
2006-12-28 15:54:55 +03:00
struct test_become_dc_state * s = talloc_get_type ( private_data , struct test_become_dc_state ) ;
WERROR status ;
const struct drsuapi_DsReplicaOIDMapping_Ctr * mapping_ctr ;
2008-07-15 18:59:09 +04:00
uint32_t nc_object_count ;
2006-12-23 00:31:57 +03:00
uint32_t object_count ;
2006-12-30 14:56:00 +03:00
struct drsuapi_DsReplicaObjectListItemEx * first_object ;
2008-07-16 15:02:54 +04:00
uint32_t nc_linked_attributes_count ;
2007-01-05 00:09:29 +03:00
uint32_t linked_attributes_count ;
struct drsuapi_DsReplicaLinkedAttribute * linked_attributes ;
2007-01-11 16:15:53 +03:00
const struct drsuapi_DsReplicaCursor2CtrEx * uptodateness_vector ;
struct dsdb_extended_replicated_objects * objs ;
2007-01-12 19:02:10 +03:00
struct repsFromTo1 * s_dsa ;
char * tmp_dns_name ;
2007-01-05 00:09:29 +03:00
uint32_t i ;
2006-12-23 00:31:57 +03:00
2007-01-12 19:02:10 +03:00
s_dsa = talloc_zero ( s , struct repsFromTo1 ) ;
NT_STATUS_HAVE_NO_MEMORY ( s_dsa ) ;
s_dsa - > other_info = talloc ( s_dsa , struct repsFromTo1OtherInfo ) ;
NT_STATUS_HAVE_NO_MEMORY ( s_dsa - > other_info ) ;
2006-12-23 00:31:57 +03:00
switch ( c - > ctr_level ) {
case 1 :
2007-01-12 19:02:10 +03:00
mapping_ctr = & c - > ctr1 - > mapping_ctr ;
2008-07-15 18:59:09 +04:00
nc_object_count = c - > ctr1 - > extended_ret ; /* maybe w2k send this unexpected? */
2007-01-12 19:02:10 +03:00
object_count = c - > ctr1 - > object_count ;
first_object = c - > ctr1 - > first_object ;
2008-07-16 15:02:54 +04:00
nc_linked_attributes_count = 0 ;
2007-01-12 19:02:10 +03:00
linked_attributes_count = 0 ;
linked_attributes = NULL ;
s_dsa - > highwatermark = c - > ctr1 - > new_highwatermark ;
s_dsa - > source_dsa_obj_guid = c - > ctr1 - > source_dsa_guid ;
s_dsa - > source_dsa_invocation_id = c - > ctr1 - > source_dsa_invocation_id ;
uptodateness_vector = NULL ; /* TODO: map it */
2006-12-23 00:31:57 +03:00
break ;
case 6 :
2007-01-12 19:02:10 +03:00
mapping_ctr = & c - > ctr6 - > mapping_ctr ;
2008-07-15 18:59:09 +04:00
nc_object_count = c - > ctr6 - > nc_object_count ;
2007-01-12 19:02:10 +03:00
object_count = c - > ctr6 - > object_count ;
first_object = c - > ctr6 - > first_object ;
2008-07-16 15:02:54 +04:00
nc_linked_attributes_count = c - > ctr6 - > nc_linked_attributes_count ;
2007-01-12 19:02:10 +03:00
linked_attributes_count = c - > ctr6 - > linked_attributes_count ;
linked_attributes = c - > ctr6 - > linked_attributes ;
s_dsa - > highwatermark = c - > ctr6 - > new_highwatermark ;
s_dsa - > source_dsa_obj_guid = c - > ctr6 - > source_dsa_guid ;
s_dsa - > source_dsa_invocation_id = c - > ctr6 - > source_dsa_invocation_id ;
uptodateness_vector = c - > ctr6 - > uptodateness_vector ;
2006-12-23 00:31:57 +03:00
break ;
default :
return NT_STATUS_INVALID_PARAMETER ;
}
2007-01-12 19:02:10 +03:00
s_dsa - > replica_flags = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
| DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
| DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS ;
memset ( s_dsa - > schedule , 0x11 , sizeof ( s_dsa - > schedule ) ) ;
tmp_dns_name = GUID_string ( s_dsa - > other_info , & s_dsa - > source_dsa_obj_guid ) ;
NT_STATUS_HAVE_NO_MEMORY ( tmp_dns_name ) ;
2007-09-15 03:21:00 +04:00
tmp_dns_name = talloc_asprintf_append_buffer ( tmp_dns_name , " ._msdcs.%s " , c - > forest - > dns_name ) ;
2007-01-12 19:02:10 +03:00
NT_STATUS_HAVE_NO_MEMORY ( tmp_dns_name ) ;
s_dsa - > other_info - > dns_name = tmp_dns_name ;
2008-07-15 18:59:09 +04:00
if ( nc_object_count ) {
2008-07-16 15:02:54 +04:00
DEBUG ( 0 , ( " Partition[%s] objects[%u/%u] linked_values[%u/%u] \n " ,
c - > partition - > nc . dn , object_count , nc_object_count ,
linked_attributes_count , nc_linked_attributes_count ) ) ;
2006-12-23 00:31:57 +03:00
} else {
2008-07-16 15:02:54 +04:00
DEBUG ( 0 , ( " Partition[%s] objects[%u] linked_values[%u \n " ,
c - > partition - > nc . dn , object_count , linked_attributes_count ) ) ;
2006-12-23 00:31:57 +03:00
}
2006-12-21 00:54:06 +03:00
2007-01-11 16:15:53 +03:00
status = dsdb_extended_replicated_objects_commit ( s - > ldb ,
c - > partition - > nc . dn ,
mapping_ctr ,
object_count ,
first_object ,
linked_attributes_count ,
linked_attributes ,
2007-01-12 19:02:10 +03:00
s_dsa ,
2007-01-11 16:15:53 +03:00
uptodateness_vector ,
2007-02-12 14:46:35 +03:00
c - > gensec_skey ,
2007-01-11 16:15:53 +03:00
s , & objs ) ;
2006-12-28 15:54:55 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
2007-01-11 16:15:53 +03:00
DEBUG ( 0 , ( " Failed to commit objects: %s \n " , win_errstr ( status ) ) ) ;
2006-12-28 15:54:55 +03:00
return werror_to_ntstatus ( status ) ;
}
2007-12-07 03:16:50 +03:00
if ( lp_parm_bool ( s - > tctx - > lp_ctx , NULL , " become dc " , " dump objects " , false ) ) {
2007-01-11 16:15:53 +03:00
for ( i = 0 ; i < objs - > num_objects ; i + + ) {
struct ldb_ldif ldif ;
fprintf ( stdout , " # \n " ) ;
ldif . changetype = LDB_CHANGETYPE_NONE ;
ldif . msg = objs - > objects [ i ] . msg ;
ldb_ldif_write_file ( s - > ldb , stdout , & ldif ) ;
NDR_PRINT_DEBUG ( replPropertyMetaDataBlob , objs - > objects [ i ] . meta_data ) ;
2006-12-30 14:56:00 +03:00
}
}
2007-01-12 19:02:10 +03:00
talloc_free ( s_dsa ) ;
2007-01-11 16:15:53 +03:00
talloc_free ( objs ) ;
2006-12-30 14:56:00 +03:00
2007-01-05 00:09:29 +03:00
for ( i = 0 ; i < linked_attributes_count ; i + + ) {
const struct dsdb_attribute * sa ;
if ( ! linked_attributes [ i ] . identifier ) {
return NT_STATUS_FOOBAR ;
}
if ( ! linked_attributes [ i ] . value . blob ) {
return NT_STATUS_FOOBAR ;
}
sa = dsdb_attribute_by_attributeID_id ( s - > schema ,
linked_attributes [ i ] . attid ) ;
if ( ! sa ) {
return NT_STATUS_FOOBAR ;
}
2007-12-07 03:16:50 +03:00
if ( lp_parm_bool ( s - > tctx - > lp_ctx , NULL , " become dc " , " dump objects " , false ) ) {
2007-01-05 00:09:29 +03:00
DEBUG ( 0 , ( " # %s \n " , sa - > lDAPDisplayName ) ) ;
NDR_PRINT_DEBUG ( drsuapi_DsReplicaLinkedAttribute , & linked_attributes [ i ] ) ;
dump_data ( 0 ,
linked_attributes [ i ] . value . blob - > data ,
linked_attributes [ i ] . value . blob - > length ) ;
}
}
2006-12-21 00:54:06 +03:00
return NT_STATUS_OK ;
}
2007-10-07 02:28:14 +04:00
bool torture_net_become_dc ( struct torture_context * torture )
2006-12-13 02:23:50 +03:00
{
2007-10-07 02:28:14 +04:00
bool ret = true ;
2006-12-13 02:23:50 +03:00
NTSTATUS status ;
struct libnet_BecomeDC b ;
struct libnet_UnbecomeDC u ;
2006-12-23 00:31:57 +03:00
struct test_become_dc_state * s ;
2007-01-18 03:26:07 +03:00
struct ldb_message * msg ;
int ldb_ret ;
uint32_t i ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
char * sam_ldb_path ;
char * location = NULL ;
torture_assert_ntstatus_ok ( torture , torture_temp_dir ( torture , " libnet_BecomeDC " , & location ) ,
" torture_temp_dir should return NT_STATUS_OK " ) ;
2006-12-23 00:31:57 +03:00
s = talloc_zero ( torture , struct test_become_dc_state ) ;
2007-10-07 02:28:14 +04:00
if ( ! s ) return false ;
2006-12-13 02:23:50 +03:00
2007-12-07 03:16:50 +03:00
s - > tctx = torture ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
s - > lp_ctx = torture - > lp_ctx ;
2007-12-07 03:16:50 +03:00
2007-12-03 17:53:17 +03:00
s - > netbios_name = lp_parm_string ( torture - > lp_ctx , NULL , " become dc " , " smbtorture dc " ) ;
2007-02-23 13:25:28 +03:00
if ( ! s - > netbios_name | | ! s - > netbios_name [ 0 ] ) {
s - > netbios_name = " smbtorturedc " ;
}
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
s - > targetdir = location ;
2007-02-23 13:25:28 +03:00
2006-12-13 02:23:50 +03:00
/* Join domain as a member server. */
2007-12-03 17:53:17 +03:00
s - > tj = torture_join_domain ( torture , s - > netbios_name ,
2006-12-13 02:23:50 +03:00
ACB_WSTRUST ,
2006-12-23 00:31:57 +03:00
& s - > machine_account ) ;
if ( ! s - > tj ) {
2006-12-13 02:23:50 +03:00
DEBUG ( 0 , ( " %s failed to join domain as workstation \n " ,
2007-02-23 13:25:28 +03:00
s - > netbios_name ) ) ;
2007-10-07 02:28:14 +04:00
return false ;
2006-12-13 02:23:50 +03:00
}
2007-12-07 04:37:04 +03:00
s - > ctx = libnet_context_init ( torture - > ev , torture - > lp_ctx ) ;
2006-12-23 00:31:57 +03:00
s - > ctx - > cred = cmdline_credentials ;
2006-12-13 02:23:50 +03:00
2008-06-14 19:24:17 +04:00
s - > ldb = ldb_init ( s , torture - > ev ) ;
2006-12-31 15:32:15 +03:00
2006-12-20 18:34:32 +03:00
ZERO_STRUCT ( b ) ;
2006-12-23 00:31:57 +03:00
b . in . domain_dns_name = torture_join_dom_dns_name ( s - > tj ) ;
b . in . domain_netbios_name = torture_join_dom_netbios_name ( s - > tj ) ;
b . in . domain_sid = torture_join_sid ( s - > tj ) ;
2007-08-28 04:16:58 +04:00
b . in . source_dsa_address = torture_setting_string ( torture , " host " , NULL ) ;
2007-02-23 13:25:28 +03:00
b . in . dest_dsa_netbios_name = s - > netbios_name ;
2006-12-13 02:23:50 +03:00
2006-12-23 00:31:57 +03:00
b . in . callbacks . private_data = s ;
2006-12-20 19:34:35 +03:00
b . in . callbacks . check_options = test_become_dc_check_options ;
2008-02-15 01:28:31 +03:00
b . in . callbacks . prepare_db = test_become_dc_prepare_db ;
2006-12-23 00:31:57 +03:00
b . in . callbacks . schema_chunk = test_become_dc_schema_chunk ;
2006-12-21 00:54:06 +03:00
b . in . callbacks . config_chunk = test_become_dc_store_chunk ;
2007-03-15 16:21:54 +03:00
b . in . callbacks . domain_chunk = test_become_dc_store_chunk ;
2006-12-20 18:34:32 +03:00
2006-12-23 00:31:57 +03:00
status = libnet_BecomeDC ( s - > ctx , s , & b ) ;
2006-12-13 02:23:50 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
printf ( " libnet_BecomeDC() failed - %s \n " , nt_errstr ( status ) ) ;
2007-10-07 02:28:14 +04:00
ret = false ;
2007-01-18 03:26:07 +03:00
goto cleanup ;
}
msg = ldb_msg_new ( s ) ;
if ( ! msg ) {
printf ( " ldb_msg_new() failed \n " ) ;
2007-10-07 02:28:14 +04:00
ret = false ;
2007-01-18 03:26:07 +03:00
goto cleanup ;
}
2007-10-30 23:01:07 +03:00
msg - > dn = ldb_dn_new ( msg , s - > ldb , " @ROOTDSE " ) ;
2007-01-18 03:26:07 +03:00
if ( ! msg - > dn ) {
2007-10-30 23:01:07 +03:00
printf ( " ldb_msg_new(@ROOTDSE) failed \n " ) ;
2007-10-07 02:28:14 +04:00
ret = false ;
2007-01-18 03:26:07 +03:00
goto cleanup ;
}
ldb_ret = ldb_msg_add_string ( msg , " isSynchronized " , " TRUE " ) ;
if ( ldb_ret ! = LDB_SUCCESS ) {
printf ( " ldb_msg_add_string(msg, isSynchronized, TRUE) failed: %d \n " , ldb_ret ) ;
2007-10-07 02:28:14 +04:00
ret = false ;
2007-01-18 03:26:07 +03:00
goto cleanup ;
}
for ( i = 0 ; i < msg - > num_elements ; i + + ) {
msg - > elements [ i ] . flags = LDB_FLAG_MOD_REPLACE ;
}
printf ( " mark ROOTDSE with isSynchronized=TRUE \n " ) ;
ldb_ret = ldb_modify ( s - > ldb , msg ) ;
if ( ldb_ret ! = LDB_SUCCESS ) {
printf ( " ldb_modify() failed: %d \n " , ldb_ret ) ;
2007-10-07 02:28:14 +04:00
ret = false ;
2007-01-18 03:26:07 +03:00
goto cleanup ;
}
/* reopen the ldb */
talloc_free ( s - > ldb ) ; /* this also free's the s->schema, because dsdb_set_schema() steals it */
s - > schema = NULL ;
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
sam_ldb_path = talloc_asprintf ( s , " %s/%s " , s - > targetdir , " private/sam.ldb " ) ;
DEBUG ( 0 , ( " Reopen the SAM LDB with system credentials and all replicated data: %s \n " , sam_ldb_path ) ) ;
2008-04-17 14:23:44 +04:00
s - > ldb = ldb_wrap_connect ( s , s - > tctx - > ev , s - > lp_ctx , sam_ldb_path ,
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
system_session ( s , s - > lp_ctx ) ,
2007-01-18 03:26:07 +03:00
NULL , 0 , NULL ) ;
if ( ! s - > ldb ) {
DEBUG ( 0 , ( " Failed to open '%s' \n " ,
Make Samba4 pass the NET-API-BECOMEDC test against Win2k3 (again).
To make Samba4, using the python provision system, pass this test
required some major rework. Untested code is broken code, and some of
the refactoring for a seperate provision test (which also now passes)
broke things.
Similarly, the iconv work has compiled, but these codepaths have never
been run (NULL pointer de-reference).
In working to use a local, rather than global, loadparm context, and
to support using a target directory, a few things needed to be
reworked, particularly around path handling.
Andrew Bartlett
(This used to be commit 1169e8d7bee20477b0efbfea3534ac63c83fb3d6)
2008-03-06 13:55:26 +03:00
sam_ldb_path ) ) ;
2007-10-07 02:28:14 +04:00
ret = false ;
2007-01-18 03:26:07 +03:00
goto cleanup ;
}
s - > schema = dsdb_get_schema ( s - > ldb ) ;
if ( ! s - > schema ) {
DEBUG ( 0 , ( " Failed to get loaded dsdb_schema \n " ) ) ;
2007-10-07 02:28:14 +04:00
ret = false ;
2007-01-18 03:26:07 +03:00
goto cleanup ;
2006-12-13 02:23:50 +03:00
}
2008-03-06 14:03:10 +03:00
/* Make sure we get this from the command line */
2008-03-06 14:04:46 +03:00
if ( lp_parm_bool ( torture - > lp_ctx , NULL , " become dc " , " do not unjoin " , false ) ) {
2007-02-22 18:25:55 +03:00
talloc_free ( s ) ;
return ret ;
}
2007-01-18 03:26:07 +03:00
cleanup :
2006-12-20 18:34:32 +03:00
ZERO_STRUCT ( u ) ;
2006-12-23 00:31:57 +03:00
u . in . domain_dns_name = torture_join_dom_dns_name ( s - > tj ) ;
u . in . domain_netbios_name = torture_join_dom_netbios_name ( s - > tj ) ;
2007-08-28 04:16:58 +04:00
u . in . source_dsa_address = torture_setting_string ( torture , " host " , NULL ) ;
2007-02-23 13:25:28 +03:00
u . in . dest_dsa_netbios_name = s - > netbios_name ;
2006-12-13 02:23:50 +03:00
2006-12-23 00:31:57 +03:00
status = libnet_UnbecomeDC ( s - > ctx , s , & u ) ;
2006-12-13 02:23:50 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
printf ( " libnet_UnbecomeDC() failed - %s \n " , nt_errstr ( status ) ) ;
2007-10-07 02:28:14 +04:00
ret = false ;
2006-12-13 02:23:50 +03:00
}
/* Leave domain. */
2008-06-14 19:24:17 +04:00
torture_leave_domain ( torture , s - > tj ) ;
2006-12-23 00:31:57 +03:00
talloc_free ( s ) ;
2006-12-13 02:23:50 +03:00
return ret ;
}