summaryrefslogtreecommitdiff
path: root/testprogs/blackbox/join_ldapcmp.sh
blob: 30d3e1e0192d711c2cebc557cf17aef127ab4c26 (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
#!/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"
}

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

cleanup_output_dir

exit $failed