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