3 # Basic testing of id mapping with idmap_ad
7 echo Usage
: $0 DOMAIN DC_SERVER DC_PASSWORD TRUST_DOMAIN TRUST_SERVER TRUST_PASSWORD
18 wbinfo
="$VALGRIND $BINDIR/wbinfo"
19 ldbmodify
="${VALGRIND} ldbmodify"
20 if [ -x "${BINDIR}/ldbmodify" ]; then
21 ldbmodify
="${VALGRIND} ${BINDIR}/ldbmodify"
24 ldbsearch
="${VALGRIND} ldbsearch"
25 if [ -x "${BINDIR}/ldbsearch" ]; then
26 ldbsearch
="${VALGRIND} ${BINDIR}/ldbsearch"
31 . $
(dirname $0)/..
/..
/testprogs
/blackbox
/subunit.sh
33 DOMAIN_SID
=$
($wbinfo -n "$DOMAIN/" | cut
-f 1 -d " ")
35 echo "Could not find domain SID" | subunit_fail_test
"test_idmap_ad"
39 TRUST_DOMAIN_SID
=$
($wbinfo -n "$TRUST_DOMAIN/" | cut
-f 1 -d " ")
41 echo "Could not find trusted domain SID" | subunit_fail_test
"test_idmap_ad"
45 BASE_DN
=$
($ldbsearch -H ldap
://$DC_SERVER -b "" --scope=base defaultNamingContext |
awk '/^defaultNamingContext/ {print $2}')
47 echo "Could not find base DN" | subunit_fail_test
"test_idmap_ad"
51 TRUST_BASE_DN
=$
($ldbsearch -H ldap
://$TRUST_SERVER -b "" --scope=base defaultNamingContext |
awk '/^defaultNamingContext/ {print $2}')
53 echo "Could not find trusted base DN" | subunit_fail_test
"test_idmap_ad"
60 cat <<EOF | $ldbmodify -H ldap://$DC_SERVER -U "$DOMAIN\Administrator%$DC_PASSWORD"
61 dn: CN=Administrator,CN=Users,$BASE_DN
67 add: unixHomeDirectory
68 unixHomeDirectory: /home/admin
72 gecos: Administrator Full Name
74 dn: CN=Domain Users,CN=Users,$BASE_DN
79 dn: CN=Domain Admins,CN=Users,$BASE_DN
86 objectClass: organizationalUnit
88 dn: cn=forbidden,ou=sub,$BASE_DN
91 samaccountName: forbidden
94 unixHomeDirectory: /home/forbidden
96 gecos: User in forbidden OU
98 dn: CN=no_posix_id,CN=Users,$BASE_DN
101 samaccountName: no_posix_id
102 unixHomeDirectory: /home/no_posix_id
104 gecos: User without uidNumber and gidNumber
108 # Add POSIX ids to trusted domain
110 cat <<EOF | $ldbmodify -H ldap://$TRUST_SERVER \
111 -U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
112 dn: CN=Administrator,CN=Users,$TRUST_BASE_DN
117 dn: CN=Domain Users,CN=Users,$TRUST_BASE_DN
122 dn: CN=Domain Admins,CN=Users,$TRUST_BASE_DN
129 # Test 1: Test uid of Administrator, should be 2000000
132 out
="$($wbinfo -S $DOMAIN_SID-500)"
133 echo "wbinfo returned: \"$out\", expecting \"2000000\""
134 test "$out" = "2000000"
136 testit
"Test uid of Administrator is 2000000" test $ret -eq 0 || failed
=$
(expr $failed + 1)
139 # Test 2: Test gid of Domain Users, should be 2000001
142 out
="$($wbinfo -Y $DOMAIN_SID-513)"
143 echo "wbinfo returned: \"$out\", expecting \"2000001\""
144 test "$out" = "2000001"
146 testit
"Test uid of Domain Users is 2000001" test $ret -eq 0 || failed
=$
(expr $failed + 1)
149 # Test 3: Test get userinfo for Administrator works
152 out
="$($wbinfo -i $DOMAIN/Administrator)"
153 echo "wbinfo returned: \"$out\", expecting \"$DOMAIN/administrator:*:2000000:2000100:Administrator Full Name:/home/admin:/bin/tcsh\""
154 test "$out" = "$DOMAIN/administrator:*:2000000:2000100:Administrator Full Name:/home/admin:/bin/tcsh"
156 testit
"Test get userinfo for Administrator works" test $ret -eq 0 || failed
=$
(expr $failed + 1)
159 # Test 4: Test lookup from gid to sid
162 out
="$($wbinfo -G 2000002)"
163 echo "wbinfo returned: \"$out\", expecting \"$DOMAIN_SID-512\""
164 test "$out" = "$DOMAIN_SID-512"
166 testit
"Test gid lookup of Domain Admins" test $ret -eq 0 || failed
=$
(expr $failed + 1)
169 # Test 5: Make sure deny_ou is really denied
170 # This depends on the "deny ous" setting in Samba3.pm
173 sid
="$($wbinfo -n $DOMAIN/forbidden | awk '{print $1}')"
174 testit
"Could create forbidden" test -n "$sid" || failed
=$
(expr $failed + 1)
177 uid
="$($wbinfo --sid-to-uid $sid)"
178 testit
"Can not resolve forbidden user" test -z "$uid" ||
179 failed
=$
(($failed + 1))
183 # Test 6: Make sure that with the default "all_groups=no"
184 # the group "domain users" will not show user "no_posix_id"
185 # but will show "SAMBA2008R2/administrator"
188 dom_users
="$DOMAIN/domain users" # Extra step to make sure that all is one word
189 out
="$($wbinfo --group-info "$dom_users")"
190 testit_grep_count
"no_posix_id1" "no_posix_id" 0 echo "$out" || failed
=$
(expr $failed + 1)
191 testit_grep
"no_posix_id2" "SAMBA2008R2/administrator" echo "$out" || failed
=$
(expr $failed + 1)
194 # Trusted domain test 1: Test uid of Administrator, should be 2500000
197 out
="$($wbinfo -S $TRUST_DOMAIN_SID-500)"
198 echo "wbinfo returned: \"$out\", expecting \"2500000\""
199 test "$out" = "2500000"
201 testit
"Test uid of Administrator in trusted domain is 2500000" test $ret -eq 0 || failed
=$
(expr $failed + 1)
204 # Trusted domain test 2: Test gid of Domain Users, should be 2500001
207 out
="$($wbinfo -Y $TRUST_DOMAIN_SID-513)"
208 echo "wbinfo returned: \"$out\", expecting \"2500001\""
209 test "$out" = "2500001"
211 testit
"Test uid of Domain Users in trusted domain is 2500001" test $ret -eq 0 || failed
=$
(expr $failed + 1)
214 # Trusted domain test 3: Test get userinfo for Administrator works
217 out
="$($wbinfo -i $TRUST_DOMAIN/Administrator)"
218 echo "wbinfo returned: \"$out\", expecting \"$TRUST_DOMAIN/administrator:*:2500000:2500001::/home/$TRUST_DOMAIN/administrator:/bin/false\""
219 test "$out" = "$TRUST_DOMAIN/administrator:*:2500000:2500001::/home/$TRUST_DOMAIN/administrator:/bin/false"
221 testit
"Test get userinfo for Administrator works" test $ret -eq 0 || failed
=$
(expr $failed + 1)
224 # Trusted domain test 4: Test lookup from gid to sid
227 out
="$($wbinfo -G 2500002)"
228 echo "wbinfo returned: \"$out\", expecting \"$TRUST_DOMAIN_SID-512\""
229 test "$out" = "$TRUST_DOMAIN_SID-512"
231 testit
"Test gid lookup of Domain Admins in trusted domain." test $ret -eq 0 || failed
=$
(expr $failed + 1)
234 # Remove POSIX ids from AD
236 cat <<EOF | $ldbmodify -H ldap://$DC_SERVER -U "$DOMAIN\Administrator%$DC_PASSWORD"
237 dn: CN=Administrator,CN=Users,$BASE_DN
243 delete: unixHomeDirectory
244 unixHomeDirectory: /home/admin
246 loginShell: /bin/tcsh
248 gecos: Administrator Full Name
250 dn: CN=Domain Users,CN=Users,$BASE_DN
255 dn: CN=Domain Admins,CN=Users,$BASE_DN
260 dn: cn=forbidden,ou=sub,$BASE_DN
263 dn: CN=no_posix_id,CN=Users,$BASE_DN
271 # Remove POSIX ids from trusted domain
273 cat <<EOF | $ldbmodify -H ldap://$TRUST_SERVER \
274 -U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
275 dn: CN=Administrator,CN=Users,$TRUST_BASE_DN
280 dn: CN=Domain Users,CN=Users,$TRUST_BASE_DN
285 dn: CN=Domain Admins,CN=Users,$TRUST_BASE_DN