summaryrefslogtreecommitdiffstats
path: root/testprogs/blackbox/join_ldapcmp.sh
blob: 3e5b264e7d7aa08495edcea856f76e43a95f6d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# Does a join against the testenv's DC and then runs ldapcmp on the resulting DB

. $(dirname $0)/subunit.sh

TARGET_DIR="$PREFIX_ABS/join_$SERVER"

cleanup_output_dir()
{
	if [ -d $TARGET_DIR ]; then
		rm -fr $TARGET_DIR
	fi
}

SAMBA_TOOL="$PYTHON $BINDIR/samba-tool"

join_dc()
{
	JOIN_ARGS="--targetdir=$TARGET_DIR --server=$SERVER -U$USERNAME%$PASSWORD"
	$SAMBA_TOOL domain join $REALM dc $JOIN_ARGS --option="netbios name = TESTJOINDC"
}

demote_joined_dc()
{
	DEMOTE_ARGS="--remove-other-dead-server=TESTJOINDC --server=$SERVER -U$USERNAME%$PASSWORD"
	$SAMBA_TOOL domain demote $DEMOTE_ARGS
}

ldapcmp_result()
{
	DB1_PATH="tdb://$PREFIX_ABS/$SERVER/private/sam.ldb"
	DB2_PATH="tdb://$TARGET_DIR/private/sam.ldb"

	# interSiteTopologyGenerator gets periodically updated. With the restored
	# testenvs, it can sometimes point to the old/deleted DC object still
	$SAMBA_TOOL ldapcmp $DB1_PATH $DB2_PATH --filter=interSiteTopologyGenerator
}

cleanup_output_dir

# check that we can join this DC
testit "check_dc_join" join_dc

# check resulting DB matches server DC
testit "new_db_matches" ldapcmp_result

testit "demote_joined_dc" demote_joined_dc

cleanup_output_dir

exit $failed