]> git.sur5r.net Git - openldap/blobdiff - tests/scripts/test025-limits
fix ITS#4479
[openldap] / tests / scripts / test025-limits
index 7e9c771c85ca2ef50e2e3236c1f2aabd709d5204..14e9560a36fe1512996f76c4ee49eb212c3220fc 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2006 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -13,6 +13,8 @@
 ## top-level directory of the distribution or, alternatively, at
 ## <http://www.OpenLDAP.org/license.html>.
 
+## FIXME: need to exclude legal but wrong results...
+
 echo "running defines.sh"
 . $SRCDIR/scripts/defines.sh
 
@@ -45,6 +47,8 @@ if test $WAIT != 0 ; then
 fi
 KILLPIDS="$PID"
 
+sleep 1
+
 echo "Testing slapd searching..."
 for i in 0 1 2 3 4 5; do
        $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
@@ -65,15 +69,92 @@ fi
 
 cat /dev/null > $SEARCHOUT
 
+echo ""
+echo "Testing regular search limits"
+echo ""
+
 echo "Testing no limits requested for unlimited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' >$SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...success (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limits requested for rootdn=$MANAGERDN..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D "$MANAGERDN" \
+       '(objectClass=*)' >$SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...success (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=4
+echo "Testing limit requested for rootdn=$MANAGERDN..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D "$MANAGERDN" \
+       '(objectClass=*)' >$SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit 1
+                       fi
+                       echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...bumped into requested size limit ($SIZELIMIT)"
+                       else
+                               echo "...error: got $COUNT entries with a requested sizelimit of $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -85,16 +166,39 @@ esac
 SIZELIMIT=2
 echo "Testing size limit request ($SIZELIMIT) for unlimited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
-       -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit 1
+                       fi
+                       echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
        ;;
        4)
-               echo "...bumped into requested size limit ($SIZELIMIT)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...bumped into requested size limit ($SIZELIMIT)"
+                       else
+                               echo "...error: got $COUNT entries with a requested sizelimit of $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -106,16 +210,25 @@ esac
 TIMELIMIT=10
 echo "Testing time limit request ($TIMELIMIT s) for unlimited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -l $TIMELIMIT \
-       -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into the requested time limit ($TIMELIMIT s; got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
        ;;
        3)
-               echo "...bumped into requested time limit ($TIMELIMIT s; $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       COUNT=0
+               fi
+               echo "...bumped into requested time limit ($TIMELIMIT s; got $COUNT entries)"
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -126,16 +239,28 @@ esac
 
 echo "Testing no limits requested for soft limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
        ;;
        4)
-               echo "...bumped into server-side size limit ($COUNT)"
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -147,23 +272,36 @@ esac
 SIZELIMIT=2
 echo "Testing lower than soft limit request ($SIZELIMIT) for soft limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
-       -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit 1
+                       fi
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test $SIZELIMIT = $COUNT ; then
+                       if test "x$SIZELIMIT" = "x$COUNT" ; then
                                echo "...bumped into requested ($SIZELIMIT) size limit"
                        else
                                echo "...bumped into server-side size limit ($COUNT)"
                        fi
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
                fi
        ;;
        *)
@@ -176,23 +314,36 @@ esac
 SIZELIMIT=100
 echo "Testing higher than soft limit request ($SIZELIMIT) for soft limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
-       -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit 1
+                       fi
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test $SIZELIMIT = $COUNT ; then
+                       if test "x$SIZELIMIT" = "x$COUNT" ; then
                                echo "...bumped into requested ($SIZELIMIT) size limit"
                        else
                                echo "...bumped into server-side size limit ($COUNT)"
                        fi
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
                fi
        ;;
        *)
@@ -205,13 +356,24 @@ esac
 SIZELIMIT=2
 echo "Testing lower than hard limit request ($SIZELIMIT) for hard limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
-       -D 'cn=Hard Limited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit 1
+                       fi
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
        ;;
        4)
                echo "...bumped into requested ($SIZELIMIT) size limit"
@@ -226,20 +388,79 @@ esac
 SIZELIMIT=100
 echo "Testing higher than hard limit request ($SIZELIMIT) for hard limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
-       -D 'cn=Hard Limited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" -gt "$SIZELIMIT" ; then
+                               echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit 1
+                       fi
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
        ;;
        4)
