2 # Test id mapping through idmap_rfc2307 module
4 echo Usage
: $0 DOMAIN USERNAME UID GROUPNAME GID LDAPPREFIX DC_SERVER DC_USERNAME DC_PASSWORD
18 echo called with
: $1 $2 $3 $4 $5 $6 $7 $8 $9
20 wbinfo
="$VALGRIND $BINDIR/wbinfo"
21 ldbadd
="$BINDIR/ldbadd"
22 ldbdel
="$BINDIR/ldbdel"
25 .
`dirname $0`/..
/..
/testprogs
/blackbox
/subunit.sh
28 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME,$LDAPPREFIX"
29 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME,$LDAPPREFIX"
30 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX"
32 # Add id mapping information to LDAP
34 cat > $PREFIX/tmpldb
<<EOF
36 objectclass: organizationalUnit
39 testit
"add ldap prefix" $VALGRIND $ldbadd -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
41 cat > $PREFIX/tmpldb
<<EOF
42 dn: cn=$USERNAME,$LDAPPREFIX
43 objectClass: organizationalPerson
44 objectClass: posixAccount
50 homeDirectory: /home/admin
53 testit
"add ldap user mapping record" $VALGRIND $ldbadd -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
55 cat > $PREFIX/tmpldb
<<EOF
56 dn: cn=$GROUPNAME,$LDAPPREFIX
57 objectClass: posixGroup
58 objectClass: groupOfNames
61 member: cn=$USERNAME,$LDAPPREFIX
64 testit
"add ldap group mapping record" $VALGRIND $ldbadd -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
66 rm -f $PREFIX/tmpldbmodify
68 testit
"wbinfo --name-to-sid" $wbinfo --name-to-sid "$DOMAIN\\$USERNAME" || failed
=$
(expr $failed + 1)
69 user_sid
=$
($wbinfo -n "$DOMAIN\\$USERNAME" | cut
-d " " -f1)
70 echo "$DOMAIN\\$USERNAME resolved to $user_sid"
72 testit
"wbinfo --sid-to-uid=$user_sid" $wbinfo --sid-to-uid=$user_sid || failed
=$
(expr $failed + 1)
73 user_uid
=$
($wbinfo --sid-to-uid=$user_sid | cut
-d " " -f1)
74 echo "$DOMAIN\\$USERNAME resolved to $user_uid"
76 testit
"test $user_uid -eq $USERUID" test $user_uid -eq $USERUID || failed
=$
(expr $failed + 1)
78 # Not sure how to get group names with spaces to resolve through testit
79 #testit "wbinfo --name-to-sid" $wbinfo --name-to-sid="$DOMAIN\\$GROUPNAME" || failed=$(expr $failed + 1)
80 group_sid
=$
($wbinfo --name-to-sid="$DOMAIN\\$GROUPNAME" | cut
-d " " -f1)
81 echo "$DOMAIN\\$GROUPNAME resolved to $group_sid"
83 testit
"wbinfo --sid-to-gid=$group_sid" $wbinfo --sid-to-gid=$group_sid || failed
=$
(expr $failed + 1)
84 group_gid
=$
($wbinfo --sid-to-gid=$group_sid | cut
-d " " -f1)
85 echo "$DOMAIN\\$GROUPNAME resolved to $group_gid"
87 testit
"test $group_gid -eq $GROUPGID" test $group_gid -eq $GROUPGID || failed
=$
(expr $failed + 1)
90 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME,$LDAPPREFIX"
91 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME,$LDAPPREFIX"
92 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX"