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 if [ -f "$samba4bindir/ldbmodify" ]; then
23 ldbmodify
="$samba4bindir/ldbmodify"
25 # Using system ldbmodify
29 .
`dirname $0`/..
/..
/testprogs
/blackbox
/subunit.sh
38 if [ x
$status = x0
]; then
53 if [ x
$status = x0
]; then
54 echo "failure: $name [unexpected success]"
57 echo "knownfail: $name"
64 # Create new testing account
65 testit
"user add" $samba_tool user create
--given-name="rfc2307" --surname="Tester" --initial="UT" rfc2307_test_user testp@ssw0Rd $@
67 #test creation of six different groups
68 testit
"group add" $samba_tool group add
$CONFIG --group-scope='Domain' --group-type='Security' rfc2307_test_group $@
70 # Create new testing group
73 testit
"wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_user" || failed
=`expr $failed + 1`
74 user_sid
=`$wbinfo -n "$DOMAIN/rfc2307_test_user" | cut -d " " -f1`
75 echo "$DOMAIN/rfc2307_test_user resolved to $user_sid"
77 testit
"wbinfo -s $user_sid against $TARGET" $wbinfo -s $user_sid || failed
=`expr $failed + 1`
78 user_name
=`$wbinfo -s $user_sid | cut -d " " -f1| tr a-z A-Z`
79 echo "$user_sid resolved to $user_name"
81 tested_name
=`echo $DOMAIN/rfc2307_test_user | tr a-z A-Z`
83 # Now check that wbinfo works correctly (sid <=> name)
84 echo "test: wbinfo -s check for sane mapping"
85 if test x
$user_name != x
$tested_name; then
86 echo "$user_name does not match $tested_name"
87 echo "failure: wbinfo -s check for sane mapping"
88 failed
=`expr $failed + 1`
90 echo "success: wbinfo -s check for sane mapping"
93 testit
"wbinfo -n on the returned name against $TARGET" $wbinfo -n $user_name || failed
=`expr $failed + 1`
94 test_sid
=`$wbinfo -n $tested_name | cut -d " " -f1`
96 echo "test: wbinfo -n check for sane mapping"
97 if test x
$user_sid != x
$test_sid; then
98 echo "$user_sid does not match $test_sid"
99 echo "failure: wbinfo -n check for sane mapping"
100 failed
=`expr $failed + 1`
102 echo "success: wbinfo -n check for sane mapping"
105 testit
"wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_group" || failed
=`expr $failed + 1`
106 group_sid
=`$wbinfo -n "$DOMAIN/rfc2307_test_group" | cut -d " " -f1`
107 echo "$DOMAIN/rfc2307_test_group resolved to $group_sid"
109 # Then add a uidNumber to the group record using ldbmodify
110 cat > $PREFIX/tmpldbmodify
<<EOF
114 uidNumber: $UID_RFC2307TEST
117 testit
"modify gidNumber on group" $VALGRIND $ldbmodify -H ldap
://$SERVER $PREFIX/tmpldbmodify
-U$DOMAIN/$USERNAME%$PASSWORD $@ || failed
=`expr $failed + 1`
119 # Then add a gidNumber to the group record using ldbmodify
120 cat > $PREFIX/tmpldbmodify
<<EOF
124 gidNumber: $GID_RFC2307TEST
127 testit
"modify gidNumber on group" $VALGRIND $ldbmodify -H ldap
://$SERVER $PREFIX/tmpldbmodify
-U$DOMAIN/$USERNAME%$PASSWORD $@ || failed
=`expr $failed + 1`
129 rm -f $PREFIX/tmpldbmodify
131 # Now check we get a correct SID for the UID
133 testit
"wbinfo -U against $TARGET" $wbinfo -U $UID_RFC2307TEST || failed
=`expr $failed + 1`
135 echo "test: wbinfo -U check for sane mapping"
136 sid_for_user
=`$wbinfo -U $UID_RFC2307TEST`
137 if test x
"$sid_for_user" != x
"$user_sid"; then
138 echo "uid $UID_RFC2307TEST mapped to $sid_for_user, not $user_sid"
139 echo "failure: wbinfo -U check for sane mapping"
140 failed
=`expr $failed + 1`
142 echo "success: wbinfo -U check for sane mapping"
145 testit
"wbinfo -G against $TARGET" $wbinfo -G $GID_RFC2307TEST || failed
=`expr $failed + 1`
147 echo "test: wbinfo -G check for sane mapping"
148 sid_for_group
=`$wbinfo -G $GID_RFC2307TEST`
149 if test x
$sid_for_group != "x$group_sid"; then
150 echo "gid $GID_RFC2307TEST mapped to $sid_for_group, not $group_sid"
151 echo "failure: wbinfo -G check for sane mapping"
152 failed
=`expr $failed + 1`
154 echo "success: wbinfo -G check for sane mapping"
157 # Now check we get the right UID from the SID
158 testit
"wbinfo -S against $TARGET" $wbinfo -S "$user_sid" || failed
=`expr $failed + 1`
160 echo "test: wbinfo -S check for sane mapping"
161 uid_for_user_sid
=`$wbinfo -S $user_sid`
162 if test 0$uid_for_user_sid -ne $UID_RFC2307TEST; then
163 echo "$user_sid mapped to $uid_for_sid, not $UID_RFC2307TEST"
164 echo "failure: wbinfo -S check for sane mapping"
165 failed
=`expr $failed + 1`
167 echo "success: wbinfo -S check for sane mapping"
170 # Now check we get the right GID from the SID
171 testit
"wbinfo -Y" $wbinfo -Y "$group_sid" || failed
=`expr $failed + 1`
173 echo "test: wbinfo -Y check for sane mapping"
174 gid_for_user_sid
=`$wbinfo -Y $group_sid`
175 if test 0$gid_for_user_sid -ne $GID_RFC2307TEST; then
176 echo "$group_sid mapped to $gid_for_sid, not $GID_RFC2307TEST"
177 echo "failure: wbinfo -Y check for sane mapping"
178 failed
=`expr $failed + 1`
180 echo "success: wbinfo -Y check for sane mapping"
183 testit
"group delete" $samba_tool group delete rfc2307_test_group $@
184 testit
"user delete" $samba_tool user delete rfc2307_test_user $@