+ int total;
+ int slimit2 = -1;
+
+ /* first round of pagedResults: set count to any appropriate limit */
+
+ /* if the limit is set, check that it does not violate any limit */
+ if ( op->ors_slimit > 0 ) {
+ slimit2 = op->ors_slimit;
+ if ( op->ors_limit->lms_s_pr_total > 0 ) {
+ if ( op->ors_slimit > op->ors_limit->lms_s_pr_total ) {
+ slimit2 = -2;
+ }
+
+ } else if ( op->ors_limit->lms_s_hard > 0 ) {
+ if ( op->ors_slimit > op->ors_limit->lms_s_hard ) {
+ slimit2 = -2;
+ }
+
+ } else if ( op->ors_limit->lms_s_soft > 0 && op->ors_slimit > op->ors_limit->lms_s_soft ) {
+ if ( op->ors_slimit > op->ors_limit->lms_s_soft ) {
+ slimit2 = -2;
+ }
+ }
+
+ if ( slimit2 == -2 ) {
+ rs->sr_err = LDAP_ADMINLIMIT_EXCEEDED;
+ send_ldap_result( op, rs );
+ rs->sr_err = LDAP_SUCCESS;
+ return -1;
+ }
+
+ } else {
+ if ( op->ors_limit->lms_s_pr_total > 0 ) {
+ slimit2 = op->ors_limit->lms_s_pr_total;
+
+ } else if ( op->ors_limit->lms_s_hard > 0 ) {
+ slimit2 = op->ors_limit->lms_s_hard;
+
+ } else if ( op->ors_limit->lms_s_soft > 0 ) {
+ slimit2 = op->ors_limit->lms_s_soft;
+ }
+ }
+
+ total = slimit2 - op->o_pagedresults_state.ps_count;