2 # Blackbox test for wbinfo and rfc2307 mappings
5 Usage: test_rfc2307_mapping.sh DOMAIN USERNAME PASSWORD SERVER UID_RFC2307TEST GID_RFC2307TEST
19 samba4bindir
="$BINDIR"
20 wbinfo
="$VALGRIND $samba4bindir/wbinfo"
21 samba_tool
="$VALGRIND $samba4bindir/samba-tool"
22 ldbmodify
="$samba4bindir/ldbmodify"
24 .
`dirname $0`/..
/..
/testprogs
/blackbox
/subunit.sh
33 if [ x
$status = x0
]; then
48 if [ x
$status = x0
]; then
49 echo "failure: $name [unexpected success]"
52 echo "knownfail: $name"
59 # Create new testing account
60 testit
"user add" $samba_tool user create
--given-name="rfc2307" --surname="Tester" --initial="UT" rfc2307_test_user testp@ssw0Rd $@
62 #test creation of six different groups
63 testit
"group add" $samba_tool group add
$CONFIG --group-scope='Domain' --group-type='Security' rfc2307_test_group $@
65 # Create new testing group
68 testit
"wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_user" || failed
=`expr $failed + 1`
69 user_sid
=`$wbinfo -n "$DOMAIN/rfc2307_test_user" | cut -d " " -f1`
70 echo "$DOMAIN/rfc2307_test_user resolved to $user_sid"
72 testit
"wbinfo -s $user_sid against $TARGET" $wbinfo -s $user_sid || failed
=`expr $failed + 1`
73 user_name
=`$wbinfo -s $user_sid | cut -d " " -f1| tr a-z A-Z`
74 echo "$user_sid resolved to $user_name"
76 tested_name
=`echo $DOMAIN/rfc2307_test_user | tr a-z A-Z`
78 # Now check that wbinfo works correctly (sid <=> name)
79 echo "test: wbinfo -s check for sane mapping"
80 if test x
$user_name != x
$tested_name; then
81 echo "$user_name does not match $tested_name"
82 echo "failure: wbinfo -s check for sane mapping"
83 failed
=`expr $failed + 1`
85 echo "success: wbinfo -s check for sane mapping"
88 testit
"wbinfo -n on the returned name against $TARGET" $wbinfo -n $user_name || failed
=`expr $failed + 1`
89 test_sid
=`$wbinfo -n $tested_name | cut -d " " -f1`
91 echo "test: wbinfo -n check for sane mapping"
92 if test x
$user_sid != x
$test_sid; then
93 echo "$user_sid does not match $test_sid"
94 echo "failure: wbinfo -n check for sane mapping"
95 failed
=`expr $failed + 1`
97 echo "success: wbinfo -n check for sane mapping"
100 testit
"wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_group" || failed
=`expr $failed + 1`
101 group_sid
=`$wbinfo -n "$DOMAIN/rfc2307_test_group" | cut -d " " -f1`
102 echo "$DOMAIN/rfc2307_test_group resolved to $group_sid"
104 # Then add a uidNumber to the group record using ldbmodify
105 cat > $PREFIX/tmpldbmodify
<<EOF
109 uidNumber: $UID_RFC2307TEST
112 testit
"modify gidNumber on group" $VALGRIND $ldbmodify -H ldap
://$SERVER $PREFIX/tmpldbmodify
-U$DOMAIN/$USERNAME%$PASSWORD $@ || failed
=`expr $failed + 1`
114 # Then add a gidNumber to the group record using ldbmodify
115 cat > $PREFIX/tmpldbmodify
<<EOF
119 gidNumber: $GID_RFC2307TEST
122 testit
"modify gidNumber on group" $VALGRIND $ldbmodify -H ldap
://$SERVER $PREFIX/tmpldbmodify
-U$DOMAIN/$USERNAME%$PASSWORD $@ || failed
=`expr $failed + 1`
124 rm -f $PREFIX/tmpldbmodify
126 # Now check we get a correct SID for the UID
128 testit
"wbinfo -U against $TARGET" $wbinfo -U $UID_RFC2307TEST || failed
=`expr $failed + 1`
130 echo "test: wbinfo -U check for sane mapping"
131 sid_for_user
=`$wbinfo -U $UID_RFC2307TEST`
132 if test x
"$sid_for_user" != x
"$user_sid"; then
133 echo "uid $UID_RFC2307TEST mapped to $sid_for_user, not $user_sid"
134 echo "failure: wbinfo -U check for sane mapping"
135 failed
=`expr $failed + 1`
137 echo "success: wbinfo -U check for sane mapping"
140 testit
"wbinfo -G against $TARGET" $wbinfo -G $GID_RFC2307TEST || failed
=`expr $failed + 1`
142 echo "test: wbinfo -G check for sane mapping"
143 sid_for_group
=`$wbinfo -G $GID_RFC2307TEST`
144 if test x
$sid_for_group != "x$group_sid"; then
145 echo "gid $GID_RFC2307TEST mapped to $sid_for_group, not $group_sid"
146 echo "failure: wbinfo -G check for sane mapping"
147 failed
=`expr $failed + 1`
149 echo "success: wbinfo -G check for sane mapping"
152 # Now check we get the right UID from the SID
153 testit
"wbinfo -S against $TARGET" $wbinfo -S "$user_sid" || failed
=`expr $failed + 1`
155 echo "test: wbinfo -S check for sane mapping"
156 uid_for_user_sid
=`$wbinfo -S $user_sid`
157 if test 0$uid_for_user_sid -ne $UID_RFC2307TEST; then
158 echo "$user_sid mapped to $uid_for_sid, not $UID_RFC2307TEST"
159 echo "failure: wbinfo -S check for sane mapping"
160 failed
=`expr $failed + 1`
162 echo "success: wbinfo -S check for sane mapping"
165 # Now check we get the right GID from the SID
166 testit
"wbinfo -Y" $wbinfo -Y "$group_sid" || failed
=`expr $failed + 1`
168 echo "test: wbinfo -Y check for sane mapping"
169 gid_for_user_sid
=`$wbinfo -Y $group_sid`
170 if test 0$gid_for_user_sid -ne $GID_RFC2307TEST; then
171 echo "$group_sid mapped to $gid_for_sid, not $GID_RFC2307TEST"
172 echo "failure: wbinfo -Y check for sane mapping"
173 failed
=`expr $failed + 1`
175 echo "success: wbinfo -Y check for sane mapping"
178 testit
"group delete" $samba_tool group delete rfc2307_test_group $@
179 testit
"user delete" $samba_tool user delete rfc2307_test_user $@