+
+#ifdef LDAP_CLIENT_UPDATE
+ if ( ( op->o_clientupdate_type & SLAP_LCUP_PERSIST ) )
+ return rs->sr_err;
+#endif
+#if defined(LDAP_CLIENT_UPDATE) && defined(LDAP_SYNC)
+ else
+#endif
+#ifdef LDAP_SYNC
+ if ( ( op->o_sync_mode & SLAP_SYNC_PERSIST ) )
+ return rs->sr_err;
+#endif
+
+ if( op->o_req_dn.bv_val != NULL) free( op->o_req_dn.bv_val );
+ if( op->o_req_ndn.bv_val != NULL) free( op->o_req_ndn.bv_val );
+
+ if( op->ors_filterstr.bv_val != NULL) free( op->ors_filterstr.bv_val );
+ if( op->ors_filter != NULL) filter_free( op->ors_filter );
+ if( op->ors_attrs != NULL ) free( op->ors_attrs );
+#ifdef LDAP_SLAPI
+ if( attrs != NULL) ch_free( attrs );
+#endif /* LDAP_SLAPI */
+
+ return rs->sr_err;
+}
+
+#ifdef LDAP_SLAPI
+
+static char **anlist2charray( AttributeName *an )
+{
+ char **attrs;
+ int i;
+
+ if ( an != NULL ) {
+ for ( i = 0; an[i].an_name.bv_val != NULL; i++ )
+ ;
+ attrs = (char **)ch_malloc( (i + 1) * sizeof(char *) );
+ for ( i = 0; an[i].an_name.bv_val != NULL; i++ ) {
+ attrs[i] = an[i].an_name.bv_val;
+ }
+ attrs[i] = NULL;
+ } else {
+ attrs = NULL;
+ }
+
+ return attrs;
+}
+
+static void initSearchPlugin( Operation *op,
+ char **attrs, int managedsait )
+{
+ slapi_x_pblock_set_operation( op->o_pb, op );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TARGET, (void *)op->o_req_dn.bv_val );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SCOPE, (void *)op->ors_scope );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_DEREF, (void *)op->ors_deref );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_SIZELIMIT, (void *)op->ors_slimit );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_TIMELIMIT, (void *)op->ors_tlimit );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_FILTER, (void *)op->ors_filter );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_STRFILTER, (void *)op->ors_filterstr.bv_val );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
+ slapi_pblock_set( op->o_pb, SLAPI_SEARCH_ATTRSONLY, (void *)op->ors_attrsonly );
+ slapi_pblock_set( op->o_pb, SLAPI_MANAGEDSAIT, (void *)managedsait );
+}
+
+static int doPreSearchPluginFNs( Operation *op )
+{
+ int rc;
+
+ rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_SEARCH_FN, op->o_pb );
+ if ( rc != 0 ) {
+ /*
+ * A preoperation plugin failure will abort the
+ * entire operation.
+ */
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, INFO, "doPreSearchPluginFNs: search preoperation plugin "
+ "returned %d\n", rc, 0, 0 );
+#else
+ Debug(LDAP_DEBUG_TRACE, "doPreSearchPluginFNs: search preoperation plugin "
+ "returned %d.\n", rc, 0, 0);
+#endif
+ if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0)
+ rc = LDAP_OTHER;
+ } else {
+ rc = LDAP_SUCCESS;