2011-05-20 23:50:55 +04:00
#!/bin/sh
if [ $# -lt 1 ] ; then
2022-04-22 16:46:04 +03:00
cat <<EOF
2011-07-13 04:49:45 +04:00
Usage: renamedc.sh PREFIX
2011-05-20 23:50:55 +04:00
EOF
2022-04-22 16:46:04 +03:00
exit 1
2011-05-20 23:50:55 +04:00
fi
PREFIX = " $1 "
shift 1
2022-04-22 16:46:04 +03:00
. $( dirname $0 ) /subunit.sh
2022-12-22 15:10:34 +03:00
. " $( dirname " ${ 0 } " ) /common_test_fns.inc "
ldbsearch = $( system_or_builddir_binary ldbsearch " ${ BINDIR } " )
2011-05-20 23:50:55 +04:00
2012-08-22 01:25:59 +04:00
if [ ! -d $PREFIX /renamedc_test ] ; then
2015-02-23 05:45:53 +03:00
mkdir -p $PREFIX /renamedc_test
2011-05-20 23:50:55 +04:00
fi
2022-04-22 16:46:04 +03:00
testprovision( )
{
$PYTHON $BINDIR /samba-tool domain provision --host-name= bar --domain= FOO --realm= foo.example.com --targetdir= " $PREFIX /renamedc_test " --server-role= "dc" --use-ntvfs
2015-02-23 05:45:53 +03:00
}
2011-05-20 23:50:55 +04:00
2022-04-22 16:46:04 +03:00
testrenamedc( )
{
2011-05-20 23:50:55 +04:00
$PYTHON $SRCDIR /source4/scripting/bin/renamedc \
--oldname= "BAR" \
--newname= "RAYMONBAR" \
2021-04-14 12:44:51 +03:00
--configfile= $PREFIX /renamedc_test/etc/smb.conf
2011-05-20 23:50:55 +04:00
}
2022-04-22 16:46:04 +03:00
confirmrenamedc( )
{
$ldbsearch -H $PREFIX /renamedc_test/private/sam.ldb --scope= base -b 'cn=RAYMONBAR,ou=domain controllers,dc=foo,dc=example,dc=com'
2015-02-23 05:45:53 +03:00
}
2022-04-22 16:46:04 +03:00
confirmrenamedc_server( )
{
$ldbsearch -H $PREFIX /renamedc_test/private/sam.ldb --scope= base -b 'cn=RAYMONBAR,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=configuration,dc=foo,dc=example,dc=com'
2015-02-23 05:45:53 +03:00
}
2022-04-22 16:46:04 +03:00
confirmrenamedc_sAMAccountName( )
{
$ldbsearch -H $PREFIX /renamedc_test/private/sam.ldb --scope= base -b 'cn=RAYMONBAR,ou=domain controllers,dc=foo,dc=example,dc=com' sAMAccountName | grep 'sAMAccountName: RAYMONBAR\$'
2015-02-23 05:45:53 +03:00
}
2022-04-22 16:46:04 +03:00
confirmrenamedc_dNSHostName( )
{
$ldbsearch -H $PREFIX /renamedc_test/private/sam.ldb --scope= base -b 'cn=RAYMONBAR,ou=domain controllers,dc=foo,dc=example,dc=com' dNSHostName | grep 'dNSHostName: RAYMONBAR.foo.example.com'
2015-02-23 05:45:53 +03:00
}
2011-05-20 23:50:55 +04:00
2022-04-22 16:46:04 +03:00
confirmrenamedc_rootdse_dnsHostName( )
{
$ldbsearch -H $PREFIX /renamedc_test/private/sam.ldb --scope= base -b '' dNSHostName | grep 'dnsHostName: RAYMONBAR.foo.example.com'
2015-02-27 05:56:22 +03:00
}
2022-04-22 16:46:04 +03:00
confirmrenamedc_rootdse_dsServiceName( )
{
$ldbsearch -H $PREFIX /renamedc_test/private/sam.ldb --show-binary --scope= base -b '' dsServiceName | grep 'dsServiceName: CN=NTDS Settings,CN=RAYMONBAR,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=foo,DC=example,DC=com'
2015-02-27 05:56:22 +03:00
}
2022-04-22 16:46:04 +03:00
testrenamedc2( )
{
2011-05-20 23:50:55 +04:00
$PYTHON $SRCDIR /source4/scripting/bin/renamedc \
--oldname= "RAYMONBAR" \
--newname= "BAR" \
2021-04-14 12:44:51 +03:00
--configfile= $PREFIX /renamedc_test/etc/smb.conf
2011-05-20 23:50:55 +04:00
}
2022-04-22 16:46:04 +03:00
dbcheck_fix( )
{
# Unlike most calls to dbcheck --fix, this will not trigger an error, as
# we do not flag an error count for this old DN string case.
2021-04-14 12:44:51 +03:00
$PYTHON $BINDIR /samba-tool dbcheck --cross-ncs --configfile= $PREFIX /renamedc_test/etc/smb.conf --fix \
2017-02-02 06:27:35 +03:00
--quiet --yes fix_all_old_dn_string_component_mismatch \
2016-07-12 03:44:10 +03:00
--attrs= "fsmoRoleOwner interSiteTopologyGenerator msDS-NC-Replica-Locations"
2016-06-30 07:17:37 +03:00
}
2022-04-22 16:46:04 +03:00
dbcheck( )
{
2021-04-14 12:44:51 +03:00
$PYTHON $BINDIR /samba-tool dbcheck --cross-ncs --configfile= $PREFIX /renamedc_test/etc/smb.conf
2015-02-23 05:45:53 +03:00
}
2022-04-22 16:46:04 +03:00
testit "renameprovision" testprovision || failed = $( expr $failed + 1)
testit "renamedc" testrenamedc || failed = $( expr $failed + 1)
testit "confirmrenamedc" confirmrenamedc || failed = $( expr $failed + 1)
testit "confirmrenamedc_server" confirmrenamedc_server || failed = $( expr $failed + 1)
testit "confirmrenamedc_sAMAccountName" confirmrenamedc_sAMAccountName || failed = $( expr $failed + 1)
testit "confirmrenamedc_dNSHostName" confirmrenamedc_dNSHostName || failed = $( expr $failed + 1)
testit "confirmrenamedc_rootdse_dnsHostName" confirmrenamedc_rootdse_dnsHostName || failed = $( expr $failed + 1)
testit "confirmrenamedc_rootdse_dsServiceName" confirmrenamedc_rootdse_dsServiceName || failed = $( expr $failed + 1)
testit "dbcheck_fix" dbcheck_fix || failed = $( expr $failed + 1)
testit "dbcheck" dbcheck || failed = $( expr $failed + 1)
testit "renamedc2" testrenamedc2 || failed = $( expr $failed + 1)
2011-05-20 23:50:55 +04:00
if [ $failed -eq 0 ] ; then
2012-08-22 01:25:59 +04:00
rm -rf $PREFIX /renamedc_test
2011-05-20 23:50:55 +04:00
fi
exit $failed