- if (i > 0) {
- an = (AttributeName *)slapi_ch_calloc( (i + 1), sizeof(AttributeName) );
- for (i = 0; attrs[i] != 0; i++) {
- an[i].an_desc = NULL;
- an[i].an_oc = NULL;
- an[i].an_oc_exclude = 0;
- an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]);
- an[i].an_name.bv_len = strlen(attrs[i]);
- slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
- }
- an[i].an_name.bv_val = NULL;
- }
-
- memset( &rs, 0, sizeof(rs) );
- rs.sr_type = REP_RESULT;
- rs.sr_err = LDAP_SUCCESS;
- rs.sr_entry = NULL; /* paranoia */
-
- if ( scope == LDAP_SCOPE_BASE ) {
- rs.sr_entry = NULL;
-
- if ( op->o_req_ndn.bv_len == 0 ) {
- rs.sr_err = root_dse_info( c, &rs.sr_entry, &rs.sr_text );
- }
-
- if( rs.sr_err != LDAP_SUCCESS ) {
- send_ldap_result( op, &rs );
- goto cleanup;
- } else if ( rs.sr_entry != NULL ) {
- rs.sr_err = test_filter( op, rs.sr_entry, filter );
-
- if ( rs.sr_err == LDAP_COMPARE_TRUE ) {
- rs.sr_type = REP_SEARCH;
- rs.sr_err = LDAP_SUCCESS;
- rs.sr_attrs = an;
- rs.sr_operational_attrs = NULL;
- rs.sr_flags = REP_ENTRY_MODIFIABLE;
-
- send_search_entry( op, &rs );
- }
-
- entry_free( rs.sr_entry );
-
- rs.sr_type = REP_RESULT;
- rs.sr_err = LDAP_SUCCESS;
-
- send_ldap_result( op, &rs );
-
- goto cleanup;
- }
- }
-
- if ( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) {
- slapi_ch_free( (void **)&op->o_req_dn.bv_val );
- slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
-
- ber_dupbv( &op->o_req_dn, &default_search_base );
- ber_dupbv( &op->o_req_ndn, &default_search_nbase );
- }
-
- if ( slapi_control_present( controls,
- LDAP_CONTROL_MANAGEDSAIT, NULL, &isCritical ) ) {
- manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
- }
-
- op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
- if ( op->o_bd == NULL ) {
- if ( manageDsaIt > SLAP_CONTROL_NONE ) {
- rs.sr_err = LDAP_NO_SUCH_OBJECT;
- } else {
- rs.sr_err = LDAP_PARTIAL_RESULTS;
- }
- goto cleanup;
- }
-
- op->o_dn = c->c_dn = op->o_bd->be_rootdn;
- op->o_ndn = c->c_ndn = op->o_bd->be_rootndn;
-
- op->oq_search.rs_scope = scope;
- op->oq_search.rs_deref = 0;
- op->oq_search.rs_slimit = SLAP_NO_LIMIT;
- op->oq_search.rs_tlimit = SLAP_NO_LIMIT;
- op->oq_search.rs_attrsonly = attrsonly;
- op->oq_search.rs_attrs = an;
- op->oq_search.rs_filter = filter;
- op->oq_search.rs_filterstr = fstr;
-
- if ( op->o_bd->be_search != NULL ) {
- (*op->o_bd->be_search)( op, &rs );
- } else {
- rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
- }