ctdb-recoverd: If obtaining recovery lock fails, try again
[Samba.git] / nsswitch / tests / test_idmap_rfc2307.sh
blobcb60364016e0ed25f3965e459e2e8ac7b18f42f9
1 #!/bin/sh
2 # Test id mapping through idmap_rfc2307 module
3 if [ $# -lt 9 ]; then
4 echo Usage: $0 DOMAIN USERNAME UID GROUPNAME GID LDAPPREFIX DC_SERVER DC_USERNAME DC_PASSWORD
5 exit 1
6 fi
8 DOMAIN="$1"
9 USERNAME="$2"
10 USERUID="$3"
11 GROUPNAME="$4"
12 GROUPGID="$5"
13 LDAPPREFIX="$6"
14 DC_SERVER="$7"
15 DC_USERNAME="$8"
16 DC_PASSWORD="$9"
18 echo called with: $1 $2 $3 $4 $5 $6 $7 $8 $9
20 wbinfo="$VALGRIND $BINDIR/wbinfo"
22 ldbadd="ldbadd"
23 if [ -x "$BINDIR/ldbadd" ]; then
24 ldbadd="$BINDIR/ldbadd"
27 ldbdel="ldbdel"
28 if [ -x "$BINDIR/ldbdel" ]; then
29 ldbdel="$BINDIR/ldbdel"
32 failed=0
34 . `dirname $0`/../../testprogs/blackbox/subunit.sh
36 # Delete LDAP records
37 $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME,$LDAPPREFIX"
38 $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME,$LDAPPREFIX"
39 $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX"
41 # Add id mapping information to LDAP
43 cat > $PREFIX/tmpldb <<EOF
44 dn: $LDAPPREFIX
45 objectclass: organizationalUnit
46 EOF
48 testit "add ldap prefix" $VALGRIND $ldbadd -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
50 cat > $PREFIX/tmpldb <<EOF
51 dn: cn=$USERNAME,$LDAPPREFIX
52 objectClass: organizationalPerson
53 objectClass: posixAccount
54 ou: People
55 cn: $USERNAME
56 uid: $USERNAME
57 uidNumber: $USERUID
58 gidNumber: 1
59 homeDirectory: /home/admin
60 EOF
62 testit "add ldap user mapping record" $VALGRIND $ldbadd -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
64 cat > $PREFIX/tmpldb <<EOF
65 dn: cn=$GROUPNAME,$LDAPPREFIX
66 objectClass: posixGroup
67 objectClass: groupOfNames
68 cn: $GROUPNAME
69 gidNumber: $GROUPGID
70 member: cn=$USERNAME,$LDAPPREFIX
71 EOF
73 testit "add ldap group mapping record" $VALGRIND $ldbadd -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD $PREFIX/tmpldb
75 rm -f $PREFIX/tmpldbmodify
77 testit "wbinfo --name-to-sid" $wbinfo --name-to-sid "$DOMAIN/$USERNAME" || failed=$(expr $failed + 1)
78 user_sid=$($wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1)
79 echo "$DOMAIN/$USERNAME resolved to $user_sid"
81 testit "wbinfo --sid-to-uid=$user_sid" $wbinfo --sid-to-uid=$user_sid || failed=$(expr $failed + 1)
82 user_uid=$($wbinfo --sid-to-uid=$user_sid | cut -d " " -f1)
83 echo "$DOMAIN/$USERNAME resolved to $user_uid"
85 testit "test $user_uid -eq $USERUID" test $user_uid -eq $USERUID || failed=$(expr $failed + 1)
87 # Not sure how to get group names with spaces to resolve through testit
88 #testit "wbinfo --name-to-sid" $wbinfo --name-to-sid="$DOMAIN/$GROUPNAME" || failed=$(expr $failed + 1)
89 group_sid=$($wbinfo --name-to-sid="$DOMAIN/$GROUPNAME" | cut -d " " -f1)
90 echo "$DOMAIN/$GROUPNAME resolved to $group_sid"
92 testit "wbinfo --sid-to-gid=$group_sid" $wbinfo --sid-to-gid=$group_sid || failed=$(expr $failed + 1)
93 group_gid=$($wbinfo --sid-to-gid=$group_sid | cut -d " " -f1)
94 echo "$DOMAIN/$GROUPNAME resolved to $group_gid"
96 testit "test $group_gid -eq $GROUPGID" test $group_gid -eq $GROUPGID || failed=$(expr $failed + 1)
98 # Delete LDAP records
99 $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$USERNAME,$LDAPPREFIX"
100 $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "cn=$GROUPNAME,$LDAPPREFIX"
101 $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX"
103 exit $failed