-               echo "...bumped into requested ($SIZELIMIT) size limit"
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...error: bumped into requested ($SIZELIMIT) size limit"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       else
+                               echo "...got size limit $COUNT instead of requested $SIZELIMIT entries"
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
        ;;
-       11)
-               echo "...bumped into server-side size limit"
+#      11)
+#              echo "...bumped into server-side hard size administrative limit"
+#      ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
        ;;
+esac
+
+SIZELIMIT=max
+echo "Testing max limit request ($SIZELIMIT) for hard limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
+       '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
+       ;;
+#      11)
+#              echo "...bumped into server-side hard size administrative limit"
+#      ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -249,16 +470,24 @@ esac
 
 echo "Testing lower than unchecked limit request for unchecked limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Unchecked Limited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \
        '(uid=uncheckedlimited)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
        ;;
        11)
-               echo "...bumped into server-side unchecked limit"
+               echo "...error: bumped into unchecked administrative limit"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -269,16 +498,22 @@ esac
 
 echo "Testing higher than unchecked limit requested for unchecked limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Unchecked Limited User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+               fi
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit 1
        ;;
        11)
-               echo "...bumped into server-side unchecked limit"
+               echo "...bumped into unchecked administrative limit"
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -287,18 +522,24 @@ case $RC in
        ;;
 esac
 
-echo "Testing higher than unchecked limit requested for unchecked limited group..."
+echo "Testing no limits requested for unchecked limited group..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Unchecked Limited User 2,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Unchecked Limited User 2,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+               fi
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit 1
        ;;
        11)
-               echo "...bumped into server-side unchecked limit"
+               echo "...bumped into unchecked administrative limit"
        ;;
        *)
                echo "ldapsearch failed ($RC)!"
@@ -307,25 +548,29 @@ case $RC in
        ;;
 esac
 
-echo "Testing higher than unchecked limit requested for unchecked limited regex..."
+echo "Testing no limits requested for limited regex..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Foo User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Foo User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test $SIZELIMIT = $COUNT ; then
-                               echo "...bumped into requested ($SIZELIMIT) size limit"
-                       else
-                               echo "...bumped into server-side size limit ($COUNT)"
-                       fi
+                       echo "...bumped into server-side size limit ($COUNT)"
                else
-                       echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
                fi
        ;;
        *)
@@ -335,19 +580,350 @@ case $RC in
        ;;
 esac
 
-echo "Testing higher than unchecked limit requested for unchecked limited onelevel..."
+echo "Testing no limits requested for limited onelevel..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Bar User,ou=People,o=University of Michigan,c=US' \
+       -D 'cn=Bar User,ou=People,dc=example,dc=com' \
        '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
+       ;;
+       4)
+               if test "x$COUNT" != "x" ; then
+                       echo "...bumped into server-side size limit ($COUNT)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limit requested for limited children..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Unchecked Limited Users,ou=Groups,dc=example,dc=com' \
+       '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
+       ;;
+       4)
+               if test "x$COUNT" != "x" ; then
+                       echo "...bumped into server-side size limit ($COUNT)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limit requested for limited subtree..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Unchecked Limited User 3,ou=Admin,dc=example,dc=com' \
+       '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
+       ;;
+       4)
+               if test "x$COUNT" != "x" ; then
+                       echo "...bumped into server-side size limit ($COUNT)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limit requested for limited users..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Special User,dc=example,dc=com' \
+       '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
+       ;;
+       4)
+               if test "x$COUNT" != "x" ; then
+                       echo "...bumped into server-side size limit ($COUNT)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limit requested for limited anonymous..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+       '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit 1
+               fi
+       ;;
+       4)
+               if test "x$COUNT" != "x" ; then
+                       echo "...bumped into server-side size limit ($COUNT)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+case $BACKEND in
+       bdb | hdb)
+               # only bdb|hdb currently supports pagedResults control
+               ;;
+       *)
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+
+               echo ">>>>> Test succeeded"
+               exit 0
+       ;;
+esac
+
+if test x"$SLAPD_PAGE_SIZE" != x ; then
+       PAGESIZE="$SLAPD_PAGE_SIZE"
+       if test "$PAGESIZE" -le 0 ; then
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+
+               echo ""
+               echo "Testing with pagedResults control disabled"
+               echo ""
+               echo ">>>>> Test succeeded"
+               exit 0
+       fi
+else
+       PAGESIZE=5
+fi
+
+echo ""
+echo "Testing regular search limits with pagedResults control (page size $PAGESIZE)"
+echo ""
+
+echo "Testing no limits requested for unlimited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' >$SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...success (got $COUNT entries)"
+               else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=2
+echo "Testing size limit request ($SIZELIMIT) for unlimited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit 1
+                        fi
+                        echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       if test $COUNT = $SIZELIMIT ; then
+                               echo "...bumped into requested size limit ($SIZELIMIT)"
+                       else
+                               echo "...error: got $COUNT entries while requesting $SIZELIMIT..."
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+TIMELIMIT=10
+echo "Testing time limit request ($TIMELIMIT s) for unlimited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -l $TIMELIMIT \
+       -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into the requested time limit ($TIMELIMIT s; got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       3)
+               if test x"$COUNT" = x ; then
+                       COUNT=0
+               fi
+               echo "...bumped into requested time limit ($TIMELIMIT s; got $COUNT entries)"
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limits requested for soft limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+               fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=2
+echo "Testing lower than soft limit request ($SIZELIMIT) for soft limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit 1
+                        fi
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test $SIZELIMIT = $COUNT ; then
+                       if test "x$SIZELIMIT" = "x$COUNT" ; then
                                echo "...bumped into requested ($SIZELIMIT) size limit"
                        else
                                echo "...bumped into server-side size limit ($COUNT)"
