3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2009 The OpenLDAP Foundation.
6 ## Portions Copyright 2008 Red Hat, Inc.
7 ## All rights reserved.
9 ## Redistribution and use in source and binary forms, with or without
10 ## modification, are permitted only as authorized by the OpenLDAP
13 ## A copy of this license is available in the file LICENSE in the
14 ## top-level directory of the distribution or, alternatively, at
15 ## <http://www.OpenLDAP.org/license.html>.
17 echo "running defines.sh"
18 . $SRCDIR/scripts/defines.sh
20 if test $MEMBEROF = memberofno; then
21 echo "Memberof overlay not available, test skipped"
25 if test "$BACKEND" != "hdb" ; then
26 echo "Test does not support $BACKEND"
30 mkdir -p $TESTDIR $DBDIR1 $TESTDIR/confdir
32 $SLAPPASSWD -g -n >$CONFIGPWF
33 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 . $CONFFILTER $BACKEND $MONITORDB < $NAKEDCONF > $CONF1
37 $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
39 if test $WAIT != 0 ; then
46 for i in 0 1 2 3 4 5; do
47 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
48 'objectclass=*' > /dev/null 2>&1
50 if test $RC = 0 ; then
53 echo "Waiting 5 seconds for slapd to start..."
56 if test $RC != 0 ; then
57 echo "ldapsearch failed ($RC)!"
58 test $KILLSERVERS != no && kill -HUP $KILLPIDS
62 cat /dev/null > $TESTOUT
64 if [ "$MEMBEROF" = memberofmod ]; then
65 echo "Inserting memberof overlay on producer..."
66 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
67 dn: cn=module,cn=config
68 objectClass: olcModuleList
70 olcModulePath: ../servers/slapd/overlays
71 olcModuleLoad: memberof.la
72 olcModuleLoad: refint.la
75 if test $RC != 0 ; then
76 echo "ldapadd failed for moduleLoad ($RC)!"
77 test $KILLSERVERS != no && kill -HUP $KILLPIDS
82 echo "Running ldapadd to build slapd config database..."
83 $LDAPADD -h $LOCALHOST -p $PORT1 -D 'cn=config' -w `cat $CONFIGPWF` \
84 >> $TESTOUT 2>&1 <<EOF
85 dn: olcDatabase={1}$BACKEND,cn=config
86 objectClass: olcDatabaseConfig
87 objectClass: olc${BACKEND}Config
88 olcDatabase: {1}$BACKEND
90 olcRootDN: cn=Manager,$BASEDN
93 olcDbDirectory: $TESTDIR/db.1.a/
95 olcDbIndex: objectClass eq
96 olcDbIndex: cn pres,eq,sub
97 olcDbIndex: uid pres,eq,sub
98 olcDbIndex: sn pres,eq,sub
101 # {0}memberof, {1}$BACKEND, config
102 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
103 objectClass: olcOverlayConfig
104 objectClass: olcMemberOf
105 olcOverlay: {0}memberof
106 olcMemberOfRefInt: TRUE
107 olcMemberOfGroupOC: groupOfNames
108 olcMemberOfMemberAD: member
109 olcMemberOfMemberOfAD: memberOf
111 # {1}refint, {1}$BACKEND, config
112 dn: olcOverlay={1}refint,olcDatabase={1}$BACKEND,cn=config
113 objectClass: olcOverlayConfig
114 objectClass: olcRefintConfig
115 olcOverlay: {1}refint
116 olcRefintAttribute: member
117 olcRefintAttribute: memberOf
120 if test $RC != 0 ; then
121 echo "ldapadd failed ($RC)!"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 echo "Running ldapadd to build slapd database..."
127 $LDAPADD -h $LOCALHOST -p $PORT1 \
128 -D "cn=Manager,$BASEDN" -w secret \
129 >> $TESTOUT 2>&1 << EOF
131 objectClass: organization
132 objectClass: dcObject
136 dn: ou=People,$BASEDN
137 objectClass: organizationalUnit
140 dn: ou=Groups,$BASEDN
141 objectClass: organizationalUnit
144 dn: cn=Roger Rabbit,ou=People,$BASEDN
145 objectClass: inetOrgPerson
149 dn: cn=Baby Herman,ou=People,$BASEDN
150 objectClass: inetOrgPerson
154 dn: cn=Cartoonia,ou=Groups,$BASEDN
155 objectClass: groupOfNames
157 member: cn=Roger Rabbit,ou=People,$BASEDN
158 member: cn=Baby Herman,ou=People,$BASEDN
161 if test $RC != 0 ; then
162 echo "ldapadd failed ($RC)!"
163 test $KILLSERVERS != no && kill -HUP $KILLPIDS
167 echo "Search the entire database..."
168 echo "# Search the entire database..." >> $SEARCHOUT
169 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
170 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
172 if test $RC != 0 ; then
173 echo "ldapsearch failed ($RC)!"
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 echo "Running ldapmodify to rename subtree..."
179 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
180 -D "cn=Manager,$BASEDN" -w secret \
181 >> $TESTOUT 2>&1 << EOF
182 dn: ou=People,$BASEDN
189 # refint runs in a background thread, so it most likely won't complete
190 # before the modify returns. Give it some time to execute.
193 echo "Re-search the entire database..."
194 echo "# Re-search the entire database..." >> $SEARCHOUT
195 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
196 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
198 if test $RC != 0 ; then
199 echo "ldapsearch failed ($RC)!"
200 test $KILLSERVERS != no && kill -HUP $KILLPIDS
204 echo "Running ldapmodify to rename subtree..."
205 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
206 -D "cn=Manager,$BASEDN" -w secret \
207 >> $TESTOUT 2>&1 << EOF
208 dn: ou=Groups,$BASEDN
217 echo "Re-search the entire database..."
218 echo "# Re-search the entire database..." >> $SEARCHOUT
219 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
220 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
222 if test $RC != 0 ; then
223 echo "ldapsearch failed ($RC)!"
224 test $KILLSERVERS != no && kill -HUP $KILLPIDS
228 echo "Running ldapdelete to remove a member..."
229 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
230 -D "cn=Manager,$BASEDN" -w secret \
231 >> $TESTOUT 2>&1 << EOF
232 dn: cn=Baby Herman,ou=Toons,$BASEDN
238 echo "Re-search the entire database..."
239 echo "# Re-search the entire database..." >> $SEARCHOUT
240 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
241 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
243 if test $RC != 0 ; then
244 echo "ldapsearch failed ($RC)!"
245 test $KILLSERVERS != no && kill -HUP $KILLPIDS
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
251 LDIF=$MEMBEROFREFINTOUT
253 echo "Filtering ldapsearch results..."
254 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
255 echo "Filtering original ldif used to create database..."
256 . $LDIFFILTER < $LDIF > $LDIFFLT
257 echo "Comparing filter output..."
258 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
260 if test $? != 0 ; then
261 echo "Comparison failed"
265 echo ">>>>> Test succeeded"
267 test $KILLSERVERS != no && wait