]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/search.c
ITS#1716 is_entry_subentr/ies/y/
[openldap] / servers / slapd / back-bdb / search.c
1 /* search.c - search operation */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11 #include <ac/string.h>
12
13 #include "back-bdb.h"
14 #include "idl.h"
15 #include "external.h"
16
17 static int base_candidate(
18         BackendDB       *be,
19         Entry   *e,
20         ID              *ids );
21 static int search_candidates(
22         BackendDB *be,
23         Operation *op,
24         Entry *e,
25         Filter *filter,
26         int scope,
27         int deref,
28         ID      *ids );
29
30 int
31 bdb_search(
32         BackendDB       *be,
33         Connection      *conn,
34         Operation       *op,
35         struct berval   *base,
36         struct berval   *nbase,
37         int             scope,
38         int             deref,
39         int             slimit,
40         int             tlimit,
41         Filter  *filter,
42         struct berval   *filterstr,
43         AttributeName   *attrs,
44         int             attrsonly )
45 {
46         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
47         int              abandon;
48         int             rc;
49         const char *text = NULL;
50         time_t          stoptime;
51         ID              id, cursor;
52         ID              candidates[BDB_IDL_UM_SIZE];
53         Entry           *e = NULL;
54         BerVarray v2refs = NULL;
55         Entry   *matched = NULL;
56         struct berval   realbase = { 0, NULL };
57         int             nentries = 0;
58         int             manageDSAit;
59
60         struct slap_limits_set *limit = NULL;
61         int isroot = 0;
62
63 #ifdef NEW_LOGGING
64         LDAP_LOG (( "search", LDAP_LEVEL_ENTRY,"bdb_back_search\n"));
65 #else
66         Debug( LDAP_DEBUG_TRACE, "=> bdb_back_search\n",
67                 0, 0, 0);
68 #endif
69
70         manageDSAit = get_manageDSAit( op );
71
72         if ( nbase->bv_len == 0 ) {
73                 /* DIT root special case */
74                 e = (Entry *) &slap_entry_root;
75                 rc = 0;
76         } else                                          
77 #ifdef BDB_ALIASES
78         /* get entry with reader lock */
79         if ( deref & LDAP_DEREF_FINDING ) {
80                 e = deref_dn_r( be, nbase-, &err, &matched, &text );
81
82         } else
83 #endif
84         {
85                 rc = bdb_dn2entry_r( be, NULL, nbase, &e, &matched, 0 );
86         }
87
88         switch(rc) {
89         case DB_NOTFOUND:
90         case 0:
91                 break;
92         default:
93                 if (e != NULL) {
94                         bdb_cache_return_entry_w(&bdb->bi_cache, e);
95                 }
96                 if (matched != NULL) {
97                         bdb_cache_return_entry_r(&bdb->bi_cache, matched);
98                 }
99                 send_ldap_result( conn, op, rc=LDAP_OTHER,
100                         NULL, "internal error", NULL, NULL );
101                 return rc;
102         }
103
104         if ( e == NULL ) {
105                 struct berval matched_dn = { 0, NULL };
106                 BerVarray refs = NULL;
107
108                 if ( matched != NULL ) {
109                         BerVarray erefs;
110
111                         ber_dupbv( &matched_dn, &matched->e_name );
112
113                         erefs = is_entry_referral( matched )
114                                 ? get_entry_referrals( be, conn, op, matched )
115                                 : NULL;
116
117                         bdb_cache_return_entry_r (&bdb->bi_cache, matched);
118                         matched = NULL;
119
120                         if( erefs ) {
121                                 refs = referral_rewrite( erefs, &matched_dn,
122                                         base, scope );
123                                 ber_bvarray_free( erefs );
124                         }
125
126                 } else {
127                         refs = referral_rewrite( default_referral,
128                                 NULL, base, scope );
129                 }
130
131                 send_ldap_result( conn, op,     rc=LDAP_REFERRAL ,
132                         matched_dn.bv_val, text, refs, NULL );
133
134                 if ( refs ) ber_bvarray_free( refs );
135                 if ( matched_dn.bv_val ) ber_memfree( matched_dn.bv_val );
136                 return rc;
137         }
138
139         if (!manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) {
140                 /* entry is a referral, don't allow add */
141                 struct berval matched_dn;
142                 BerVarray erefs, refs;
143                 
144                 ber_dupbv( &matched_dn, &e->e_name );
145                 erefs = get_entry_referrals( be, conn, op, e );
146                 refs = NULL;
147
148                 bdb_cache_return_entry_r( &bdb->bi_cache, e );
149                 e = NULL;
150
151                 if( erefs ) {
152                         refs = referral_rewrite( erefs, &matched_dn,
153                                 base, scope );
154                         ber_bvarray_free( erefs );
155                 }
156
157 #ifdef NEW_LOGGING
158                 LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: entry is referral\n"));
159 #else
160                 Debug( LDAP_DEBUG_TRACE, "bdb_search: entry is referral\n",
161                         0, 0, 0 );
162 #endif
163
164                 send_ldap_result( conn, op, LDAP_REFERRAL,
165                         matched_dn.bv_val,
166                         refs ? NULL : "bad referral object",
167                         refs, NULL );
168
169                 ber_bvarray_free( refs );
170                 ber_memfree( matched_dn.bv_val );
171                 return 1;
172         }
173
174         /* if not root, get appropriate limits */
175         if ( be_isroot( be, &op->o_ndn ) ) {
176                 isroot = 1;
177         } else {
178                 ( void ) get_limits( be, &op->o_ndn, &limit );
179         }
180
181         /* The time/size limits come first because they require very little
182          * effort, so there's no chance the candidates are selected and then 
183          * the request is not honored only because of time/size constraints */
184
185         /* if no time limit requested, use soft limit (unless root!) */
186         if ( isroot ) {
187                 if ( tlimit == 0 ) {
188                         tlimit = -1;    /* allow root to set no limit */
189                 }
190
191                 if ( slimit == 0 ) {
192                         slimit = -1;
193                 }
194
195         } else {
196                 /* if no limit is required, use soft limit */
197                 if ( tlimit <= 0 ) {
198                         tlimit = limit->lms_t_soft;
199
200                 /* if requested limit higher than hard limit, abort */
201                 } else if ( tlimit > limit->lms_t_hard ) {
202                         /* no hard limit means use soft instead */
203                         if ( limit->lms_t_hard == 0 ) {
204                                 tlimit = limit->lms_t_soft;
205
206                         /* positive hard limit means abort */
207                         } else if ( limit->lms_t_hard > 0 ) {
208                                 send_search_result( conn, op, 
209                                                 LDAP_UNWILLING_TO_PERFORM,
210                                                 NULL, NULL, NULL, NULL, 0 );
211                                 rc = 0;
212                                 goto done;
213                         }
214                 
215                         /* negative hard limit means no limit */
216                 }
217                 
218                 /* if no limit is required, use soft limit */
219                 if ( slimit <= 0 ) {
220                         slimit = limit->lms_s_soft;
221
222                 /* if requested limit higher than hard limit, abort */
223                 } else if ( slimit > limit->lms_s_hard ) {
224                         /* no hard limit means use soft instead */
225                         if ( limit->lms_s_hard == 0 ) {
226                                 slimit = limit->lms_s_soft;
227
228                         /* positive hard limit means abort */
229                         } else if ( limit->lms_s_hard > 0 ) {
230                                 send_search_result( conn, op, 
231                                                 LDAP_UNWILLING_TO_PERFORM,
232                                                 NULL, NULL, NULL, NULL, 0 );
233                                 rc = 0; 
234                                 goto done;
235                         }
236                         
237                         /* negative hard limit means no limit */
238                 }
239         }
240
241         /* compute it anyway; root does not use it */
242         stoptime = op->o_time + tlimit;
243
244         /* select candidates */
245         if ( scope == LDAP_SCOPE_BASE ) {
246                 rc = base_candidate( be, e, candidates );
247
248         } else {
249                 BDB_IDL_ALL( bdb, candidates );
250                 rc = search_candidates( be, op, e, filter,
251                         scope, deref, candidates );
252         }
253
254         /* need normalized dn below */
255         ber_dupbv( &realbase, &e->e_nname );
256
257         /* start cursor at base entry's id 
258          * FIXME: hack to make "" base work
259          * FIXME: moddn needs to assign new ID for this to work
260          */
261         cursor = e->e_id == NOID ? 1 : e->e_id;
262
263         if ( e != &slap_entry_root ) {
264                 bdb_cache_return_entry_r(&bdb->bi_cache, e);
265         }
266         e = NULL;
267
268         if ( candidates[0] == 0 ) {
269 #ifdef NEW_LOGGING
270         LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: no candidates\n"));
271 #else
272                 Debug( LDAP_DEBUG_TRACE, "bdb_search: no candidates\n",
273                         0, 0, 0 );
274 #endif
275
276                 send_search_result( conn, op,
277                         LDAP_SUCCESS,
278                         NULL, NULL, NULL, NULL, 0 );
279
280                 rc = 1;
281                 goto done;
282         }
283
284         /* if not root and candidates exceed to-be-checked entries, abort */
285         if ( !isroot && limit->lms_s_unchecked != -1 ) {
286                 if ( BDB_IDL_N(candidates) > (unsigned) limit->lms_s_unchecked ) {
287                         send_search_result( conn, op, 
288                                         LDAP_UNWILLING_TO_PERFORM,
289                                         NULL, NULL, NULL, NULL, 0 );
290                         rc = 1;
291                         goto done;
292                 }
293         }
294
295         for ( id = bdb_idl_first( candidates, &cursor );
296                 id != NOID;
297                 id = bdb_idl_next( candidates, &cursor ) )
298         {
299                 int             scopeok = 0;
300
301                 /* check for abandon */
302                 ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
303                 abandon = op->o_abandon;
304                 ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
305
306                 if ( abandon ) {
307                         rc = 0;
308                         goto done;
309                 }
310
311                 /* check time limit */
312                 if ( tlimit != -1 && slap_get_time() > stoptime ) {
313                         send_search_result( conn, op, rc = LDAP_TIMELIMIT_EXCEEDED,
314                                 NULL, NULL, v2refs, NULL, nentries );
315                         goto done;
316                 }
317
318                 /* get the entry with reader lock */
319                 rc = bdb_id2entry_r( be, NULL, id, &e );
320
321                 if ( e == NULL ) {
322                         if( !BDB_IDL_IS_RANGE(candidates) ) {
323                                 /* only complain for non-range IDLs */
324 #ifdef NEW_LOGGING
325                                 LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: candidate %ld not found\n", (long) id));
326 #else
327                                 Debug( LDAP_DEBUG_TRACE,
328                                         "bdb_search: candidate %ld not found\n",
329                                         (long) id, 0, 0 );
330 #endif
331                         }
332
333                         goto loop_continue;
334                 }
335
336 #ifdef BDB_SUBENTRIES
337                 if ( is_entry_subentry( e ) ) {
338                         if( scope != LDAP_SCOPE_BASE ) {
339                                 if(!get_subentries_visibility( op )) {
340                                         /* only subentries are visible */
341                                         goto loop_continue;
342                                 }
343
344                         } else if ( get_subentries( op ) &&
345                                 !get_subentries_visibility( op ))
346                         {
347                                 /* only subentries are visible */
348                                 goto loop_continue;
349                         }
350
351                 } else if ( get_subentries_visibility( op )) {
352                         /* only subentries are visible */
353                         goto loop_continue;
354                 }
355 #endif
356
357 #ifdef BDB_ALIASES
358                 if ( deref & LDAP_DEREF_SEARCHING && is_entry_alias( e ) ) {
359                         Entry *matched;
360                         int err;
361                         const char *text;
362                         
363                         e = deref_entry_r( be, e, &err, &matched, &text );
364
365                         if( e == NULL ) {
366                                 e = matched;
367                                 goto loop_continue;
368                         }
369
370                         if( e->e_id == id ) {
371                                 /* circular loop */
372                                 goto loop_continue;
373                         }
374
375                         /* need to skip alias which deref into scope */
376                         if( scope & LDAP_SCOPE_ONELEVEL ) {
377                                 struct berval   pdn;
378                                 
379                                 dnParent( &e->e_nname, &pdn ):
380                                 if ( ber_bvcmp( pdn, &realbase ) ) {
381                                         goto loop_continue;
382                                 }
383
384                         } else if ( dnIsSuffix( &e->e_nname, &realbase ) ) {
385                                 /* alias is within scope */
386 #ifdef NEW_LOGGING
387                                 LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: \"%s\" in subtree\n", e->edn));
388 #else
389                                 Debug( LDAP_DEBUG_TRACE,
390                                         "bdb_search: \"%s\" in subtree\n",
391                                         e->e_dn, 0, 0 );
392 #endif
393                                 goto loop_continue;
394                         }
395
396                         scopeok = 1;
397                 }
398 #endif
399
400                 /*
401                  * if it's a referral, add it to the list of referrals. only do
402                  * this for non-base searches, and don't check the filter
403                  * explicitly here since it's only a candidate anyway.
404                  */
405                 if ( !manageDSAit && scope != LDAP_SCOPE_BASE &&
406                         is_entry_referral( e ) )
407                 {
408                         BerVarray erefs = get_entry_referrals(
409                                 be, conn, op, e );
410                         BerVarray refs = referral_rewrite( erefs,
411                                 &e->e_name, NULL,
412                                 scope == LDAP_SCOPE_SUBTREE 
413                                         ? LDAP_SCOPE_SUBTREE
414                                         : LDAP_SCOPE_BASE );
415
416                         send_search_reference( be, conn, op,
417                                 e, refs, NULL, &v2refs );
418
419                         ber_bvarray_free( refs );
420
421                         goto loop_continue;
422                 }
423
424                 /* if it matches the filter and scope, send it */
425                 rc = test_filter( be, conn, op, e, filter );
426                 if ( rc == LDAP_COMPARE_TRUE ) {
427                         struct berval   dn;
428
429                         /* check scope */
430                         if ( !scopeok && scope == LDAP_SCOPE_ONELEVEL ) {
431                                 if ( be_issuffix( be, &e->e_nname ) ) {
432                                         scopeok = (realbase.bv_len == 0);
433                                 } else {
434                                         dnParent( &e->e_nname, &dn );
435                                         scopeok = dn_match( &dn, &realbase );
436                                 }
437
438                         } else if ( !scopeok && scope == LDAP_SCOPE_SUBTREE ) {
439                                 scopeok = dnIsSuffix( &e->e_nname, &realbase );
440
441                         } else {
442                                 scopeok = 1;
443                         }
444
445                         if ( scopeok ) {
446                                 /* check size limit */
447                                 if ( --slimit == -1 ) {
448                                         bdb_cache_return_entry_r (&bdb->bi_cache, e);
449                                         e = NULL;
450                                         send_search_result( conn, op,
451                                                 rc = LDAP_SIZELIMIT_EXCEEDED, NULL, NULL,
452                                                 v2refs, NULL, nentries );
453                                         goto done;
454                                 }
455
456                                 if (e) {
457                                         int result;
458                                         
459                                         if( op->o_noop ) {
460                                                 result = 0;
461                                         } else {
462                                                 result = send_search_entry( be, conn, op,
463                                                         e, attrs, attrsonly, NULL);
464                                         }
465
466                                         switch (result) {
467                                         case 0:         /* entry sent ok */
468                                                 nentries++;
469                                                 break;
470                                         case 1:         /* entry not sent */
471                                                 break;
472                                         case -1:        /* connection closed */
473                                                 bdb_cache_return_entry_r(&bdb->bi_cache, e);
474                                                 e = NULL;
475                                                 rc = LDAP_OTHER;
476                                                 goto done;
477                                         }
478                                 }
479                         } else {
480 #ifdef NEW_LOGGING
481                                 LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: %ld scope not okay\n", (long) id));
482 #else
483                                 Debug( LDAP_DEBUG_TRACE,
484                                         "bdb_search: %ld scope not okay\n",
485                                         (long) id, 0, 0 );
486 #endif
487                         }
488                 } else {
489 #ifdef NEW_LOGGING
490                                 LDAP_LOG (( "search", LDAP_LEVEL_RESULTS,"bdb_search: %ld does match filter\n", (long) id));
491 #else
492                         Debug( LDAP_DEBUG_TRACE,
493                                 "bdb_search: %ld does match filter\n",
494                                 (long) id, 0, 0 );
495 #endif
496                 }
497
498 loop_continue:
499                 if( e != NULL ) {
500                         /* free reader lock */
501                         bdb_cache_return_entry_r ( &bdb->bi_cache, e );
502                         e = NULL;
503                 }
504
505                 ldap_pvt_thread_yield();
506         }
507         send_search_result( conn, op,
508                 v2refs == NULL ? LDAP_SUCCESS : LDAP_REFERRAL,
509                 NULL, NULL, v2refs, NULL, nentries );
510
511         rc = 0;
512
513 done:
514         if( e != NULL ) {
515                 /* free reader lock */
516                 bdb_cache_return_entry_r ( &bdb->bi_cache, e );
517         }
518
519         if( v2refs ) ber_bvarray_free( v2refs );
520         if( realbase.bv_val ) ch_free( realbase.bv_val );
521
522         return rc;
523 }
524
525
526 static int base_candidate(
527         BackendDB       *be,
528         Entry   *e,
529         ID              *ids )
530 {
531 #ifdef NEW_LOGGING
532         LDAP_LOG (( "search", LDAP_LEVEL_ENTRY,"base_candidate: base: \"%s\" (0x%08lx)\n", e->e_dn, (long) e->e_id));
533 #else
534         Debug(LDAP_DEBUG_ARGS, "base_candidates: base: \"%s\" (0x%08lx)\n",
535                 e->e_dn, (long) e->e_id, 0);
536 #endif
537
538         ids[0] = 1;
539         ids[1] = e->e_id;
540         return 0;
541 }
542
543 /* Is "objectClass=xx" mentioned anywhere in this filter? Presence
544  * doesn't count, we're looking for explicit values. Also count depth
545  * of filter tree while we're at it.
546  */
547 static int oc_filter(
548         Filter *f,
549         int cur,
550         int *max
551 )
552 {
553         int rc = 0;
554
555         if( cur > *max ) *max = cur;
556
557         switch(f->f_choice) {
558         case LDAP_FILTER_EQUALITY:
559         case LDAP_FILTER_APPROX:
560                 if (f->f_av_desc == slap_schema.si_ad_objectClass)
561                         rc = 1;
562                 break;
563
564         case LDAP_FILTER_SUBSTRINGS:
565                 if (f->f_sub_desc == slap_schema.si_ad_objectClass)
566                         rc = 1;
567                 break;
568
569         case LDAP_FILTER_AND:
570         case LDAP_FILTER_OR:
571                 cur++;
572                 for (f=f->f_and; f; f=f->f_next)
573                         if ((rc = oc_filter(f, cur, max)))
574                                 break;
575                 break;
576         default:
577                 break;
578         }
579         return rc;
580 }
581
582 static int search_candidates(
583         BackendDB *be,
584         Operation *op,
585         Entry *e,
586         Filter *filter,
587         int scope,
588         int deref,
589         ID      *ids )
590 {
591         int rc, depth = 1;
592         Filter          f, scopef, rf, xf;
593         ID              *stack;
594         AttributeAssertion aa_ref;
595 #ifdef BDB_SUBENTRIES
596         Filter  sf;
597         AttributeAssertion aa_subentry;
598 #endif
599 #ifdef BDB_ALIASES
600         Filter  af;
601         AttributeAssertion aa_alias;
602 #endif
603         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
604
605         /*
606          * This routine takes as input a filter (user-filter)
607          * and rewrites it as follows:
608          *      (&(scope=DN)[(objectClass=subentry)]
609          *              (|[(objectClass=referral)(objectClass=alias)](user-filter))
610          */
611
612 #ifdef NEW_LOGGING
613         LDAP_LOG (( "search", LDAP_LEVEL_ENTRY,"search_candidates: base=\"%s\" (0x%08lx) scope=%d\n", e->e_dn, (long) e->e_id, scope));
614 #else
615         Debug(LDAP_DEBUG_TRACE,
616                 "search_candidates: base=\"%s\" (0x%08lx) scope=%d\n",
617                 e->e_dn, (long) e->e_id, scope );
618 #endif
619
620         xf.f_or = filter;
621         xf.f_choice = LDAP_FILTER_OR;
622         xf.f_next = NULL;
623
624         /* If the user's filter doesn't mention objectClass, or if
625          * it just uses objectClass=*, these clauses are redundant.
626          */
627         if (oc_filter(filter, 1, &depth) && !get_subentries_visibility(op) ) {
628                 if( !get_manageDSAit(op) ) { /* match referrals */
629                         struct berval bv_ref = { sizeof("REFERRAL")-1, "REFERRAL" };
630                         rf.f_choice = LDAP_FILTER_EQUALITY;
631                         rf.f_ava = &aa_ref;
632                         rf.f_av_desc = slap_schema.si_ad_objectClass;
633                         rf.f_av_value = bv_ref;
634                         rf.f_next = xf.f_or;
635                         xf.f_or = &rf;
636                 }
637
638 #ifdef BDB_ALIASES
639                 if( deref & LDAP_DEREF_SEARCHING ) { /* match aliases */
640                         struct berval bv_alias = { sizeof("ALIAS")-1, "ALIAS" };
641                         af.f_choice = LDAP_FILTER_EQUALITY;
642                         af.f_ava = &aa_alias;
643                         af.f_av_desc = slap_schema.si_ad_objectClass;
644                         af.f_av_value = bv_alias;
645                         af.f_next = xf.f_or;
646                         xf.f_or = &af;
647                 }
648 #endif
649                 /* We added one of these clauses, filter depth increased */
650                 if( xf.f_or != filter ) depth++;
651         }
652
653         f.f_next = NULL;
654         f.f_choice = LDAP_FILTER_AND;
655         f.f_and = &scopef;
656         scopef.f_choice = scope == LDAP_SCOPE_SUBTREE
657                 ? SLAPD_FILTER_DN_SUBTREE
658                 : SLAPD_FILTER_DN_ONE;
659         scopef.f_dn = &e->e_nname;
660         scopef.f_next = xf.f_or == filter ? filter : &xf ;
661         /* Filter depth increased again, adding scope clause */
662         depth++;
663
664 #ifdef BDB_SUBENTRIES
665         if( get_subentries_visibility( op ) ) {
666                 struct berval bv_subentry = { sizeof("SUBENTRY")-1, "SUBENTRY" };
667                 sf.f_choice = LDAP_FILTER_EQUALITY;
668                 sf.f_ava = &aa_subentry;
669                 sf.f_av_desc = slap_schema.si_ad_objectClass;
670                 sf.f_av_value = bv_subentry;
671                 sf.f_next = scopef.f_next;
672                 scopef.f_next = &sf;
673         }
674 #endif
675
676         /* Allocate IDL stack, plus 1 more for former tmp */
677         stack = malloc( (depth + 1) * BDB_IDL_UM_SIZE * sizeof( ID ) );
678
679         rc = bdb_filter_candidates( be, &f, ids, stack, stack+BDB_IDL_UM_SIZE );
680
681         free( stack );
682
683         if( rc ) {
684 #ifdef NEW_LOGGING
685         LDAP_LOG (( "search", LDAP_LEVEL_DETAIL1,"bdb_search_candidates: failed (rc=%d)\n", rc));
686 #else
687                 Debug(LDAP_DEBUG_TRACE,
688                         "bdb_search_candidates: failed (rc=%d)\n",
689                         rc, NULL, NULL );
690 #endif
691
692         } else {
693 #ifdef NEW_LOGGING
694                 LDAP_LOG (( "search", LDAP_LEVEL_DETAIL1,"bdb_search_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids)));
695 #else
696                 Debug(LDAP_DEBUG_TRACE,
697                         "bdb_search_candidates: id=%ld first=%ld last=%ld\n",
698                         (long) ids[0],
699                         (long) BDB_IDL_FIRST(ids),
700                         (long) BDB_IDL_LAST(ids) );
701 #endif
702         }
703
704         return rc;
705 }