@@ -363,19 +939,31 @@ case $RC in
        ;;
 esac
 
-echo "Testing higher than unchecked limit requested for unchecked limited children..."
-$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Unchecked Limited Users,ou=Groups,o=University of Michigan,c=US' \
-       '(objectClass=*)' > $SEARCHOUT 2>&1
+SIZELIMIT=100
+echo "Testing higher than soft limit request ($SIZELIMIT) for soft limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit 1
+                        fi
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test $SIZELIMIT = $COUNT ; then
+                       if test "x$SIZELIMIT" = "x$COUNT" ; then
                                echo "...bumped into requested ($SIZELIMIT) size limit"
                        else
                                echo "...bumped into server-side size limit ($COUNT)"
@@ -391,19 +979,304 @@ case $RC in
        ;;
 esac
 
-echo "Testing higher than unchecked limit requested for unchecked limited subtree..."
+SIZELIMIT=2
+echo "Testing lower than hard limit request ($SIZELIMIT) for hard limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit 1
+                        fi
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...bumped into requested ($SIZELIMIT) size limit"
+                       else
+                               echo "...error: got size limit $SIZELIMIT but $COUNT entries"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+                fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=100
+echo "Testing higher than hard limit request ($SIZELIMIT) for hard limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit 1
+                        fi
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       if test "$COUNT" = "$SIZELIMIT" ; then
+                               echo "...error: bumped into requested ($SIZELIMIT) size limit"
+                               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                               exit $RC
+                       else
+                               echo "...got size limit $COUNT instead of requested $SIZELIMIT entries"
+                       fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+#      11)
+#              echo "...bumped into hard size administrative limit"
+#      ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=max
+echo "Testing max limit request ($SIZELIMIT) for hard limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit"
+               else
+                       echo "...error: bumped into size limit but got no entries!"
+                       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                       exit $RC
+               fi
+       ;;
+#      11)
+#              echo "...bumped into hard size administrative limit"
+#      ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing lower than unchecked limit request for unchecked limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Unchecked Limited User 3,ou=Admin,o=University of Michigan,c=US' \
-       '(objectClass=*)' > $SEARCHOUT 2>&1
+       -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(uid=uncheckedlimited)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               if test x"$COUNT" != x ; then
+                        echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+#      11)
+#              echo "...bumped into unchecked administrative limit"
+#      ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing higher than unchecked limit requested for unchecked limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                fi
+                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                exit 1
+       ;;
+       11)
+               echo "...bumped into unchecked administrative limit"
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo ""
+echo "Testing specific search limits with pagedResults control"
+echo ""
+
+echo "Testing no limit requested for unlimited page size ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Unlimited User,ou=Paged Results Users,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                       echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       echo "...bumped into server-side size limit (got $COUNT entries)"
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limit requested for limited page size ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Page Size Limited User,ou=Paged Results Users,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               echo "...success; didn't bump into server-side page size limit (got $COUNT entries)"
+       ;;
+       4)
+               echo "...bumped into page size limit ($COUNT)"
+       ;;
+       11)
+               echo "...bumped into page size administrative limit"
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limit requested for pagedResults disabled ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Paged Results Disabled User,ou=Paged Results Users,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+       ;;
+       4)
+               echo "...bumped into server-side size limit ($COUNT)"
+       ;;
+       11)
+               echo "...bumped into pagedResults disabled administrative limit"
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+echo "Testing no limit requested for pagedResults total count limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
+       ;;
+       4)
+               echo "...bumped into server-side size limit ($COUNT)"
+       ;;
+       11)
+               echo "...bumped into pagedResults total count administrative limit"
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+SIZELIMIT=8
+echo "Testing higher than hard but lower then total count limit requested for pagedResults total count limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
+       -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test $SIZELIMIT = $COUNT ; then
+                       if test "x$SIZELIMIT" = "x$COUNT" ; then
                                echo "...bumped into requested ($SIZELIMIT) size limit"
                        else
                                echo "...bumped into server-side size limit ($COUNT)"
