3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-2011 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 mkdir -p $TESTDIR $DBDIR1
21 . $CONFFILTER $BACKEND $MONITORDB < $DNCONF > $CONF1
22 echo "Starting slapd on TCP/IP port $PORT1..."
23 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
25 if test $WAIT != 0 ; then
33 echo "Testing slapd DN parsing..."
34 for i in 0 1 2 3 4 5; do
35 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
36 'objectclass=*' > /dev/null 2>&1
38 if test $RC = 0 ; then
41 echo "Waiting 5 seconds for slapd to start..."
45 if test $RC != 0 ; then
46 echo "ldapsearch failed ($RC)!"
47 test $KILLSERVERS != no && kill -HUP $KILLPIDS
51 echo "Loading database..."
52 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD -c -f $LDIFDN > \
55 cat /dev/null > $SEARCHOUT
57 echo "Searching database..."
58 echo "# Searching database..." >> $SEARCHOUT
59 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 >> $SEARCHOUT 2>&1
62 if test $RC != 0 ; then
63 echo "ldapsearch failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 DN="OU=Sales+CN=J. Smith,DC=example,DC=net"
69 echo "Searching database for DN=\"$DN\"..."
70 echo "# Searching database for DN=\"$DN\"..." >> $SEARCHOUT
71 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
72 "(member=$DN)" >> $SEARCHOUT 2>&1
75 if test $RC != 0 ; then
76 echo "ldapsearch failed ($RC)!"
77 test $KILLSERVERS != no && kill -HUP $KILLPIDS
81 DN="testUUID=597ae2f6-16a6-1027-98f4-ABCDEFabcdef,DC=Example"
82 echo "Searching database for entryUUID-named DN=\"$DN\"..."
83 echo "# Searching database for entryUUID-named DN=\"$DN\"..." >> $SEARCHOUT
84 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
89 if test $RC != 0 ; then
90 echo "ldapsearch failed ($RC)!"
91 test $KILLSERVERS != no && kill -HUP $KILLPIDS
95 DN="dc=example,dc=com"
96 echo "Searching database for nameAndOptionalUID=\"$DN\"..."
97 echo "# Searching database for nameAndOptionalUID=\"$DN\"..." >> $SEARCHOUT
98 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
99 "(uniqueMember=$DN)" >> $SEARCHOUT 2>&1
102 if test $RC != 0 ; then
103 echo "ldapsearch failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 DN="dc=example,dc=com#'001000'B"
109 echo "Searching database for nameAndOptionalUID=\"$DN\"..."
110 echo "# Searching database for nameAndOptionalUID=\"$DN\"..." >> $SEARCHOUT
111 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
112 "(uniqueMember=$DN)" >> $SEARCHOUT 2>&1
115 if test $RC != 0 ; then
116 echo "ldapsearch failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 DN="dc=example,dc=com#'1000'B"
122 echo "Searching database for nameAndOptionalUID=\"$DN\"..."
123 echo "# Searching database for nameAndOptionalUID=\"$DN\"..." >> $SEARCHOUT
124 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
125 "(uniqueMember=$DN)" >> $SEARCHOUT 2>&1
128 if test $RC != 0 ; then
129 echo "ldapsearch failed ($RC)!"
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 DN="dc=example,dc=com"
135 echo "Searching database for uniqueMember~=\"$DN\" (approx)..."
136 echo "# Searching database for uniqueMember~=\"$DN\" (approx)..." >> $SEARCHOUT
137 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
138 "(uniqueMember~=)" >> $SEARCHOUT 2>&1
141 if test $RC != 0 ; then
142 echo "ldapsearch failed ($RC)!"
143 test $KILLSERVERS != no && kill -HUP $KILLPIDS
147 DN="dc=example,dc=com#'1000'B"
148 echo "Searching database for uniqueMember~=\"$DN\" (approx)..."
149 echo "# Searching database for uniqueMember~=\"$DN\" (approx)..." >> $SEARCHOUT
150 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
151 "(uniqueMember~=$DN)" >> $SEARCHOUT 2>&1
154 if test $RC != 0 ; then
155 echo "ldapsearch failed ($RC)!"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 echo "Filtering ldapsearch results..."
163 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
164 echo "Filtering original data..."
165 $LDIFFILTER < $DNOUT > $LDIFFLT
166 echo "Comparing ldapsearch results against original..."
167 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
169 if test $? != 0 ; then
170 echo "comparison failed - DN write operations did not complete correctly"
176 echo ">>>>> Test succeeded"
178 test $KILLSERVERS != no && wait