2 # Blackbox test for wbinfo and rfc2307 mappings
5 Usage: test_rfc2307_mapping.sh DOMAIN USERNAME PASSWORD SERVER UID_RFC2307TEST GID_RFC2307TEST CONFIGURATION
20 samba4bindir
="$BINDIR"
21 wbinfo
="$VALGRIND $samba4bindir/wbinfo"
22 samba_tool
="$VALGRIND $samba4bindir/samba-tool"
24 . $
(dirname $0)/..
/..
/testprogs
/blackbox
/subunit.sh
25 .
"$(dirname "${0}")/../../testprogs/blackbox/common_test_fns.inc"
27 ldbmodify
=$
(system_or_builddir_binary ldbmodify
"${BINDIR}")
29 # Create new testing account
30 testit
"user add" $PYTHON $samba_tool user create
--given-name="rfc2307" \
31 --surname="Tester" --initial="UT" rfc2307_test_user testp@ssw0Rd \
32 "${CONFIGURATION}" "$@"
34 #test creation of six different groups
35 testit
"group add" $PYTHON $samba_tool group add \
36 --group-scope='Domain' --group-type='Security' rfc2307_test_group \
37 "${CONFIGURATION}" "$@"
39 # Create new testing group
42 testit
"wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_user" || failed
=$
(expr $failed + 1)
43 user_sid
=$
($wbinfo -n "$DOMAIN/rfc2307_test_user" | cut
-d " " -f1)
44 echo "$DOMAIN/rfc2307_test_user resolved to $user_sid"
46 testit
"wbinfo -s $user_sid against $TARGET" $wbinfo -s $user_sid || failed
=$
(expr $failed + 1)
47 user_name
=$
($wbinfo -s $user_sid | cut
-d " " -f1 |
tr a-z A-Z
)
48 echo "$user_sid resolved to $user_name"
50 tested_name
=$
(echo $DOMAIN/rfc2307_test_user |
tr a-z A-Z
)
52 # Now check that wbinfo works correctly (sid <=> name)
53 echo "test: wbinfo -s check for sane mapping"
54 if test x
$user_name != x
$tested_name; then
55 echo "$user_name does not match $tested_name"
56 echo "failure: wbinfo -s check for sane mapping"
57 failed
=$
(expr $failed + 1)
59 echo "success: wbinfo -s check for sane mapping"
62 testit
"wbinfo -n on the returned name against $TARGET" $wbinfo -n $user_name || failed
=$
(expr $failed + 1)
63 test_sid
=$
($wbinfo -n $tested_name | cut
-d " " -f1)
65 echo "test: wbinfo -n check for sane mapping"
66 if test x
$user_sid != x
$test_sid; then
67 echo "$user_sid does not match $test_sid"
68 echo "failure: wbinfo -n check for sane mapping"
69 failed
=$
(expr $failed + 1)
71 echo "success: wbinfo -n check for sane mapping"
74 testit
"wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_group" || failed
=$
(expr $failed + 1)
75 group_sid
=$
($wbinfo -n "$DOMAIN/rfc2307_test_group" | cut
-d " " -f1)
76 echo "$DOMAIN/rfc2307_test_group resolved to $group_sid"
78 # Then add a uidNumber to the group record using ldbmodify
79 cat >$PREFIX/tmpldbmodify
<<EOF
83 uidNumber: $UID_RFC2307TEST
86 testit
"modify gidNumber on group" $VALGRIND $ldbmodify -H ldap
://$SERVER \
87 $PREFIX/tmpldbmodify
-U$DOMAIN/$USERNAME%$PASSWORD "$@" ||
88 failed
=$
(expr $failed + 1)
90 # Then add a gidNumber to the group record using ldbmodify
91 cat >$PREFIX/tmpldbmodify
<<EOF
95 gidNumber: $GID_RFC2307TEST
98 testit
"modify gidNumber on group" $VALGRIND $ldbmodify -H ldap
://$SERVER \
99 $PREFIX/tmpldbmodify
-U$DOMAIN/$USERNAME%$PASSWORD "$@" ||
100 failed
=$
(expr $failed + 1)
102 rm -f $PREFIX/tmpldbmodify
104 # Now check we get a correct SID for the UID
106 testit
"wbinfo -U against $TARGET" $wbinfo -U $UID_RFC2307TEST || failed
=$
(expr $failed + 1)
108 echo "test: wbinfo -U check for sane mapping"
109 sid_for_user
=$
($wbinfo -U $UID_RFC2307TEST)
110 if test x
"$sid_for_user" != x
"$user_sid"; then
111 echo "uid $UID_RFC2307TEST mapped to $sid_for_user, not $user_sid"
112 echo "failure: wbinfo -U check for sane mapping"
113 failed
=$
(expr $failed + 1)
115 echo "success: wbinfo -U check for sane mapping"
118 testit
"wbinfo -G against $TARGET" $wbinfo -G $GID_RFC2307TEST || failed
=$
(expr $failed + 1)
120 echo "test: wbinfo -G check for sane mapping"
121 sid_for_group
=$
($wbinfo -G $GID_RFC2307TEST)
122 if test x
$sid_for_group != "x$group_sid"; then
123 echo "gid $GID_RFC2307TEST mapped to $sid_for_group, not $group_sid"
124 echo "failure: wbinfo -G check for sane mapping"
125 failed
=$
(expr $failed + 1)
127 echo "success: wbinfo -G check for sane mapping"
130 # Now check we get the right UID from the SID
131 testit
"wbinfo -S against $TARGET" $wbinfo -S "$user_sid" || failed
=$
(expr $failed + 1)
133 echo "test: wbinfo -S check for sane mapping"
134 uid_for_user_sid
=$
($wbinfo -S $user_sid)
135 if test 0$uid_for_user_sid -ne $UID_RFC2307TEST; then
136 echo "$user_sid mapped to $uid_for_sid, not $UID_RFC2307TEST"
137 echo "failure: wbinfo -S check for sane mapping"
138 failed
=$
(expr $failed + 1)
140 echo "success: wbinfo -S check for sane mapping"
143 # Now check we get the right GID from the SID
144 testit
"wbinfo -Y" $wbinfo -Y "$group_sid" || failed
=$
(expr $failed + 1)
146 echo "test: wbinfo -Y check for sane mapping"
147 gid_for_user_sid
=$
($wbinfo -Y $group_sid)
148 if test 0$gid_for_user_sid -ne $GID_RFC2307TEST; then
149 echo "$group_sid mapped to $gid_for_sid, not $GID_RFC2307TEST"
150 echo "failure: wbinfo -Y check for sane mapping"
151 failed
=$
(expr $failed + 1)
153 echo "success: wbinfo -Y check for sane mapping"
156 testit
"group delete" $PYTHON $samba_tool group delete rfc2307_test_group
"${CONFIGURATION}" "$@"
157 testit
"user delete" $PYTHON $samba_tool user delete rfc2307_test_user
"${CONFIGURATION}" "$@"