@@ -412,6 +1285,9 @@ case $RC in
                        echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
                fi
        ;;
+       11)
+               echo "...bumped into either hard size or pagedResults total count administrative limit"
+       ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -419,19 +1295,20 @@ case $RC in
        ;;
 esac
 
-echo "Testing higher than unchecked limit requested for unchecked limited users..."
+SIZELIMIT=15
+echo "Testing higher than total count limit requested for pagedResults total count limited ID..."
 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
-       -D 'cn=Special User,o=University of Michigan,c=US' \
-       '(objectClass=*)' > $SEARCHOUT 2>&1
+       -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
+       -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test $SIZELIMIT = $COUNT ; then
+                       if test "x$SIZELIMIT" = "x$COUNT" ; then
                                echo "...bumped into requested ($SIZELIMIT) size limit"
                        else
                                echo "...bumped into server-side size limit ($COUNT)"
@@ -440,6 +1317,9 @@ case $RC in
                        echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
                fi
        ;;
+       11)
+               echo "...bumped into pagedResults total count administrative limit"
+       ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -447,18 +1327,20 @@ case $RC in
        ;;
 esac
 
-echo "Testing higher than unchecked limit requested for unchecked limited anonymous..."
-$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
-       '(objectClass=*)' > $SEARCHOUT 2>&1
+SIZELIMIT=max
+echo "Testing max limit requested for pagedResults total count limited ID..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
+       -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
+       -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
 RC=$?
-COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
 case $RC in
        0)
-               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
+               echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
        ;;
        4)
                if test "x$COUNT" != "x" ; then
-                       if test $SIZELIMIT = $COUNT ; then
+                       if test "x$SIZELIMIT" = "x$COUNT" ; then
                                echo "...bumped into requested ($SIZELIMIT) size limit"
                        else
                                echo "...bumped into server-side size limit ($COUNT)"
@@ -467,6 +1349,55 @@ case $RC in
                        echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
                fi
        ;;
+       11)
+               echo "...bumped into pagedResults total count administrative limit"
+       ;;
+       *)
+               echo "ldapsearch failed ($RC)!"
+               test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               exit $RC
+       ;;
+esac
+
+# ITS#4479
+PAGESIZE=1
+SIZELIMIT=2
+echo "Testing size limit request ($SIZELIMIT) for unlimited ID and pagesize=$PAGESIZE..."
+$LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
+       -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
+       -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
+RC=$?
+COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
+case $RC in
+       0)
+               if test x"$COUNT" != x ; then
+                        if test "$COUNT" -gt "$SIZELIMIT" ; then
+                                echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit 1
+                        fi
+                        echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
+                else
+                        echo "...error: did not expect ldapsearch success ($RC)!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit 1
+                fi
+       ;;
+       4)
+               if test x"$COUNT" != x ; then
+                       if test $COUNT = $SIZELIMIT ; then
+                               echo "...bumped into requested size limit ($SIZELIMIT)"
+                       else
+                               echo "...error: got $COUNT entries while requesting $SIZELIMIT..."
+                                test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                                exit $RC
+                        fi
+               else
+                       echo "...error: bumped into server-side size limit, but got no entries!"
+                        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+                        exit $RC
+               fi
+       ;;
        *)
                echo "ldapsearch failed ($RC)!"
                test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -477,4 +1408,7 @@ esac
 test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
 echo ">>>>> Test succeeded"
+
+test $KILLSERVERS != no && wait
+
 exit 0