2022-01-25 23:09:54 +03:00
/*
2005-05-02 18:17:19 +04:00
Unix SMB / CIFS implementation .
2022-01-25 23:09:54 +03:00
2008-04-09 06:02:11 +04:00
Extract the user / system database from a remote server
2005-05-21 10:31:02 +04:00
2008-04-09 06:02:11 +04:00
Copyright ( C ) Stefan Metzmacher 2004 - 2006
Copyright ( C ) Brad Henry 2005
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2005 - 2008
2022-01-25 23:09:54 +03:00
2005-05-02 18:17:19 +04: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
2005-05-02 18:17:19 +04:00
( at your option ) any later version .
2022-01-25 23:09:54 +03:00
2005-05-02 18:17:19 +04:00
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 .
2022-01-25 23:09:54 +03:00
2005-05-02 18:17:19 +04:00
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/>.
2005-05-02 18:17:19 +04:00
*/
# include "includes.h"
# include "libnet/libnet.h"
2008-04-09 06:02:11 +04:00
# include "lib/events/events.h"
# include "dsdb/samdb/samdb.h"
2008-10-11 23:31:42 +04:00
# include "../lib/util/dlinklist.h"
2011-02-10 06:12:51 +03:00
# include <ldb.h>
# include <ldb_errors.h>
2008-04-09 06:02:11 +04:00
# 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"
2010-06-16 15:43:38 +04:00
# include "ldb_wrap.h"
2008-04-09 06:02:11 +04:00
# include "auth/auth.h"
2010-04-29 02:51:01 +04:00
# include "auth/credentials/credentials.h"
2007-09-28 05:17:46 +04:00
# include "param/param.h"
2008-04-09 08:59:32 +04:00
# include "param/provision.h"
2010-09-20 11:42:13 +04:00
# include "libcli/security/security.h"
2010-08-02 17:47:38 +04:00
# include "dsdb/common/util.h"
2005-05-21 09:05:44 +04:00
2017-09-06 07:37:34 +03:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_DRS_REPL
2022-01-25 23:09:54 +03:00
/*
2008-04-09 06:02:11 +04:00
List of tasks vampire . py must perform :
- Domain Join
- but don ' t write the secrets . ldb
- results for this should be enough to handle the provision
2022-01-25 23:09:54 +03:00
- if vampire method is samsync
- Provision using these results
2008-04-09 06:02:11 +04:00
- do we still want to support this NT4 technology ?
- Start samsync with libnet code
2022-01-25 23:09:54 +03:00
- provision in the callback
2008-04-09 06:02:11 +04:00
- Write out the secrets database , using the code from libnet_Join
*/
2010-06-12 11:22:20 +04:00
struct libnet_vampire_cb_state {
2008-04-09 06:02:11 +04:00
const char * netbios_name ;
2010-06-12 11:22:20 +04:00
const char * domain_name ;
const char * realm ;
2008-04-09 06:02:11 +04:00
struct cli_credentials * machine_account ;
2010-06-12 05:05:47 +04:00
/* Schema loaded from local LDIF files */
2010-06-09 14:52:02 +04:00
struct dsdb_schema * provision_schema ;
2010-06-12 05:05:47 +04:00
/* 1st pass, with some OIDs/attribute names/class names not
* converted , because we may not know them yet */
struct dsdb_schema * self_made_schema ;
/* prefixMap in LDB format, from the remote DRS server */
2010-06-09 15:53:01 +04:00
DATA_BLOB prefixmap_blob ;
2008-04-09 06:02:11 +04:00
const struct dsdb_schema * schema ;
struct ldb_context * ldb ;
2005-05-21 09:05:44 +04:00
2008-04-09 06:02:11 +04:00
struct {
uint32_t object_count ;
struct drsuapi_DsReplicaObjectListItemEx * first_object ;
struct drsuapi_DsReplicaObjectListItemEx * last_object ;
} schema_part ;
const char * targetdir ;
struct loadparm_context * lp_ctx ;
2008-12-29 22:24:57 +03:00
struct tevent_context * event_ctx ;
2009-09-03 12:31:45 +04:00
unsigned total_objects ;
libnet/drs: Update replication debug to report link progress
Update the replication debug (for joins/backups) so that it's easier to
see how far through syncing the links we are. E.g. with 150,000 links,
you just get screeds of debug like this, with no real idea how far
through the replication is.
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
This patch now applies to links the same debug logic we use for objects,
and changes it to look like:
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[57024/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[58524/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[60024/150024]
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-12 03:29:32 +03:00
unsigned total_links ;
2009-09-03 12:31:45 +04:00
char * last_partition ;
2010-08-02 17:47:38 +04:00
const char * server_dn_str ;
2008-04-09 06:02:11 +04:00
} ;
2010-08-24 09:40:42 +04:00
/* initialise a state structure ready for replication of chunks */
void * libnet_vampire_replicate_init ( TALLOC_CTX * mem_ctx ,
struct ldb_context * samdb ,
struct loadparm_context * lp_ctx )
{
struct libnet_vampire_cb_state * s = talloc_zero ( mem_ctx , struct libnet_vampire_cb_state ) ;
if ( ! s ) {
return NULL ;
}
s - > ldb = samdb ;
s - > lp_ctx = lp_ctx ;
s - > provision_schema = dsdb_get_schema ( s - > ldb , s ) ;
2010-09-07 09:25:45 +04:00
s - > schema = s - > provision_schema ;
2010-09-15 12:50:09 +04:00
s - > netbios_name = lpcfg_netbios_name ( lp_ctx ) ;
s - > domain_name = lpcfg_workgroup ( lp_ctx ) ;
s - > realm = lpcfg_realm ( lp_ctx ) ;
2010-08-24 09:40:42 +04:00
return s ;
}
2010-06-12 11:22:20 +04:00
/* Caller is expected to keep supplied pointers around for the lifetime of the structure */
void * libnet_vampire_cb_state_init ( TALLOC_CTX * mem_ctx ,
struct loadparm_context * lp_ctx , struct tevent_context * event_ctx ,
const char * netbios_name , const char * domain_name , const char * realm ,
const char * targetdir )
{
struct libnet_vampire_cb_state * s = talloc_zero ( mem_ctx , struct libnet_vampire_cb_state ) ;
if ( ! s ) {
return NULL ;
}
s - > lp_ctx = lp_ctx ;
s - > event_ctx = event_ctx ;
s - > netbios_name = netbios_name ;
s - > domain_name = domain_name ;
s - > realm = realm ;
s - > targetdir = targetdir ;
return s ;
}
struct ldb_context * libnet_vampire_cb_ldb ( struct libnet_vampire_cb_state * state )
{
state = talloc_get_type_abort ( state , struct libnet_vampire_cb_state ) ;
return state - > ldb ;
}
struct loadparm_context * libnet_vampire_cb_lp_ctx ( struct libnet_vampire_cb_state * state )
{
state = talloc_get_type_abort ( state , struct libnet_vampire_cb_state ) ;
return state - > lp_ctx ;
}
NTSTATUS libnet_vampire_cb_prepare_db ( void * private_data ,
const struct libnet_BecomeDC_PrepareDB * p )
2005-05-21 09:05:44 +04:00
{
2010-06-12 11:22:20 +04:00
struct libnet_vampire_cb_state * s = talloc_get_type ( private_data , struct libnet_vampire_cb_state ) ;
2008-04-09 06:02:11 +04:00
struct provision_settings settings ;
2008-04-11 13:15:24 +04:00
struct provision_result result ;
2008-04-09 06:02:11 +04:00
NTSTATUS status ;
2005-05-21 09:05:44 +04:00
2009-07-02 08:47:06 +04:00
ZERO_STRUCT ( settings ) ;
2008-04-09 06:02:11 +04: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 ;
settings . netbios_name = p - > dest_dsa - > netbios_name ;
2010-06-12 11:22:20 +04:00
settings . realm = s - > realm ;
settings . domain = s - > domain_name ;
2008-04-09 06:02:11 +04:00
settings . server_dn_str = p - > dest_dsa - > server_dn_str ;
2021-02-23 16:03:25 +03:00
settings . machine_password = generate_random_machine_password ( s , 120 , 120 ) ;
2008-04-09 06:02:11 +04:00
settings . targetdir = s - > targetdir ;
2012-08-21 13:58:18 +04:00
settings . use_ntvfs = true ;
2008-04-11 13:15:24 +04:00
status = provision_bare ( s , s - > lp_ctx , & settings , & result ) ;
2005-05-02 18:17:19 +04:00
2008-04-11 13:15:24 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
2005-05-02 18:17:19 +04:00
}
2010-06-12 11:23:32 +04:00
s - > ldb = talloc_steal ( s , result . samdb ) ;
2010-10-03 05:30:14 +04:00
s - > lp_ctx = talloc_reparent ( talloc_parent ( result . lp_ctx ) , s , result . lp_ctx ) ;
2010-06-09 14:52:02 +04:00
s - > provision_schema = dsdb_get_schema ( s - > ldb , s ) ;
2010-08-02 17:47:38 +04:00
s - > server_dn_str = talloc_steal ( s , p - > dest_dsa - > server_dn_str ) ;
2008-04-09 06:02:11 +04:00
2009-09-02 10:57:25 +04:00
/* wrap the entire vapire operation in a transaction. This
isn ' t just cosmetic - we use this to ensure that linked
attribute back links are added at the end by relying on a
transaction commit hook in the linked attributes module . We
need to do this as the order of objects coming from the
server is not sufficiently deterministic to know that the
record that a backlink needs to be created in has itself
been created before the object containing the forward link
has come over the wire */
if ( ldb_transaction_start ( s - > ldb ) ! = LDB_SUCCESS ) {
return NT_STATUS_FOOBAR ;
}
2008-04-09 06:02:11 +04:00
return NT_STATUS_OK ;
}
2010-06-12 11:22:20 +04:00
NTSTATUS libnet_vampire_cb_check_options ( void * private_data ,
const struct libnet_BecomeDC_CheckOptions * o )
2008-04-09 06:02:11 +04:00
{
2010-06-12 11:22:20 +04:00
struct libnet_vampire_cb_state * s = talloc_get_type ( private_data , struct libnet_vampire_cb_state ) ;
2008-04-09 06:02:11 +04:00
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 "
2022-01-25 23:09:54 +03:00
" \t domain w2k3_update_revision[%u] \n " ,
2008-04-09 06:02:11 +04:00
o - > forest - > crossref_behavior_version ,
o - > forest - > schema_object_version ,
o - > domain - > behavior_version ,
o - > domain - > w2k3_update_revision ) ) ;
return NT_STATUS_OK ;
}
2016-10-31 06:19:37 +03:00
static WERROR libnet_vampire_cb_apply_schema ( struct libnet_vampire_cb_state * s ,
const struct libnet_BecomeDC_StoreChunk * c )
2008-04-09 06:02:11 +04:00
{
WERROR status ;
2010-11-10 04:45:22 +03:00
struct dsdb_schema_prefixmap * pfm_remote ;
2008-04-09 06:02:11 +04:00
const struct drsuapi_DsReplicaOIDMapping_Ctr * mapping_ctr ;
2010-09-24 23:56:36 +04:00
struct dsdb_schema * provision_schema ;
2010-09-27 02:50:54 +04:00
uint32_t object_count = 0 ;
2008-04-09 06:02:11 +04:00
struct drsuapi_DsReplicaObjectListItemEx * first_object ;
uint32_t linked_attributes_count ;
struct drsuapi_DsReplicaLinkedAttribute * linked_attributes ;
const struct drsuapi_DsReplicaCursor2CtrEx * uptodateness_vector ;
2010-06-12 05:05:47 +04:00
struct dsdb_extended_replicated_objects * schema_objs ;
2008-04-09 06:02:11 +04:00
struct repsFromTo1 * s_dsa ;
char * tmp_dns_name ;
2010-06-10 15:33:45 +04:00
struct ldb_context * schema_ldb ;
2016-03-21 05:49:33 +03:00
struct ldb_dn * partition_dn ;
2008-04-09 06:02:11 +04:00
struct ldb_message * msg ;
struct ldb_message_element * prefixMap_el ;
uint32_t i ;
2013-05-18 01:18:55 +04:00
int ret ;
2008-04-09 06:02:11 +04:00
bool ok ;
2016-07-26 02:54:07 +03:00
uint64_t seq_num = 0 ;
2013-05-18 01:18:55 +04:00
uint32_t cycle_before_switching ;
2008-04-09 06:02:11 +04:00
DEBUG ( 0 , ( " Analyze and apply schema objects \n " ) ) ;
s_dsa = talloc_zero ( s , struct repsFromTo1 ) ;
2016-10-31 06:19:37 +03:00
if ( s_dsa = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
s_dsa - > other_info = talloc ( s_dsa , struct repsFromTo1OtherInfo ) ;
2016-10-31 06:19:37 +03:00
if ( s_dsa - > other_info = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
switch ( c - > ctr_level ) {
case 1 :
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 */
break ;
case 6 :
mapping_ctr = & c - > ctr6 - > mapping_ctr ;
object_count = s - > schema_part . object_count ;
first_object = s - > schema_part . first_object ;
2009-09-03 12:31:45 +04:00
linked_attributes_count = c - > ctr6 - > linked_attributes_count ;
linked_attributes = c - > ctr6 - > linked_attributes ;
2008-04-09 06:02:11 +04:00
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 ;
break ;
default :
2016-10-31 06:19:37 +03:00
return WERR_INVALID_PARAMETER ;
2008-04-09 06:02:11 +04:00
}
2012-12-31 14:12:23 +04:00
/* We must set these up to ensure the replMetaData is written
* correctly , before our NTDS Settings entry is replicated */
ok = samdb_set_ntds_invocation_id ( s - > ldb , & c - > dest_dsa - > invocation_id ) ;
if ( ! ok ) {
DEBUG ( 0 , ( " Failed to set cached ntds invocationId \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2012-12-31 14:12:23 +04:00
}
ok = samdb_set_ntds_objectGUID ( s - > ldb , & c - > dest_dsa - > ntds_guid ) ;
if ( ! ok ) {
DEBUG ( 0 , ( " Failed to set cached ntds objectGUID \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2012-12-31 14:12:23 +04:00
}
2010-11-10 04:45:22 +03:00
status = dsdb_schema_pfm_from_drsuapi_pfm ( mapping_ctr , true ,
s , & pfm_remote , NULL ) ;
if ( ! W_ERROR_IS_OK ( status ) ) {
2023-08-07 07:53:23 +03:00
DEBUG ( 0 , ( __location__ " : Failed to decode remote prefixMap: %s \n " ,
2010-11-10 04:45:22 +03:00
win_errstr ( status ) ) ) ;
2016-10-31 06:19:37 +03:00
return status ;
2010-11-10 04:45:22 +03:00
}
2010-01-17 13:59:56 +03:00
s_dsa - > replica_flags = DRSUAPI_DRS_WRIT_REP
| DRSUAPI_DRS_INIT_SYNC
| DRSUAPI_DRS_PER_SYNC ;
2008-04-09 06:02:11 +04:00
memset ( s_dsa - > schedule , 0x11 , sizeof ( s_dsa - > schedule ) ) ;
tmp_dns_name = GUID_string ( s_dsa - > other_info , & s_dsa - > source_dsa_obj_guid ) ;
2016-10-31 06:19:37 +03:00
if ( tmp_dns_name = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
tmp_dns_name = talloc_asprintf_append_buffer ( tmp_dns_name , " ._msdcs.%s " , c - > forest - > dns_name ) ;
2016-10-31 06:19:37 +03:00
if ( tmp_dns_name = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
s_dsa - > other_info - > dns_name = tmp_dns_name ;
2012-10-08 08:46:38 +04:00
if ( s - > self_made_schema = = NULL ) {
DEBUG ( 0 , ( " libnet_vampire_cb_apply_schema: called with out self_made_schema \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2012-10-08 08:46:38 +04:00
}
2011-11-14 11:52:51 +04:00
schema_ldb = provision_get_schema ( s , s - > lp_ctx ,
c - > forest - > schema_dn_str ,
& s - > prefixmap_blob ) ;
2010-06-10 15:33:45 +04:00
if ( ! schema_ldb ) {
2010-09-24 23:56:36 +04:00
DEBUG ( 0 , ( " Failed to re-load from local provision using remote prefixMap. "
" Will continue with local prefixMap \n " ) ) ;
provision_schema = dsdb_get_schema ( s - > ldb , s ) ;
2010-06-10 15:33:45 +04:00
} else {
2010-09-24 23:56:36 +04:00
provision_schema = dsdb_get_schema ( schema_ldb , s ) ;
2017-11-22 02:34:01 +03:00
ret = dsdb_reference_schema ( s - > ldb , provision_schema , SCHEMA_MEMORY_ONLY ) ;
2010-06-10 15:33:45 +04:00
if ( ret ! = LDB_SUCCESS ) {
2023-08-07 07:53:23 +03:00
DEBUG ( 0 , ( " Failed to attach schema from local provision using remote prefixMap. \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2010-06-10 15:33:45 +04:00
}
2019-02-15 13:04:23 +03:00
talloc_unlink ( s , schema_ldb ) ;
2010-06-10 15:33:45 +04:00
}
2013-05-18 01:18:55 +04:00
cycle_before_switching = lpcfg_parm_long ( s - > lp_ctx , NULL ,
" become dc " ,
" schema convert retrial " , 1 ) ;
2016-08-08 13:11:53 +03:00
provision_schema - > resolving_in_progress = true ;
s - > self_made_schema - > resolving_in_progress = true ;
2016-08-04 06:20:27 +03:00
status = dsdb_repl_resolve_working_schema ( s - > ldb ,
2013-05-18 01:18:55 +04:00
pfm_remote ,
cycle_before_switching ,
provision_schema ,
s - > self_made_schema ,
object_count ,
first_object ) ;
if ( ! W_ERROR_IS_OK ( status ) ) {
2023-08-07 07:53:23 +03:00
DEBUG ( 0 , ( " %s: dsdb_repl_resolve_working_schema() failed: %s \n " ,
2013-05-18 01:18:55 +04:00
__location__ , win_errstr ( status ) ) ) ;
2016-10-31 06:19:37 +03:00
return status ;
2010-09-24 23:56:36 +04:00
}
2010-06-09 14:52:02 +04:00
2010-09-24 23:56:36 +04:00
/* free temp objects for 1st conversion phase */
talloc_unlink ( s , provision_schema ) ;
2005-05-02 18:17:19 +04:00
2016-08-08 13:11:53 +03:00
s - > self_made_schema - > resolving_in_progress = false ;
2010-09-24 23:56:36 +04:00
/*
* attach the schema we just brought over DRS to the ldb ,
* so we can use it in dsdb_convert_object_ex below
*/
2017-11-22 02:34:01 +03:00
ret = dsdb_set_schema ( s - > ldb , s - > self_made_schema , SCHEMA_WRITE ) ;
2008-04-09 06:02:11 +04:00
if ( ret ! = LDB_SUCCESS ) {
2010-09-24 23:56:36 +04:00
DEBUG ( 0 , ( " Failed to attach working schema from DRS. \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2008-04-09 06:02:11 +04:00
}
2010-06-09 12:57:52 +04:00
2008-04-09 06:02:11 +04:00
/* we don't want to access the self made schema anymore */
2010-09-24 23:56:36 +04:00
s - > schema = s - > self_made_schema ;
s - > self_made_schema = NULL ;
2008-04-09 06:02:11 +04:00
2016-03-21 05:49:33 +03:00
partition_dn = ldb_dn_new ( s , s - > ldb , c - > partition - > nc . dn ) ;
if ( partition_dn = = NULL ) {
DEBUG ( 0 , ( " Failed to parse partition DN from DRS. \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INVALID_PARAMETER ;
2016-03-21 05:49:33 +03:00
}
2010-06-12 05:05:47 +04:00
/* Now convert the schema elements again, using the schema we finalised, ready to actually import */
2010-11-08 00:04:33 +03:00
status = dsdb_replicated_objects_convert ( s - > ldb ,
2010-11-26 03:38:39 +03:00
s - > schema ,
2016-03-21 05:49:33 +03:00
partition_dn ,
2010-11-08 00:04:33 +03:00
mapping_ctr ,
object_count ,
first_object ,
linked_attributes_count ,
linked_attributes ,
s_dsa ,
uptodateness_vector ,
c - > gensec_skey ,
2011-09-23 11:35:48 +04:00
0 ,
2010-11-08 00:04:33 +03:00
s , & schema_objs ) ;
2008-04-09 06:02:11 +04:00
if ( ! W_ERROR_IS_OK ( status ) ) {
2010-06-09 15:53:01 +04:00
DEBUG ( 0 , ( " Failed to convert objects when trying to import over DRS (2nd pass, to store remote schema): %s \n " , win_errstr ( status ) ) ) ;
2016-10-31 06:19:37 +03:00
return status ;
2008-04-09 06:02:11 +04:00
}
2005-05-21 10:31:02 +04:00
2010-07-16 08:32:42 +04:00
if ( lpcfg_parm_bool ( s - > lp_ctx , NULL , " become dc " , " dump objects " , false ) ) {
2010-06-12 05:05:47 +04:00
for ( i = 0 ; i < schema_objs - > num_objects ; i + + ) {
2008-04-09 06:02:11 +04:00
struct ldb_ldif ldif ;
fprintf ( stdout , " # \n " ) ;
ldif . changetype = LDB_CHANGETYPE_NONE ;
2010-06-12 05:05:47 +04:00
ldif . msg = schema_objs - > objects [ i ] . msg ;
2008-04-09 06:02:11 +04:00
ldb_ldif_write_file ( s - > ldb , stdout , & ldif ) ;
2010-06-12 05:05:47 +04:00
NDR_PRINT_DEBUG ( replPropertyMetaDataBlob , schema_objs - > objects [ i ] . meta_data ) ;
2008-04-09 06:02:11 +04:00
}
}
2010-12-10 03:55:30 +03:00
status = dsdb_replicated_objects_commit ( s - > ldb , NULL , schema_objs , & seq_num ) ;
2009-11-09 13:26:02 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
DEBUG ( 0 , ( " Failed to commit objects: %s \n " , win_errstr ( status ) ) ) ;
2016-10-31 06:19:37 +03:00
return status ;
2009-11-09 13:26:02 +03:00
}
2010-06-12 05:05:47 +04:00
msg = ldb_msg_new ( schema_objs ) ;
2016-10-31 06:19:37 +03:00
if ( msg = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2010-06-12 05:05:47 +04:00
msg - > dn = schema_objs - > partition_dn ;
/* We must ensure a prefixMap has been written. Unlike other
* attributes ( including schemaInfo ) , it is not replicated in
* the normal replication stream . We can use the one from
* s - > prefixmap_blob because we operate with one , unchanging
* prefixMap for this entire operation . */
ret = ldb_msg_add_value ( msg , " prefixMap " , & s - > prefixmap_blob , & prefixMap_el ) ;
2008-04-09 06:02:11 +04:00
if ( ret ! = LDB_SUCCESS ) {
2016-10-31 06:19:37 +03:00
return WERR_NOT_ENOUGH_MEMORY ;
2008-04-09 06:02:11 +04:00
}
2010-06-12 05:05:47 +04:00
/* We want to know if a prefixMap was written already, as it
* would mean that the above comment was not true , and we have
* somehow updated the prefixMap during this transaction */
prefixMap_el - > flags = LDB_FLAG_MOD_ADD ;
2008-04-09 06:02:11 +04:00
2011-11-14 11:54:18 +04:00
ret = dsdb_modify ( s - > ldb , msg , DSDB_FLAG_AS_SYSTEM ) ;
2008-04-09 06:02:11 +04:00
if ( ret ! = LDB_SUCCESS ) {
2010-06-12 05:05:47 +04:00
DEBUG ( 0 , ( " Failed to add prefixMap: %s \n " , ldb_errstring ( s - > ldb ) ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2008-04-09 06:02:11 +04:00
}
talloc_free ( s_dsa ) ;
2010-06-12 05:05:47 +04:00
talloc_free ( schema_objs ) ;
2008-04-09 06:02:11 +04:00
2010-03-16 06:52:39 +03:00
s - > schema = dsdb_get_schema ( s - > ldb , s ) ;
2008-04-09 06:02:11 +04:00
if ( ! s - > schema ) {
DEBUG ( 0 , ( " Failed to get loaded dsdb_schema \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2008-04-09 06:02:11 +04:00
}
2005-05-21 10:31:02 +04:00
2016-10-31 06:19:37 +03:00
return WERR_OK ;
2005-05-21 10:31:02 +04:00
}
2016-10-31 06:19:37 +03:00
WERROR libnet_vampire_cb_schema_chunk ( void * private_data ,
const struct libnet_BecomeDC_StoreChunk * c )
2005-05-03 18:38:14 +04:00
{
2010-06-12 11:22:20 +04:00
struct libnet_vampire_cb_state * s = talloc_get_type ( private_data , struct libnet_vampire_cb_state ) ;
2016-10-31 06:19:37 +03:00
WERROR werr ;
2008-04-09 06:02:11 +04:00
const struct drsuapi_DsReplicaOIDMapping_Ctr * mapping_ctr ;
2008-07-15 18:59:09 +04:00
uint32_t nc_object_count ;
2011-10-23 17:01:29 +04:00
uint32_t nc_total_received = 0 ;
2008-04-09 06:02:11 +04: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 ;
2008-04-09 06:02:11 +04: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 ;
2005-05-03 18:38:14 +04:00
break ;
2008-04-09 06:02:11 +04:00
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 ;
2005-05-21 10:31:02 +04:00
break ;
2005-07-25 05:19:16 +04:00
default :
2016-10-31 06:19:37 +03:00
return WERR_INVALID_PARAMETER ;
2005-05-03 18:38:14 +04:00
}
2005-05-02 18:17:19 +04:00
2011-10-23 17:01:29 +04:00
if ( ! s - > schema_part . first_object ) {
nc_total_received = object_count ;
} else {
nc_total_received = s - > schema_part . object_count + object_count ;
}
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 " ,
2011-10-23 17:01:29 +04:00
c - > partition - > nc . dn , nc_total_received , nc_object_count ,
2008-07-16 15:02:54 +04:00
linked_attributes_count , nc_linked_attributes_count ) ) ;
2008-04-09 06:02:11 +04:00
} else {
2009-09-26 07:47:06 +04:00
DEBUG ( 0 , ( " Schema-DN[%s] objects[%u] linked_values[%u] \n " ,
2011-10-23 17:01:29 +04:00
c - > partition - > nc . dn , nc_total_received , linked_attributes_count ) ) ;
2008-04-09 06:02:11 +04:00
}
2010-06-12 05:05:47 +04:00
if ( ! s - > self_made_schema ) {
2010-06-10 15:33:45 +04:00
struct drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr_without_schema_info ;
2010-06-09 15:53:01 +04:00
/* Put the DRS prefixmap aside for the schema we are
* about to load in the provision , and into the one we
* are making with the help of DRS */
2010-06-10 15:33:45 +04:00
mapping_ctr_without_schema_info = * mapping_ctr ;
/* This strips off the 0xFF schema info from the end,
* because we don ' t want it in the blob */
if ( mapping_ctr_without_schema_info . num_mappings > 0 ) {
mapping_ctr_without_schema_info . num_mappings - - ;
}
werr = dsdb_get_drsuapi_prefixmap_as_blob ( & mapping_ctr_without_schema_info , s , & s - > prefixmap_blob ) ;
2010-06-09 15:53:01 +04:00
if ( ! W_ERROR_IS_OK ( werr ) ) {
2016-10-31 06:19:37 +03:00
return werr ;
2010-06-09 15:53:01 +04:00
}
2010-06-12 05:05:47 +04:00
/* Set up two manually-constructed schema - the local
* schema from the provision will be used to build
* one , which will then in turn be used to build the
* other . */
2010-05-09 19:20:01 +04:00
s - > self_made_schema = dsdb_new_schema ( s ) ;
2016-10-31 06:19:37 +03:00
if ( s - > self_made_schema = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
2016-10-31 06:19:37 +03:00
werr = dsdb_load_prefixmap_from_drsuapi ( s - > self_made_schema , mapping_ctr ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
return werr ;
2005-07-25 06:23:41 +04:00
}
2008-04-09 06:02:11 +04:00
} else {
2016-10-31 06:19:37 +03:00
werr = dsdb_schema_pfm_contains_drsuapi_pfm ( s - > self_made_schema - > prefixmap , mapping_ctr ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
return werr ;
2005-07-25 06:23:41 +04:00
}
2008-04-09 06:02:11 +04:00
}
if ( ! s - > schema_part . first_object ) {
s - > schema_part . object_count = object_count ;
s - > schema_part . first_object = talloc_steal ( s , first_object ) ;
2005-07-25 06:23:41 +04:00
} else {
2008-04-09 06:02:11 +04:00
s - > schema_part . object_count + = object_count ;
s - > schema_part . last_object - > next_object = talloc_steal ( s - > schema_part . last_object ,
first_object ) ;
2005-05-02 18:17:19 +04:00
}
2019-03-12 01:16:38 +03:00
if ( first_object ! = NULL ) {
for ( cur = first_object ; cur - > next_object ; cur = cur - > next_object ) { }
} else {
cur = first_object ;
}
2008-04-09 06:02:11 +04:00
s - > schema_part . last_object = cur ;
2005-07-25 06:23:41 +04:00
2008-07-16 15:01:56 +04:00
if ( ! c - > partition - > more_data ) {
2010-06-12 11:22:20 +04:00
return libnet_vampire_cb_apply_schema ( s , c ) ;
2005-05-02 18:17:19 +04:00
}
2016-10-31 06:19:37 +03:00
return WERR_OK ;
2008-04-09 06:02:11 +04:00
}
2016-10-31 06:19:37 +03:00
WERROR libnet_vampire_cb_store_chunk ( void * private_data ,
const struct libnet_BecomeDC_StoreChunk * c )
2008-04-09 06:02:11 +04:00
{
2010-06-12 11:22:20 +04:00
struct libnet_vampire_cb_state * s = talloc_get_type ( private_data , struct libnet_vampire_cb_state ) ;
2008-04-09 06:02:11 +04:00
WERROR status ;
2010-11-26 03:38:39 +03:00
struct dsdb_schema * schema ;
2008-04-09 06:02:11 +04:00
const struct drsuapi_DsReplicaOIDMapping_Ctr * mapping_ctr ;
2008-07-15 18:59:09 +04:00
uint32_t nc_object_count ;
2008-04-09 06:02:11 +04:00
uint32_t object_count ;
struct drsuapi_DsReplicaObjectListItemEx * first_object ;
2008-07-16 15:02:54 +04:00
uint32_t nc_linked_attributes_count ;
2008-04-09 06:02:11 +04:00
uint32_t linked_attributes_count ;
struct drsuapi_DsReplicaLinkedAttribute * linked_attributes ;
const struct drsuapi_DsReplicaCursor2CtrEx * uptodateness_vector ;
struct dsdb_extended_replicated_objects * objs ;
2011-08-09 14:23:29 +04:00
uint32_t req_replica_flags ;
2015-08-19 04:26:41 +03:00
uint32_t dsdb_repl_flags = 0 ;
2008-04-09 06:02:11 +04:00
struct repsFromTo1 * s_dsa ;
char * tmp_dns_name ;
uint32_t i ;
2022-01-25 23:05:26 +03:00
uint64_t seq_num = 0 ;
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
bool is_exop = false ;
2016-03-21 05:49:33 +03:00
struct ldb_dn * partition_dn = NULL ;
struct ldb_dn * nc_root = NULL ;
2008-04-09 06:02:11 +04:00
s_dsa = talloc_zero ( s , struct repsFromTo1 ) ;
2016-10-31 06:19:37 +03:00
if ( s_dsa = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
s_dsa - > other_info = talloc ( s_dsa , struct repsFromTo1OtherInfo ) ;
2016-10-31 06:19:37 +03:00
if ( s_dsa - > other_info = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
switch ( c - > ctr_level ) {
case 1 :
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? */
2008-04-09 06:02:11 +04: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 ;
2008-04-09 06:02:11 +04: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 */
break ;
case 6 :
mapping_ctr = & c - > ctr6 - > mapping_ctr ;
2008-07-15 18:59:09 +04:00
nc_object_count = c - > ctr6 - > nc_object_count ;
2008-04-09 06:02:11 +04: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 ;
2008-04-09 06:02:11 +04: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 ;
break ;
default :
2016-10-31 06:19:37 +03:00
return WERR_INVALID_PARAMETER ;
2006-01-12 12:33:49 +03:00
}
2011-08-09 14:23:29 +04:00
switch ( c - > req_level ) {
case 0 :
/* none */
req_replica_flags = 0 ;
break ;
case 5 :
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
if ( c - > req5 - > extended_op ! = DRSUAPI_EXOP_NONE ) {
is_exop = true ;
}
2011-08-09 14:23:29 +04:00
req_replica_flags = c - > req5 - > replica_flags ;
break ;
case 8 :
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
if ( c - > req8 - > extended_op ! = DRSUAPI_EXOP_NONE ) {
is_exop = true ;
}
2011-08-09 14:23:29 +04:00
req_replica_flags = c - > req8 - > replica_flags ;
break ;
case 10 :
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
if ( c - > req10 - > extended_op ! = DRSUAPI_EXOP_NONE ) {
is_exop = true ;
}
2011-08-09 14:23:29 +04:00
req_replica_flags = c - > req10 - > replica_flags ;
replmd: Don't fail cycle if we get link for deleted object with GET_TGT
We are going to end up supporting 2 different server schemes:
A. the old/default behaviour of sending all the linked attributes last,
at the end of the replication cycle.
B. the new/Microsoft way of sending the linked attributes interleaved
with the source/target objects.
Normally if we're talking to a server using the old scheme-A, we won't
ever use the GET_TGT flag. However, there are a couple of cases where
it can happen:
- A link to a new object was added during the replication cycle.
- An object was deleted while the replication was in progress (and
the linked attribute got queued before the object was deleted).
Talking to an Samba DC running the old scheme will just cause it to
start the replication cycle from scratch again, which is fairly
harmless. However, there is a chance that the same thing can happen
again, in which case the replication cycle will fail (because GET_TGT
was already set).
Even if we're using the new scheme (B), we could still potentially hit
this case, as we can still queue up linked attributes between requests
(group memberships can be larger than what can fit into a single
replication chunk).
If GET_TGT is set in the GetNcChanges request, then the local copy of
the target object should always be up-to-date when we process the linked
attribute. So if we still think the target object is deleted/recycled at
this point, then it's safe to ignore the linked attribute (because we
know our local copy is up-to-date). This logic matches the MS spec logic
in ProcessLinkValue().
Not failing the replication cycle may be beneficial if we're trying to
do a full-sync of a large database. Otherwise it might be time-consuming
and frustrating to repeat the sync unnecessarily.
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12972
2017-07-20 02:14:27 +03:00
if ( c - > req10 - > more_flags & DRSUAPI_DRS_GET_TGT ) {
dsdb_repl_flags | = DSDB_REPL_FLAG_TARGETS_UPTODATE ;
}
2011-08-09 14:23:29 +04:00
break ;
default :
2016-10-31 06:19:37 +03:00
return WERR_INVALID_PARAMETER ;
2011-08-09 14:23:29 +04:00
}
2019-07-01 08:06:31 +03:00
/*
* If the peer DC doesn ' t support GET_TGT ( req v10 ) , then the link
* targets are as up - to - date as they ' re ever gonna be . ( Without this ,
* cases where we ' d normally retry with GET_TGT cause the join to fail )
*/
if ( c - > req_level < 10 ) {
dsdb_repl_flags | = DSDB_REPL_FLAG_TARGETS_UPTODATE ;
}
2017-02-23 03:00:19 +03:00
if ( req_replica_flags & DRSUAPI_DRS_CRITICAL_ONLY | | is_exop ) {
2011-08-09 14:23:29 +04:00
/*
2017-02-23 03:00:19 +03:00
* If we only replicate the critical objects , or this
* is an exop we should not remember what we already
2011-08-09 14:23:29 +04:00
* got , as it is incomplete .
*/
ZERO_STRUCT ( s_dsa - > highwatermark ) ;
uptodateness_vector = NULL ;
2017-06-14 02:35:36 +03:00
dsdb_repl_flags | = DSDB_REPL_FLAG_OBJECT_SUBSET ;
2011-08-09 14:23:29 +04:00
}
/* TODO: avoid hardcoded flags */
2010-01-17 13:59:56 +03:00
s_dsa - > replica_flags = DRSUAPI_DRS_WRIT_REP
| DRSUAPI_DRS_INIT_SYNC
| DRSUAPI_DRS_PER_SYNC ;
2008-04-09 06:02:11 +04:00
memset ( s_dsa - > schedule , 0x11 , sizeof ( s_dsa - > schedule ) ) ;
tmp_dns_name = GUID_string ( s_dsa - > other_info , & s_dsa - > source_dsa_obj_guid ) ;
2016-10-31 06:19:37 +03:00
if ( tmp_dns_name = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
tmp_dns_name = talloc_asprintf_append_buffer ( tmp_dns_name , " ._msdcs.%s " , c - > forest - > dns_name ) ;
2016-10-31 06:19:37 +03:00
if ( tmp_dns_name = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
2008-04-09 06:02:11 +04:00
s_dsa - > other_info - > dns_name = tmp_dns_name ;
2009-09-03 12:31:45 +04:00
/* we want to show a count per partition */
if ( ! s - > last_partition | | strcmp ( s - > last_partition , c - > partition - > nc . dn ) ! = 0 ) {
s - > total_objects = 0 ;
libnet/drs: Update replication debug to report link progress
Update the replication debug (for joins/backups) so that it's easier to
see how far through syncing the links we are. E.g. with 150,000 links,
you just get screeds of debug like this, with no real idea how far
through the replication is.
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
This patch now applies to links the same debug logic we use for objects,
and changes it to look like:
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[57024/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[58524/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[60024/150024]
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-12 03:29:32 +03:00
s - > total_links = 0 ;
2009-09-03 12:31:45 +04:00
talloc_free ( s - > last_partition ) ;
s - > last_partition = talloc_strdup ( s , c - > partition - > nc . dn ) ;
}
s - > total_objects + = object_count ;
libnet/drs: Update replication debug to report link progress
Update the replication debug (for joins/backups) so that it's easier to
see how far through syncing the links we are. E.g. with 150,000 links,
you just get screeds of debug like this, with no real idea how far
through the replication is.
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
This patch now applies to links the same debug logic we use for objects,
and changes it to look like:
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[57024/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[58524/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[60024/150024]
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-12 03:29:32 +03:00
s - > total_links + = linked_attributes_count ;
2009-09-03 12:31:45 +04:00
2017-04-12 16:12:49 +03:00
partition_dn = ldb_dn_new ( s_dsa , s - > ldb , c - > partition - > nc . dn ) ;
2016-03-21 05:49:33 +03:00
if ( partition_dn = = NULL ) {
DEBUG ( 0 , ( " Failed to parse partition DN from DRS. \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INVALID_PARAMETER ;
2016-03-21 05:49:33 +03:00
}
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
if ( is_exop ) {
2016-03-21 05:49:33 +03:00
int ret ;
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
if ( nc_object_count ) {
DEBUG ( 0 , ( " Exop on[%s] objects[%u/%u] linked_values[%u/%u] \n " ,
c - > partition - > nc . dn , s - > total_objects , nc_object_count ,
libnet/drs: Update replication debug to report link progress
Update the replication debug (for joins/backups) so that it's easier to
see how far through syncing the links we are. E.g. with 150,000 links,
you just get screeds of debug like this, with no real idea how far
through the replication is.
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
This patch now applies to links the same debug logic we use for objects,
and changes it to look like:
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[57024/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[58524/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[60024/150024]
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-12 03:29:32 +03:00
s - > total_links , nc_linked_attributes_count ) ) ;
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
} else {
DEBUG ( 0 , ( " Exop on[%s] objects[%u] linked_values[%u] \n " ,
c - > partition - > nc . dn , s - > total_objects , linked_attributes_count ) ) ;
}
2017-04-12 16:12:49 +03:00
ret = dsdb_find_nc_root ( s - > ldb , s_dsa ,
2016-03-21 05:49:33 +03:00
partition_dn , & nc_root ) ;
if ( ret ! = LDB_SUCCESS ) {
DEBUG ( 0 , ( __location__ " : Failed to find nc_root for %s \n " ,
ldb_dn_get_linearized ( partition_dn ) ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2016-03-21 05:49:33 +03:00
}
2006-01-12 12:33:49 +03:00
} else {
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
if ( nc_object_count ) {
DEBUG ( 0 , ( " Partition[%s] objects[%u/%u] linked_values[%u/%u] \n " ,
c - > partition - > nc . dn , s - > total_objects , nc_object_count ,
libnet/drs: Update replication debug to report link progress
Update the replication debug (for joins/backups) so that it's easier to
see how far through syncing the links we are. E.g. with 150,000 links,
you just get screeds of debug like this, with no real idea how far
through the replication is.
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
This patch now applies to links the same debug logic we use for objects,
and changes it to look like:
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[57024/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[58524/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[60024/150024]
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-12 03:29:32 +03:00
s - > total_links , nc_linked_attributes_count ) ) ;
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
} else {
DEBUG ( 0 , ( " Partition[%s] objects[%u] linked_values[%u] \n " ,
libnet/drs: Update replication debug to report link progress
Update the replication debug (for joins/backups) so that it's easier to
see how far through syncing the links we are. E.g. with 150,000 links,
you just get screeds of debug like this, with no real idea how far
through the replication is.
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[1500/150024]
This patch now applies to links the same debug logic we use for objects,
and changes it to look like:
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[57024/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[58524/150024]
Partition[DC=addom,DC=samba,DC=example,DC=com] objects[11816/11720]
linked_values[60024/150024]
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-12 03:29:32 +03:00
c - > partition - > nc . dn , s - > total_objects , s - > total_links ) ) ;
libnet-vampire: reports Exops as they rather than sync on some partitions
Instead of showing:
Partition[CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com]
objects[1] linked_values[8]
Report a exop based on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com
as
Exop on CN=RODC,OU=Domain Controllers,DC=samba,DC=example,DC=com, ...
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-By: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed Jan 9 09:01:30 CET 2013 on sn-devel-104
2013-01-01 03:38:50 +04:00
}
2016-03-21 05:49:33 +03:00
nc_root = partition_dn ;
2006-01-12 12:33:49 +03:00
}
2008-04-09 06:02:11 +04:00
2009-09-03 12:31:45 +04:00
2010-11-26 03:38:39 +03:00
schema = dsdb_get_schema ( s - > ldb , NULL ) ;
if ( ! schema ) {
DEBUG ( 0 , ( __location__ " : Schema is not loaded yet! \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2010-11-26 03:38:39 +03:00
}
2015-08-19 04:30:55 +03:00
if ( req_replica_flags & DRSUAPI_DRS_FULL_SYNC_IN_PROGRESS ) {
dsdb_repl_flags | = DSDB_REPL_FLAG_PRIORITISE_INCOMING ;
}
2015-08-19 04:26:41 +03:00
if ( req_replica_flags & DRSUAPI_DRS_SPECIAL_SECRET_PROCESSING ) {
dsdb_repl_flags | = DSDB_REPL_FLAG_EXPECT_NO_SECRETS ;
}
2010-11-08 00:04:33 +03:00
status = dsdb_replicated_objects_convert ( s - > ldb ,
2010-11-26 03:38:39 +03:00
schema ,
2016-03-21 05:49:33 +03:00
nc_root ,
2010-11-08 00:04:33 +03:00
mapping_ctr ,
object_count ,
first_object ,
linked_attributes_count ,
linked_attributes ,
s_dsa ,
uptodateness_vector ,
c - > gensec_skey ,
2015-08-19 04:26:41 +03:00
dsdb_repl_flags ,
2010-11-08 00:04:33 +03:00
s , & objs ) ;
2008-04-09 06:02:11 +04:00
if ( ! W_ERROR_IS_OK ( status ) ) {
2009-11-09 13:26:02 +03:00
DEBUG ( 0 , ( " Failed to convert objects: %s \n " , win_errstr ( status ) ) ) ;
2016-10-31 06:19:37 +03:00
return status ;
2006-01-12 12:33:49 +03:00
}
2008-04-09 06:02:11 +04:00
2010-07-16 08:32:42 +04:00
if ( lpcfg_parm_bool ( s - > lp_ctx , NULL , " become dc " , " dump objects " , false ) ) {
2008-04-09 06:02:11 +04: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-01-13 00:42:26 +03:00
}
2005-05-02 18:17:19 +04:00
}
2010-12-10 03:55:30 +03:00
status = dsdb_replicated_objects_commit ( s - > ldb , NULL , objs , & seq_num ) ;
2009-11-09 13:26:02 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
DEBUG ( 0 , ( " Failed to commit objects: %s \n " , win_errstr ( status ) ) ) ;
2016-10-31 06:19:37 +03:00
return status ;
2009-11-09 13:26:02 +03:00
}
2018-11-05 06:34:15 +03:00
/* reset debug counters once we've finished replicating the partition */
if ( ! c - > partition - > more_data ) {
s - > total_objects = 0 ;
s - > total_links = 0 ;
}
2008-04-09 06:02:11 +04:00
talloc_free ( s_dsa ) ;
talloc_free ( objs ) ;
2005-05-02 18:17:19 +04:00
2008-04-09 06:02:11 +04:00
for ( i = 0 ; i < linked_attributes_count ; i + + ) {
const struct dsdb_attribute * sa ;
2006-01-12 12:33:49 +03:00
2008-04-09 06:02:11 +04:00
if ( ! linked_attributes [ i ] . identifier ) {
2012-04-29 09:12:40 +04:00
DEBUG ( 0 , ( " No linked attribute identifier \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2008-04-09 06:02:11 +04:00
}
2006-01-12 12:33:49 +03:00
2008-04-09 06:02:11 +04:00
if ( ! linked_attributes [ i ] . value . blob ) {
2012-04-29 09:12:40 +04:00
DEBUG ( 0 , ( " No linked attribute value \n " ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2008-04-09 06:02:11 +04:00
}
2005-05-02 18:17:19 +04:00
2008-04-09 06:02:11 +04:00
sa = dsdb_attribute_by_attributeID_id ( s - > schema ,
linked_attributes [ i ] . attid ) ;
if ( ! sa ) {
2012-04-29 09:12:40 +04:00
DEBUG ( 0 , ( " Unable to find attribute via attribute id %d \n " , linked_attributes [ i ] . attid ) ) ;
2016-10-31 06:19:37 +03:00
return WERR_INTERNAL_ERROR ;
2008-04-09 06:02:11 +04:00
}
2005-05-02 18:17:19 +04:00
2010-07-16 08:32:42 +04:00
if ( lpcfg_parm_bool ( s - > lp_ctx , NULL , " become dc " , " dump objects " , false ) ) {
2008-04-09 06:02:11 +04: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 ) ;
}
2005-05-02 18:17:19 +04:00
}
2016-10-31 06:19:37 +03:00
return WERR_OK ;
2008-04-09 06:02:11 +04:00
}