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