2018-06-21 06:04:00 +03:00
#!/bin/sh
# Does an ldapcmp between a newly restored testenv and the original testenv it
# was based on
if [ $# -lt 2 ] ; then
2022-04-22 16:46:04 +03:00
cat <<EOF
2018-06-21 06:04:00 +03:00
Usage: $0 ORIG_DC_PREFIX RESTORED_DC_PREFIX
EOF
2022-04-22 16:46:04 +03:00
exit 1
2018-06-21 06:04:00 +03:00
fi
ORIG_DC_PREFIX_ABS = " $1 "
RESTORED_DC_PREFIX_ABS = " $2 "
shift 2
2022-04-22 16:46:04 +03:00
. $( dirname $0 ) /subunit.sh
2022-12-22 15:06:55 +03:00
. " $( dirname " ${ 0 } " ) /common_test_fns.inc "
2018-06-21 06:04:00 +03:00
2022-12-22 15:06:55 +03:00
ldbsearch = $( system_or_builddir_binary ldbsearch " ${ BINDIR } " )
2022-12-04 21:46:36 +03:00
2022-04-22 16:46:04 +03:00
basedn( )
{
SAMDB_PATH = $1
2022-12-04 21:46:36 +03:00
${ ldbsearch } -H $SAMDB_PATH --basedn= '' --scope= base defaultNamingContext | grep defaultNamingContext | awk '{print $2}'
2018-06-21 06:04:00 +03:00
}
2022-04-22 16:46:04 +03:00
ldapcmp_with_orig( )
{
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
DB1_PATH = " tdb:// $ORIG_DC_PREFIX_ABS /private/sam.ldb "
DB2_PATH = " tdb:// $RESTORED_DC_PREFIX_ABS /private/sam.ldb "
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# check if the 2 DCs are in different domains
DC1_BASEDN = $( basedn $DB1_PATH )
DC2_BASEDN = $( basedn $DB2_PATH )
BASE_DN_OPTS = ""
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# if necessary, pass extra args to ldapcmp to handle the difference in base DNs
if [ " $DC1_BASEDN " != " $DC2_BASEDN " ] ; then
BASE_DN_OPTS = " --base= $DC1_BASEDN --base2= $DC2_BASEDN "
fi
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# the restored DC will remove DNS entries for the old DC(s)
IGNORE_ATTRS = "dnsRecord,dNSTombstoned"
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# DC2 joined DC1, so it will have different DRS info
IGNORE_ATTRS = " $IGNORE_ATTRS ,msDS-NC-Replica-Locations,msDS-HasInstantiatedNCs "
IGNORE_ATTRS = " $IGNORE_ATTRS ,interSiteTopologyGenerator "
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# there's a servicePrincipalName that uses the objectGUID of the DC's NTDS
# Settings that will differ between the two DCs
IGNORE_ATTRS = " $IGNORE_ATTRS ,servicePrincipalName "
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# the restore changes the new DC's password twice
IGNORE_ATTRS = " $IGNORE_ATTRS ,lastLogonTimestamp "
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# The RID pools get bumped during the restore process
IGNORE_ATTRS = " $IGNORE_ATTRS ,rIDAllocationPool,rIDAvailablePool "
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# these are just differences between provisioning a domain and joining a DC
IGNORE_ATTRS = " $IGNORE_ATTRS ,localPolicyFlags,operatingSystem,displayName "
2018-06-21 06:04:00 +03:00
2022-04-22 16:46:04 +03:00
# the restored DC may use a different side compared to the original DC
IGNORE_ATTRS = " $IGNORE_ATTRS ,serverReferenceBL,msDS-IsDomainFor "
2018-09-18 07:30:15 +03:00
2022-04-22 16:46:04 +03:00
LDAPCMP_CMD = " $PYTHON $BINDIR /samba-tool ldapcmp "
$LDAPCMP_CMD $DB1_PATH $DB2_PATH --two --skip-missing-dn --filter= $IGNORE_ATTRS $BASE_DN_OPTS
2018-06-21 06:04:00 +03:00
}
# check that the restored testenv DC basically matches the original
testit "orig_dc_matches" ldapcmp_with_orig
exit $failed