5 Usage: test_primary_group.sh SERVER USERNAME PASSWORD DOMAIN PREFIX_ABS
18 TMPDIR
="$PREFIX_ABS/$(basename $0)"
21 . $
(dirname $0)/subunit.sh
22 . $
(dirname $0)/common_test_fns.inc
24 ldbmodify
=$
(system_or_builddir_binary ldbmodify
"${BINDIR}")
25 ldbsearch
=$
(system_or_builddir_binary ldbsearch
"${BINDIR}")
33 testgroup
="testgroup$N"
35 echo "testuser: $testuser"
36 echo "testgroup: $testgroup"
38 testit
"mkdir -p '${TMPDIR}'" mkdir
-p ${TMPDIR} || failed
=$
(expr $failed + 1)
40 testit
"create '$testuser'" $VALGRIND $PYTHON $BINDIR/samba-tool user create
"$testuser" Password
.1 || failed
=$
(expr $failed + 1)
41 testit
"add '$testgroup'" $VALGRIND $PYTHON $BINDIR/samba-tool group add
"$testgroup" || failed
=$
(expr $failed + 1)
42 testit
"addmembers '$testgroup' '$testuser'" $VALGRIND $PYTHON $BINDIR/samba-tool group addmembers
"$testgroup" "$testuser" || failed
=$
(expr $failed + 1)
44 testit
"search1" ${ldbsearch} -H ldap
://$SERVER_IP -U$USERNAME%$PASSWORD -d0 sAMAccountName
="$testgroup" objectSid || failed
=$
(expr $failed + 1)
45 ldif
="${TMPDIR}/search1.ldif"
46 ${ldbsearch} -H ldap
://$SERVER_IP -U$USERNAME%$PASSWORD -d0 sAMAccountName
=$testgroup objectSid
>$ldif
47 rid
=$
(cat $ldif |
sed -n 's/^objectSid: S-1-5-21-.*-.*-.*-//p')
49 testit
"search2" ${ldbsearch} -H ldap
://$SERVER_IP -U$USERNAME%$PASSWORD -d0 sAMAccountName
="$testuser" dn || failed
=$
(expr $failed + 1)
50 ldif
="${TMPDIR}/search2.ldif"
51 ${ldbsearch} -H ldap
://$SERVER_IP -U$USERNAME%$PASSWORD -d0 sAMAccountName
=$testuser dn
>$ldif
52 user_dn
=$
(cat $ldif |
sed -n 's/^dn: //p')
54 ldif
="${TMPDIR}/modify1.ldif"
58 replace: primaryGroupID
61 testit
"Change primaryGroupID to $rid" ${ldbmodify} -H ldap
://$SERVER_IP -U$USERNAME%$PASSWORD -d0 --verbose <$ldif || failed
=$
(expr $failed + 1)
63 testit
"dbcheck run1" $VALGRIND $PYTHON $BINDIR/samba-tool dbcheck
--attrs=member || failed
=$
(expr $failed + 1)
65 ldif
="${TMPDIR}/modify2.ldif"
69 replace: primaryGroupID
72 testit
"Change primaryGroupID to 513" ${ldbmodify} -H ldap
://$SERVER_IP -U$USERNAME%$PASSWORD -d0 <$ldif || failed
=$
(expr $failed + 1)
74 testit
"dbcheck run2" $VALGRIND $PYTHON $BINDIR/samba-tool dbcheck
--attrs=member || failed
=$
(expr $failed + 1)
76 testit
"delete '$testuser'" $VALGRIND $PYTHON $BINDIR/samba-tool user delete
"$testuser" || failed
=$
(expr $failed + 1)
77 testit
"delete '$testgroup'" $VALGRIND $PYTHON $BINDIR/samba-tool group delete
"$testgroup" || failed
=$
(expr $failed + 1)
80 # As we don't support phantom objects and virtual backlinks
81 # the deletion of the user prior to the group causes dangling links,
82 # which are detected like this:
84 # WARNING: target DN is deleted for member in object
86 # Specifically, this happens because after the member link is
87 # deactivated the memberOf is gone, and so there is no way to find the
88 # now redundant forward link to clean it up.
90 testit_expect_failure
"dbcheck run3" $VALGRIND $PYTHON $BINDIR/samba-tool dbcheck
--attrs=member
--fix --yes || failed
=$
(expr $failed + 1)
91 testit
"dbcheck run4" $VALGRIND $PYTHON $BINDIR/samba-tool dbcheck
--attrs=member || failed
=$
(expr $failed + 1)