2 # Test id mapping through idmap_rfc2307 module
4 echo Usage
: $0 DOMAIN USERNAME UID USERNAME2 UID2 GROUPNAME GID GROUPNAME2 GID2 LDAPPREFIX DC_SERVER DC_USERNAME DC_PASSWORD
23 wbinfo
="$VALGRIND $BINDIR/wbinfo"
26 if [ -x "$BINDIR/ldbadd" ]; then
27 ldbadd
="$BINDIR/ldbadd"
31 if [ -x "$BINDIR/ldbdel" ]; then
32 ldbdel
="$BINDIR/ldbdel"
37 .
`dirname $0`/..
/..
/testprogs
/blackbox
/subunit.sh
40 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME,$LDAPPREFIX"
41 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME2,$LDAPPREFIX"
42 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME,$LDAPPREFIX"
43 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME2,$LDAPPREFIX"
44 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX"
46 # Add id mapping information to LDAP
48 cat > $PREFIX/tmpldb
<<EOF
50 objectclass: organizationalUnit
53 testit
"add ldap prefix" $VALGRIND $ldbadd -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
55 cat > $PREFIX/tmpldb
<<EOF
56 dn: cn=$USERNAME,$LDAPPREFIX
57 objectClass: organizationalPerson
58 objectClass: posixAccount
64 homeDirectory: /home/admin
67 testit
"add ldap user mapping record" $VALGRIND $ldbadd -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
69 cat > $PREFIX/tmpldb
<<EOF
70 dn: cn=$USERNAME2,$LDAPPREFIX
71 objectClass: organizationalPerson
72 objectClass: posixAccount
78 homeDirectory: /home/admin
81 testit
"add second ldap user mapping record" $VALGRIND $ldbadd -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
83 cat > $PREFIX/tmpldb
<<EOF
84 dn: cn=$GROUPNAME,$LDAPPREFIX
85 objectClass: posixGroup
86 objectClass: groupOfNames
89 member: cn=$USERNAME,$LDAPPREFIX
92 testit
"add ldap group mapping record" $VALGRIND $ldbadd -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
94 cat > $PREFIX/tmpldb
<<EOF
95 dn: cn=$GROUPNAME2,$LDAPPREFIX
96 objectClass: posixGroup
97 objectClass: groupOfNames
100 member: cn=$USERNAME,$LDAPPREFIX
103 testit
"add second ldap group mapping record" $VALGRIND $ldbadd -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
105 rm -f $PREFIX/tmpldbmodify
107 testit
"wbinfo --name-to-sid" $wbinfo --name-to-sid "$DOMAIN/$USERNAME" || failed
=$
(expr $failed + 1)
108 user_sid
=$
($wbinfo -n "$DOMAIN/$USERNAME" | cut
-d " " -f1)
109 echo "$DOMAIN/$USERNAME resolved to $user_sid"
111 testit
"wbinfo --sid-to-uid=$user_sid" $wbinfo --sid-to-uid=$user_sid || failed
=$
(expr $failed + 1)
112 user_uid
=$
($wbinfo --sid-to-uid=$user_sid | cut
-d " " -f1)
113 echo "$DOMAIN/$USERNAME resolved to $user_uid"
115 testit
"test $user_uid -eq $USERUID" test $user_uid -eq $USERUID || failed
=$
(expr $failed + 1)
117 # Not sure how to get group names with spaces to resolve through testit
118 #testit "wbinfo --name-to-sid" $wbinfo --name-to-sid="$DOMAIN/$GROUPNAME" || failed=$(expr $failed + 1)
119 group_sid
=$
($wbinfo --name-to-sid="$DOMAIN/$GROUPNAME" | cut
-d " " -f1)
120 echo "$DOMAIN/$GROUPNAME resolved to $group_sid"
122 testit
"wbinfo --sid-to-gid=$group_sid" $wbinfo --sid-to-gid=$group_sid || failed
=$
(expr $failed + 1)
123 group_gid
=$
($wbinfo --sid-to-gid=$group_sid | cut
-d " " -f1)
124 echo "$DOMAIN/$GROUPNAME resolved to $group_gid"
126 testit
"test $group_gid -eq $GROUPGID" test $group_gid -eq $GROUPGID || failed
=$
(expr $failed + 1)
128 # Use different user and group for reverse lookup to not read from cache
130 testit
"$wbinfo --uid-to-sid=$USERUID2" $wbinfo --uid-to-sid=$USERUID2 || failed
=$
(expr $failed + 1)
131 user_sid2
=$
($wbinfo --uid-to-sid=$USERUID2 | cut
-d " " -f1)
132 echo "UID $USERUID2 resolved to SID $user_sid2"
134 testit
"$wbinfo --sid-to-name=$user_sid2" $wbinfo --sid-to-name=$user_sid2 || failed
=$
(expr $failed + 1)
135 user_name2
=$
($wbinfo --sid-to-name=$user_sid2 | cut
-d " " -f1)
136 echo "SID $user_sid2 resolved to $user_name2"
138 testit
"test $user_name2 = $DOMAIN/$USERNAME2" test "$(echo $user_name2 | tr A-Z a-z)" = "$(echo $DOMAIN/$USERNAME2 | tr A-Z a-z)" || failed
=$
(expr $failed + 1)
140 testit
"$wbinfo --gid-to-sid=$GROUPGID2" $wbinfo --gid-to-sid=$GROUPGID2 || failed
=$
(expr $failed + 1)
141 group_sid2
=$
($wbinfo --gid-to-sid=$GROUPGID2 | cut
-d " " -f1)
142 echo "GID $GROUPGID2 resolved to SID $group_sid2"
144 testit
"$wbinfo --sid-to-name=$group_sid2" $wbinfo --sid-to-name=$group_sid2 || failed
=$
(expr $failed + 1)
145 group_name2
=$
($wbinfo --sid-to-name=$group_sid2 | cut
-d " " -f1)
146 echo "SID $group_sid2 resolved to $group_name2"
148 testit
"test $group_name2 = $DOMAIN/$GROUPNAME2" test "$(echo $group_name2 | tr A-Z a-z)" = "$(echo $DOMAIN/$GROUPNAME2 | tr A-Z a-z)" || failed
=$
(expr $failed + 1)
150 # Delete LDAP records
151 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME,$LDAPPREFIX"
152 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME2,$LDAPPREFIX"
153 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME,$LDAPPREFIX"
154 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME2,$LDAPPREFIX"
155 $VALGRIND $ldbdel -H ldap
://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX"