2018-02-28 13:10:43 -07:00
#!/bin/sh
# Blackbox test for wbinfo name lookup
2019-03-11 16:25:42 -07:00
if [ $# -lt 3 ] ; then
2022-02-21 11:20:53 +01:00
cat <<EOF
2023-09-05 16:20:53 +12:00
Usage: test_wbinfo_name_lookup.sh DOMAIN REALM DC_USERNAME
2018-02-28 13:10:43 -07:00
EOF
2022-02-21 11:20:53 +01:00
exit 1
2018-02-28 13:10:43 -07:00
fi
DOMAIN = $1
2018-04-20 11:24:30 +02:00
REALM = $2
DC_USERNAME = $3
shift 3
2018-02-28 13:10:43 -07:00
failed = 0
sambabindir = " $BINDIR "
wbinfo = " $VALGRIND $sambabindir /wbinfo "
2022-02-21 11:20:53 +01:00
. $( dirname $0 ) /../../testprogs/blackbox/subunit.sh
2018-02-28 13:10:43 -07:00
# Correct query is expected to work
testit "name-to-sid.single-separator" \
2022-02-21 11:20:53 +01:00
$wbinfo -n $DOMAIN /$DC_USERNAME ||
2018-02-28 13:10:43 -07:00
failed = $( expr $failed + 1)
2018-05-04 12:43:05 +02:00
testit "name-to-sid.at_domain" \
2022-02-21 11:20:53 +01:00
$wbinfo -n $DOMAIN / ||
2018-05-04 12:43:05 +02:00
failed = $( expr $failed + 1)
2018-04-20 11:24:30 +02:00
testit "name-to-sid.upn" \
2022-02-21 11:20:53 +01:00
$wbinfo -n $DC_USERNAME @$REALM ||
2018-04-20 11:24:30 +02:00
failed = $( expr $failed + 1)
2019-03-11 16:26:48 -07:00
testit "name-to-sid.realm-user" \
2022-02-21 11:20:53 +01:00
$wbinfo -n $REALM /$DC_USERNAME ||
2019-03-11 16:26:48 -07:00
failed = $( expr $failed + 1)
# For the name-to-sid.realm-user query, ensure
# that this does not change subsequent sid-to-name
# queries.
sid = $( $wbinfo -n $REALM /$DC_USERNAME | sed -e 's/ .*//' )
out = $( $wbinfo -s $sid | sed -e 's/ .//' )
# winbindd returns usernames in lowercase
lcuser = $( echo $DC_USERNAME | tr A-Z a-z)
testit "Verify DOMAIN/USER output" \
2022-02-21 11:20:53 +01:00
test " $out " = " $DOMAIN / $lcuser " ||
2019-03-11 16:26:48 -07:00
failed = $( expr $failed + 1)
2018-02-28 13:10:43 -07:00
# Two separator characters should fail
testit_expect_failure "name-to-sid.double-separator" \
2022-02-21 11:20:53 +01:00
$wbinfo -n $DOMAIN //$DC_USERNAME ||
2018-02-28 13:10:43 -07:00
failed = $( expr $failed + 1)
# Invalid domain is expected to fail
testit_expect_failure "name-to-sid.invalid-domain" \
2022-02-21 11:20:53 +01:00
$wbinfo -n INVALID/$DC_USERNAME ||
2018-02-28 13:10:43 -07:00
failed = $( expr $failed + 1)
# Invalid domain with two separator characters is expected to fail
testit_expect_failure "name-to-sid.double-separator-invalid-domain" \
2022-02-21 11:20:53 +01:00
$wbinfo -n INVALID//$DC_USERNAME ||
2018-02-28 13:10:43 -07:00
failed = $( expr $failed + 1)
exit $failed