]> git.sur5r.net Git - openldap/blob - servers/slapd/search.c
9df49bf0cbb975f06b34e0d935effa49fd470d71
[openldap] / servers / slapd / search.c
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2004 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in the file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms are permitted
19  * provided that this notice is preserved and that due credit is given
20  * to the University of Michigan at Ann Arbor. The name of the University
21  * may not be used to endorse or promote products derived from this
22  * software without specific prior written permission. This software
23  * is provided ``as is'' without express or implied warranty.
24  */
25
26 #include "portable.h"
27
28 #include <stdio.h>
29
30 #include <ac/string.h>
31 #include <ac/socket.h>
32
33 #include "ldap_pvt.h"
34 #include "lutil.h"
35 #include "slap.h"
36
37 #ifdef LDAP_SLAPI
38 #include "slapi/slapi.h"
39
40 static char **anlist2charray( Operation *op, AttributeName *an );
41 static void init_search_pblock( Operation *op, char **attrs, int managedsait );
42 static int call_search_preop_plugins( Operation *op );
43 static int call_search_rewrite_plugins( Operation *op );
44 static void call_search_postop_plugins( Operation *op );
45 #endif /* LDAPI_SLAPI */
46
47 int
48 do_search(
49     Operation   *op,    /* info about the op to which we're responding */
50     SlapReply   *rs     /* all the response data we'll send */ )
51 {
52         struct berval base = BER_BVNULL;
53         ber_len_t       siz, off, i;
54
55 #ifdef NEW_LOGGING
56         LDAP_LOG( OPERATION, ENTRY, "do_search: conn %d\n", op->o_connid, 0, 0 );
57 #else
58         Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 );
59 #endif
60
61         /*
62          * Parse the search request.  It looks like this:
63          *
64          *      SearchRequest := [APPLICATION 3] SEQUENCE {
65          *              baseObject      DistinguishedName,
66          *              scope           ENUMERATED {
67          *                      baseObject      (0),
68          *                      singleLevel     (1),
69          *                      wholeSubtree (2),
70          *          subordinate (3)  -- OpenLDAP extension
71          *              },
72          *              derefAliases    ENUMERATED {
73          *                      neverDerefaliases       (0),
74          *                      derefInSearching        (1),
75          *                      derefFindingBaseObj     (2),
76          *                      alwaysDerefAliases      (3)
77          *              },
78          *              sizelimit       INTEGER (0 .. 65535),
79          *              timelimit       INTEGER (0 .. 65535),
80          *              attrsOnly       BOOLEAN,
81          *              filter          Filter,
82          *              attributes      SEQUENCE OF AttributeType
83          *      }
84          */
85
86         /* baseObject, scope, derefAliases, sizelimit, timelimit, attrsOnly */
87         if ( ber_scanf( op->o_ber, "{miiiib" /*}*/,
88                 &base, &op->ors_scope, &op->ors_deref, &op->ors_slimit,
89             &op->ors_tlimit, &op->ors_attrsonly ) == LBER_ERROR )
90         {
91                 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
92                 rs->sr_err = SLAPD_DISCONNECT;
93                 goto return_results;
94         }
95
96         if ( op->ors_tlimit < 0 || op->ors_tlimit > SLAP_MAX_LIMIT ) {
97                 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR, "invalid time limit" );
98                 goto return_results;
99         }
100
101         if ( op->ors_slimit < 0 || op->ors_slimit > SLAP_MAX_LIMIT ) {
102                 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR, "invalid size limit" );
103                 goto return_results;
104         }
105
106         switch( op->ors_scope ) {
107         case LDAP_SCOPE_BASE:
108         case LDAP_SCOPE_ONELEVEL:
109         case LDAP_SCOPE_SUBTREE:
110 #ifdef LDAP_SCOPE_SUBORDINATE
111         case LDAP_SCOPE_SUBORDINATE:
112 #endif
113                 break;
114         default:
115                 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR, "invalid scope" );
116                 goto return_results;
117         }
118
119         switch( op->ors_deref ) {
120         case LDAP_DEREF_NEVER:
121         case LDAP_DEREF_FINDING:
122         case LDAP_DEREF_SEARCHING:
123         case LDAP_DEREF_ALWAYS:
124                 break;
125         default:
126                 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR, "invalid deref" );
127                 goto return_results;
128         }
129
130         rs->sr_err = dnPrettyNormal( NULL, &base, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
131         if( rs->sr_err != LDAP_SUCCESS ) {
132 #ifdef NEW_LOGGING
133                 LDAP_LOG( OPERATION, ERR, 
134                         "do_search: conn %d  invalid dn (%s)\n",
135                         op->o_connid, base.bv_val, 0 );
136 #else
137                 Debug( LDAP_DEBUG_ANY,
138                         "do_search: invalid dn (%s)\n", base.bv_val, 0, 0 );
139 #endif
140                 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
141                 goto return_results;
142         }
143
144 #ifdef NEW_LOGGING
145         LDAP_LOG( OPERATION, ARGS, "SRCH \"%s\" %d %d",
146                 base.bv_val, op->ors_scope, op->ors_deref );
147         LDAP_LOG( OPERATION, ARGS, "    %d %d %d\n",
148                 op->ors_slimit, op->ors_tlimit, op->ors_attrsonly);
149 #else
150         Debug( LDAP_DEBUG_ARGS, "SRCH \"%s\" %d %d",
151                 base.bv_val, op->ors_scope, op->ors_deref );
152         Debug( LDAP_DEBUG_ARGS, "    %d %d %d\n",
153                 op->ors_slimit, op->ors_tlimit, op->ors_attrsonly);
154 #endif
155
156         /* filter - returns a "normalized" version */
157         rs->sr_err = get_filter( op, op->o_ber, &op->ors_filter, &rs->sr_text );
158         if( rs->sr_err != LDAP_SUCCESS ) {
159                 if( rs->sr_err == SLAPD_DISCONNECT ) {
160                         rs->sr_err = LDAP_PROTOCOL_ERROR;
161                         send_ldap_disconnect( op, rs );
162                         rs->sr_err = SLAPD_DISCONNECT;
163                 } else {
164                         send_ldap_result( op, rs );
165                 }
166                 goto return_results;
167         }
168         filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
169
170 #ifdef NEW_LOGGING
171         LDAP_LOG( OPERATION, ARGS, 
172                 "do_search: conn %d     filter: %s\n", 
173                 op->o_connid, !BER_BVISEMPTY( &op->ors_filterstr ) ? op->ors_filterstr.bv_val : "empty",
174                 0 );
175 #else
176         Debug( LDAP_DEBUG_ARGS, "    filter: %s\n",
177                 !BER_BVISEMPTY( &op->ors_filterstr ) ? op->ors_filterstr.bv_val : "empty", 0, 0 );
178 #endif
179
180         /* attributes */
181         siz = sizeof(AttributeName);
182         off = offsetof(AttributeName,an_name);
183         if ( ber_scanf( op->o_ber, "{M}}", &op->ors_attrs, &siz, off ) == LBER_ERROR ) {
184                 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding attrs error" );
185                 rs->sr_err = SLAPD_DISCONNECT;
186                 goto return_results;
187         }
188         for ( i=0; i<siz; i++ ) {
189                 const char *dummy;      /* ignore msgs from bv2ad */
190                 op->ors_attrs[i].an_desc = NULL;
191                 op->ors_attrs[i].an_oc = NULL;
192                 op->ors_attrs[i].an_oc_exclude = 0;
193                 slap_bv2ad(&op->ors_attrs[i].an_name, &op->ors_attrs[i].an_desc, &dummy);
194         }
195
196         if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
197 #ifdef NEW_LOGGING
198                 LDAP_LOG( OPERATION, INFO, 
199                         "do_search: conn %d  get_ctrls failed (%d)\n",
200                         op->o_connid, rs->sr_err, 0 );
201 #else
202                 Debug( LDAP_DEBUG_ANY, "do_search: get_ctrls failed\n", 0, 0, 0 );
203 #endif
204
205                 goto return_results;
206         }
207
208 #ifdef NEW_LOGGING
209         LDAP_LOG( OPERATION, ARGS, 
210                 "do_search: conn %d     attrs:", op->o_connid, 0, 0 );
211 #else
212         Debug( LDAP_DEBUG_ARGS, "    attrs:", 0, 0, 0 );
213 #endif
214
215         if ( siz != 0 ) {
216                 for ( i = 0; i<siz; i++ ) {
217 #ifdef NEW_LOGGING
218                         LDAP_LOG( OPERATION, ARGS, 
219                                 "do_search: %s", op->ors_attrs[i].an_name.bv_val, 0, 0 );
220 #else
221                         Debug( LDAP_DEBUG_ARGS, " %s", op->ors_attrs[i].an_name.bv_val, 0, 0 );
222 #endif
223                 }
224         }
225
226 #ifdef NEW_LOGGING
227         LDAP_LOG( OPERATION, ARGS, "\n" , 0, 0, 0 );
228 #else
229         Debug( LDAP_DEBUG_ARGS, "\n", 0, 0, 0 );
230 #endif
231
232         if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
233                 char abuf[BUFSIZ/2], *ptr = abuf;
234                 int len = 0, alen;
235
236                 sprintf(abuf, "scope=%d deref=%d", op->ors_scope, op->ors_deref);
237                 Statslog( LDAP_DEBUG_STATS,
238                         "conn=%lu op=%lu SRCH base=\"%s\" %s filter=\"%s\"\n",
239                         op->o_connid, op->o_opid, op->o_req_dn.bv_val, abuf,
240                         op->ors_filterstr.bv_val );
241
242                 for ( i = 0; i<siz; i++ ) {
243                         alen = op->ors_attrs[i].an_name.bv_len;
244                         if (alen >= sizeof(abuf)) {
245                                 alen = sizeof(abuf)-1;
246                         }
247                         if (len && (len + 1 + alen >= sizeof(abuf))) {
248                                 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu SRCH attr=%s\n",
249                                     op->o_connid, op->o_opid, abuf, 0, 0 );
250                                 len = 0;
251                                 ptr = abuf;
252                         }
253                         if (len) {
254                                 *ptr++ = ' ';
255                                 len++;
256                         }
257                         ptr = lutil_strncopy(ptr, op->ors_attrs[i].an_name.bv_val, alen);
258                         len += alen;
259                         *ptr = '\0';
260                 }
261                 if (len) {
262                         Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu SRCH attr=%s\n",
263                                 op->o_connid, op->o_opid, abuf, 0, 0 );
264                 }
265         }
266
267         op->o_bd = frontendDB;
268         rs->sr_err = frontendDB->be_search( op, rs );
269
270 return_results:;
271         if ( ( op->o_sync_mode & SLAP_SYNC_PERSIST ) ) {
272                 return rs->sr_err;
273         }
274         if ( ( op->o_sync_slog_size != -1 ) ) {
275                 return rs->sr_err;
276         }
277         if ( !BER_BVISNULL( &op->o_req_dn ) ) {
278                 slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
279         }
280         if ( !BER_BVISNULL( &op->o_req_ndn ) ) {
281                 slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
282         }
283         if ( !BER_BVISNULL( &op->ors_filterstr ) ) {
284                 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
285         }
286         if ( op->ors_filter != NULL) {
287                 filter_free_x( op, op->ors_filter );
288         }
289         if ( op->ors_attrs != NULL ) {
290                 op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
291         }
292
293         return rs->sr_err;
294 }
295
296 int
297 fe_op_search( Operation *op, SlapReply *rs )
298 {
299         int                     manageDSAit;
300         int                     be_manageDSAit;
301 #ifdef LDAP_SLAPI
302         char                    **attrs = NULL;
303 #endif
304
305         manageDSAit = get_manageDSAit( op );
306
307         /* fake while loop to allow breaking out */
308         while ( op->ors_scope == LDAP_SCOPE_BASE ) {
309                 Entry *entry = NULL;
310
311                 if ( BER_BVISEMPTY( &op->o_req_ndn ) ) {
312 #ifdef LDAP_CONNECTIONLESS
313                         /* Ignore LDAPv2 CLDAP Root DSE queries */
314                         if (op->o_protocol == LDAP_VERSION2 && op->o_conn->c_is_udp) {
315                                 goto return_results;
316                         }
317 #endif
318                         /* check restrictions */
319                         if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
320                                 send_ldap_result( op, rs );
321                                 goto return_results;
322                         }
323
324 #ifdef LDAP_SLAPI
325                         if ( op->o_pb ) {
326                                 attrs = anlist2charray( op, op->ors_attrs );
327                                 init_search_pblock( op, attrs, manageDSAit );
328                                 rs->sr_err = call_search_preop_plugins( op );
329                                 if ( rs->sr_err ) break;
330                                 call_search_rewrite_plugins( op );
331                         }
332 #endif /* LDAP_SLAPI */
333                         rs->sr_err = root_dse_info( op->o_conn, &entry, &rs->sr_text );
334
335                 } else if ( bvmatch( &op->o_req_ndn, &frontendDB->be_schemandn ) ) {
336                         /* check restrictions */
337                         if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
338                                 send_ldap_result( op, rs );
339                                 goto return_results;
340                         }
341
342 #ifdef LDAP_SLAPI
343                         if ( op->o_pb ) {
344                                 attrs = anlist2charray( op, op->ors_attrs );
345                                 init_search_pblock( op, attrs, manageDSAit );
346                                 rs->sr_err = call_search_preop_plugins( op );
347                                 if ( rs->sr_err ) break;
348                                 call_search_rewrite_plugins( op );
349                         }
350 #endif /* LDAP_SLAPI */
351                         rs->sr_err = schema_info( &entry, &rs->sr_text );
352                 }
353
354                 if( rs->sr_err != LDAP_SUCCESS ) {
355                         send_ldap_result( op, rs );
356 #ifdef LDAP_SLAPI
357                         if ( op->o_pb ) call_search_postop_plugins( op );
358 #endif /* LDAP_SLAPI */
359                         goto return_results;
360
361                 } else if ( entry != NULL ) {
362                         rs->sr_err = test_filter( op, entry, op->ors_filter );
363
364                         if( rs->sr_err == LDAP_COMPARE_TRUE ) {
365                                 rs->sr_entry = entry;
366                                 rs->sr_attrs = op->ors_attrs;
367                                 rs->sr_operational_attrs = NULL;
368                                 send_search_entry( op, rs );
369                                 rs->sr_entry = NULL;
370                                 rs->sr_operational_attrs = NULL;
371                         }
372                         entry_free( entry );
373
374                         rs->sr_err = LDAP_SUCCESS;
375                         send_ldap_result( op, rs );
376 #ifdef LDAP_SLAPI
377                         if ( op->o_pb ) call_search_postop_plugins( op );
378 #endif /* LDAP_SLAPI */
379                         goto return_results;
380                 }
381                 break;
382         }
383
384         if( BER_BVISEMPTY( &op->o_req_ndn ) && !BER_BVISEMPTY( &default_search_nbase ) ) {
385                 slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
386                 slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
387
388                 ber_dupbv_x( &op->o_req_dn, &default_search_base, op->o_tmpmemctx );
389                 ber_dupbv_x( &op->o_req_ndn, &default_search_nbase, op->o_tmpmemctx );
390         }
391
392         /*
393          * We could be serving multiple database backends.  Select the
394          * appropriate one, or send a referral to our "referral server"
395          * if we don't hold it.
396          */
397
398         /* Sync control overrides manageDSAit */
399
400         if ( manageDSAit != SLAP_NO_CONTROL ) {
401                 if ( op->o_sync_mode & SLAP_SYNC_REFRESH ) {
402                         be_manageDSAit = SLAP_NO_CONTROL;
403                 } else {
404                         be_manageDSAit = manageDSAit;
405                 }
406         } else {
407                 be_manageDSAit = manageDSAit;
408         }
409
410         op->o_bd = select_backend( &op->o_req_ndn, be_manageDSAit, 1 );
411         if ( op->o_bd == NULL ) {
412                 rs->sr_ref = referral_rewrite( default_referral,
413                         NULL, &op->o_req_dn, op->ors_scope );
414
415                 if (!rs->sr_ref) rs->sr_ref = default_referral;
416                 rs->sr_err = LDAP_REFERRAL;
417                 send_ldap_result( op, rs );
418
419                 if (rs->sr_ref != default_referral)
420                 ber_bvarray_free( rs->sr_ref );
421                 rs->sr_ref = NULL;
422                 goto return_results;
423         }
424
425         /* check restrictions */
426         if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
427                 send_ldap_result( op, rs );
428                 goto return_results;
429         }
430
431         /* check for referrals */
432         if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
433                 goto return_results;
434         }
435
436 #ifdef LDAP_SLAPI
437         if ( op->o_pb ) {
438                 attrs = anlist2charray( op, op->ors_attrs );
439                 init_search_pblock( op, attrs, manageDSAit );
440                 rs->sr_err = call_search_preop_plugins( op );
441                 if ( rs->sr_err != LDAP_SUCCESS ) {
442                         goto return_results;
443                 }
444
445                 call_search_rewrite_plugins( op );
446         }
447 #endif /* LDAP_SLAPI */
448
449         /* actually do the search and send the result(s) */
450         if ( op->o_bd->be_search ) {
451                 if ( limits_check( op, rs ) == 0 ) {
452                         (op->o_bd->be_search)( op, rs );
453                 }
454                 /* else limits_check() sends error */
455
456         } else {
457                 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
458                         "operation not supported within namingContext" );
459         }
460
461 #ifdef LDAP_SLAPI
462         if ( op->o_pb ) call_search_postop_plugins( op );
463 #endif /* LDAP_SLAPI */
464
465 #ifdef LDAP_SLAPI
466         if( attrs != NULL) op->o_tmpfree( attrs, op->o_tmpmemctx );
467 #endif /* LDAP_SLAPI */
468
469 return_results:;
470         return rs->sr_err;
471 }
472
473 #ifdef LDAP_SLAPI
474
475 static char **anlist2charray( Operation *op, AttributeName *an )
476 {
477         char **attrs;
478         int i;
479
480         if ( an != NULL ) {
481                 for ( i = 0; !BER_BVISNULL( &an[i].an_name ); i++ )
482                         ;
483                 attrs = (char **)op->o_tmpalloc( (i + 1) * sizeof(char *), op->o_tmpmemctx );
484                 for ( i = 0; !BER_BVISNULL( &an[i].an_name ); i++ ) {
485                         attrs[i] = an[i].an_name.bv_val;
486                 }
487                 attrs[i] = NULL;
488         } else {
489                 attrs = NULL;
490         }
491
492         return attrs;
493 }
494
495 static void init_search_pblock( Operation *op,
496         char **attrs, int managedsait )
497 {
498         slapi_int_pblock_set_operation( op->o_pb, op );
499         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TARGET, (void *)op->o_req_dn.bv_val );
500         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SCOPE, (void *)op->ors_scope );
501         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_DEREF, (void *)op->ors_deref );
502         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SIZELIMIT, (void *)op->ors_slimit );
503         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TIMELIMIT, (void *)op->ors_tlimit );
504         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_FILTER, (void *)op->ors_filter );
505         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_STRFILTER, (void *)op->ors_filterstr.bv_val );
506         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
507         slapi_pblock_set( op->o_pb, SLAPI_SEARCH_ATTRSONLY, (void *)op->ors_attrsonly );
508         slapi_pblock_set( op->o_pb, SLAPI_MANAGEDSAIT, (void *)managedsait );
509 }
510
511 static int call_search_preop_plugins( Operation *op )
512 {
513         int rc;
514
515         rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_SEARCH_FN, op->o_pb );
516         if ( rc < 0 ) {
517                 /*
518                  * A preoperation plugin failure will abort the
519                  * entire operation.
520                  */
521 #ifdef NEW_LOGGING
522                 LDAP_LOG( OPERATION, INFO, "call_search_preop_plugins: search preoperation plugin "
523                                 "returned %d\n", rc, 0, 0 );
524 #else
525                 Debug(LDAP_DEBUG_TRACE, "call_search_preop_plugins: search preoperation plugin "
526                                 "returned %d.\n", rc, 0, 0);
527 #endif
528                 if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 ) ||
529                      rc == LDAP_SUCCESS ) {
530                         rc = LDAP_OTHER;
531                 }
532         } else {
533                 rc = LDAP_SUCCESS;
534         }
535
536         return rc;
537 }
538
539 static int call_search_rewrite_plugins( Operation *op )
540 {
541         if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, op->o_pb ) == 0 ) {
542                 int rc;
543
544                 /*
545                  * The plugin can set the SLAPI_SEARCH_FILTER.
546                  * SLAPI_SEARCH_STRFILER is not normative.
547                  */
548                 slapi_pblock_get( op->o_pb, SLAPI_SEARCH_FILTER, (void *)&op->ors_filter );
549                 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
550                 filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
551
552                 /*
553                  * Also permit other search parameters to be reset. One thing
554                  * this doesn't (yet) deal with is plugins that change a root
555                  * DSE search to a non-root DSE search...
556                  */
557                 slapi_pblock_get( op->o_pb, SLAPI_SEARCH_TARGET, (void **)&op->o_req_dn.bv_val );
558                 op->o_req_dn.bv_len = strlen( op->o_req_dn.bv_val );
559
560                 if( !BER_BVISNULL( &op->o_req_ndn ) ) {
561                         slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
562                 }
563                 rc = dnNormalize( 0, NULL, NULL, &op->o_req_dn, &op->o_req_ndn,
564                         op->o_tmpmemctx );
565                 if ( rc != LDAP_SUCCESS ) {
566                         return rc;
567                 }
568
569                 slapi_pblock_get( op->o_pb, SLAPI_SEARCH_SCOPE, (void **)&op->ors_scope );
570                 slapi_pblock_get( op->o_pb, SLAPI_SEARCH_DEREF, (void **)&op->ors_deref );
571
572 #ifdef NEW_LOGGING
573                 LDAP_LOG( OPERATION, ARGS, 
574                         "call_search_rewrite_plugins: after compute_rewrite_search filter: %s\n", 
575                         !BER_BVISEMPTY( &op->ors_filterstr ) ? op->ors_filterstr.bv_val : "empty", 0, 0 );
576 #else
577                 Debug( LDAP_DEBUG_ARGS, "    after compute_rewrite_search filter: %s\n",
578                         !BER_BVISEMPTY( &op->ors_filterstr ) ? op->ors_filterstr.bv_val : "empty", 0, 0 );
579 #endif
580         }
581
582         return LDAP_SUCCESS;
583 }
584
585 static void call_search_postop_plugins( Operation *op )
586 {
587         if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_SEARCH_FN, op->o_pb ) < 0 ) {
588 #ifdef NEW_LOGGING
589                 LDAP_LOG( OPERATION, INFO, "call_search_postop_plugins: search postoperation plugins "
590                                 "failed\n", 0, 0, 0 );
591 #else
592                 Debug(LDAP_DEBUG_TRACE, "call_search_postop_plugins: search postoperation plugins "
593                                 "failed.\n", 0, 0, 0);
594 #endif
595         }
596 }
597
598 void slapi_int_dummy(void)
599 {
600         /*
601          * XXX slapi_search_internal() was no getting pulled
602          * in; all manner of linker flags failed to link it.
603          * FIXME
604          */
605         slapi_search_internal( NULL, 0, NULL, NULL, NULL, 0 );
606 }
607 #endif /* LDAP_SLAPI */
608