3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2010 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 $REFINT = refintno; then
26 echo "Referential Integrity overlay not available, test skipped"
30 if test $BACKEND = bdb; then
31 echo "$BACKEND backend does not support subtree rename, test skipped"
35 mkdir -p $TESTDIR $DBDIR1 $TESTDIR/confdir
37 $SLAPPASSWD -g -n >$CONFIGPWF
38 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
40 echo "Starting slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $NAKEDCONF > $CONF1
42 $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 if test $WAIT != 0 ; then
51 for i in 0 1 2 3 4 5; do
52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53 'objectclass=*' > /dev/null 2>&1
55 if test $RC = 0 ; then
58 echo "Waiting 5 seconds for slapd to start..."
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 cat /dev/null > $TESTOUT
69 bdbInclude="# " nullExclude=""
71 bdb | hdb) bdbInclude="" ;;
72 null) nullExclude="# " ;;
75 if [ "$MEMBEROF" = memberofmod ]; then
76 echo "Inserting memberof overlay on provider..."
77 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
78 dn: cn=module,cn=config
79 objectClass: olcModuleList
81 olcModulePath: ../servers/slapd/overlays
82 olcModuleLoad: memberof.la
83 olcModuleLoad: refint.la
86 if test $RC != 0 ; then
87 echo "ldapadd failed for moduleLoad ($RC)!"
88 test $KILLSERVERS != no && kill -HUP $KILLPIDS
93 echo "Running ldapadd to build slapd config database..."
94 $LDAPADD -h $LOCALHOST -p $PORT1 -D 'cn=config' -w `cat $CONFIGPWF` \
95 >> $TESTOUT 2>&1 <<EOF
96 dn: olcDatabase={1}$BACKEND,cn=config
97 objectClass: olcDatabaseConfig
98 ${nullExclude}objectClass: olc${BACKEND}Config
99 olcDatabase: {1}$BACKEND
101 olcRootDN: cn=Manager,$BASEDN
104 ${nullExclude}olcDbDirectory: $TESTDIR/db.1.a/
105 ${bdbInclude}olcDbCacheSize: 1000
106 ${bdbInclude}olcDbIndex: objectClass eq
107 ${bdbInclude}olcDbIndex: cn pres,eq,sub
108 ${bdbInclude}olcDbIndex: uid pres,eq,sub
109 ${bdbInclude}olcDbIndex: sn pres,eq,sub
110 ${bdbInclude}olcDbMode: 384
112 # {0}memberof, {1}$BACKEND, config
113 dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
114 objectClass: olcOverlayConfig
115 objectClass: olcMemberOf
116 olcOverlay: {0}memberof
117 olcMemberOfRefInt: TRUE
118 olcMemberOfGroupOC: groupOfNames
119 olcMemberOfMemberAD: member
120 olcMemberOfMemberOfAD: memberOf
122 # {1}refint, {1}$BACKEND, config
123 dn: olcOverlay={1}refint,olcDatabase={1}$BACKEND,cn=config
124 objectClass: olcOverlayConfig
125 objectClass: olcRefintConfig
126 olcOverlay: {1}refint
127 olcRefintAttribute: member
128 olcRefintAttribute: memberOf
131 if test $RC != 0 ; then
132 echo "ldapadd failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Running ldapadd to build slapd database..."
138 $LDAPADD -h $LOCALHOST -p $PORT1 \
139 -D "cn=Manager,$BASEDN" -w secret \
140 >> $TESTOUT 2>&1 << EOF
142 objectClass: organization
143 objectClass: dcObject
147 dn: ou=People,$BASEDN
148 objectClass: organizationalUnit
151 dn: ou=Groups,$BASEDN
152 objectClass: organizationalUnit
155 dn: cn=Roger Rabbit,ou=People,$BASEDN
156 objectClass: inetOrgPerson
160 dn: cn=Baby Herman,ou=People,$BASEDN
161 objectClass: inetOrgPerson
165 dn: cn=Cartoonia,ou=Groups,$BASEDN
166 objectClass: groupOfNames
168 member: cn=Roger Rabbit,ou=People,$BASEDN
169 member: cn=Baby Herman,ou=People,$BASEDN
172 if test $RC != 0 ; then
173 echo "ldapadd failed ($RC)!"
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 echo "Search the entire database..."
179 echo "# Search the entire database..." >> $SEARCHOUT
180 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
181 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
183 if test $RC != 0 ; then
184 echo "ldapsearch failed ($RC)!"
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 echo "Running ldapmodify to rename subtree..."
190 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
191 -D "cn=Manager,$BASEDN" -w secret \
192 >> $TESTOUT 2>&1 << EOF
193 dn: ou=People,$BASEDN
200 # refint runs in a background thread, so it most likely won't complete
201 # before the modify returns. Give it some time to execute.
204 echo "Re-search the entire database..."
205 echo "# Re-search the entire database..." >> $SEARCHOUT
206 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
207 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
209 if test $RC != 0 ; then
210 echo "ldapsearch failed ($RC)!"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 echo "Running ldapmodify to rename subtree..."
216 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
217 -D "cn=Manager,$BASEDN" -w secret \
218 >> $TESTOUT 2>&1 << EOF
219 dn: ou=Groups,$BASEDN
228 echo "Re-search the entire database..."
229 echo "# Re-search the entire database..." >> $SEARCHOUT
230 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
231 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
233 if test $RC != 0 ; then
234 echo "ldapsearch failed ($RC)!"
235 test $KILLSERVERS != no && kill -HUP $KILLPIDS
239 echo "Running ldapdelete to remove a member..."
240 $LDAPMODIFY -h $LOCALHOST -p $PORT1 \
241 -D "cn=Manager,$BASEDN" -w secret \
242 >> $TESTOUT 2>&1 << EOF
243 dn: cn=Baby Herman,ou=Toons,$BASEDN
249 echo "Re-search the entire database..."
250 echo "# Re-search the entire database..." >> $SEARCHOUT
251 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
252 '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
254 if test $RC != 0 ; then
255 echo "ldapsearch failed ($RC)!"
256 test $KILLSERVERS != no && kill -HUP $KILLPIDS
260 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 LDIF=$MEMBEROFREFINTOUT
264 echo "Filtering ldapsearch results..."
265 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
266 echo "Filtering original ldif used to create database..."
267 $LDIFFILTER < $LDIF > $LDIFFLT
268 echo "Comparing filter output..."
269 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
271 if test $? != 0 ; then
272 echo "Comparison failed"
276 echo ">>>>> Test succeeded"
278 test $KILLSERVERS != no && wait