]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/search.c
return structuralObjectClass errors
[openldap] / servers / slapd / back-bdb / search.c
index 9b7a94f2f2ab2b2410c1462948ca329b3fc81192..519b65dd6b786d0db3971b9ae36a71d3db838f8e 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2005 The OpenLDAP Foundation.
+ * Copyright 2000-2006 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -319,9 +319,7 @@ bdb_search( Operation *op, SlapReply *rs )
        Entry           *matched = NULL;
        EntryInfo       *ei, ei_root = {0};
        struct berval   realbase = BER_BVNULL;
-#ifdef SLAP_ACL_HONOR_DISCLOSE
        slap_mask_t     mask;
-#endif
        int             manageDSAit;
        int             tentries = 0;
        ID              lastid = NOID;
@@ -424,7 +422,6 @@ dn2entry_retry:
                if ( matched != NULL ) {
                        BerVarray erefs = NULL;
 
-#ifdef SLAP_ACL_HONOR_DISCLOSE
                        /* return referral only if "disclose"
                         * is granted on the object */
                        if ( ! access_allowed( op, matched,
@@ -433,9 +430,7 @@ dn2entry_retry:
                        {
                                rs->sr_err = LDAP_NO_SUCH_OBJECT;
 
-                       } else
-#endif /* SLAP_ACL_HONOR_DISCLOSE */
-                       {
+                       } else {
                                ber_dupbv( &matched_dn, &matched->e_name );
 
                                erefs = is_entry_referral( matched )
@@ -465,7 +460,7 @@ dn2entry_retry:
 #endif
                        rs->sr_ref = referral_rewrite( default_referral,
                                NULL, &op->o_req_dn, op->oq_search.rs_scope );
-                       rs->sr_err = LDAP_REFERRAL;
+                       rs->sr_err = rs->sr_ref != NULL ? LDAP_REFERRAL : LDAP_NO_SUCH_OBJECT;
                }
 
                send_ldap_result( op, rs );
@@ -483,7 +478,6 @@ dn2entry_retry:
                return rs->sr_err;
        }
 
-#ifdef SLAP_ACL_HONOR_DISCLOSE
        /* NOTE: __NEW__ "search" access is required
         * on searchBase object */
        if ( ! access_allowed_mask( op, e, slap_schema.si_ad_entry,
@@ -504,7 +498,6 @@ dn2entry_retry:
                send_ldap_result( op, rs );
                return rs->sr_err;
        }
-#endif /* SLAP_ACL_HONOR_DISCLOSE */
 
        if ( !manageDSAit && e != &e_root && is_entry_referral( e ) ) {
                /* entry is a referral, don't allow add */
@@ -726,28 +719,24 @@ fetch_entry_retry:
 
                rs->sr_entry = e;
 
-#ifdef BDB_SUBENTRIES
-               {
-                       if ( is_entry_subentry( e ) ) {
-                               if( op->oq_search.rs_scope != LDAP_SCOPE_BASE ) {
-                                       if(!get_subentries_visibility( op )) {
-                                               /* only subentries are visible */
-                                               goto loop_continue;
-                                       }
-
-                               } else if ( get_subentries( op ) &&
-                                       !get_subentries_visibility( op ))
-                               {
+               if ( is_entry_subentry( e ) ) {
+                       if( op->oq_search.rs_scope != LDAP_SCOPE_BASE ) {
+                               if(!get_subentries_visibility( op )) {
                                        /* only subentries are visible */
                                        goto loop_continue;
                                }
 
-                       } else if ( get_subentries_visibility( op )) {
+                       } else if ( get_subentries( op ) &&
+                               !get_subentries_visibility( op ))
+                       {
                                /* only subentries are visible */
                                goto loop_continue;
                        }
+
+               } else if ( get_subentries_visibility( op )) {
+                       /* only subentries are visible */
+                       goto loop_continue;
                }
-#endif /* BDB_SUBENTRIES */
 
                /* Does this candidate actually satisfy the search scope?
                 *
@@ -874,20 +863,20 @@ fetch_entry_retry:
 
                        if (e) {
                                /* safe default */
-                               int result = -1;
                                rs->sr_attrs = op->oq_search.rs_attrs;
                                rs->sr_operational_attrs = NULL;
                                rs->sr_ctrls = NULL;
                                rs->sr_flags = 0;
                                rs->sr_err = LDAP_SUCCESS;
-                               result = send_search_entry( op, rs );
+                               rs->sr_err = send_search_entry( op, rs );
 
-                               switch ( result ) {
-                               case 0:         /* entry sent ok */
+                               switch ( rs->sr_err ) {
+                               case LDAP_SUCCESS:      /* entry sent ok */
                                        break;
-                               case 1:         /* entry not sent */
+                               default:                /* entry not sent */
                                        break;
-                               default:
+                               case LDAP_UNAVAILABLE:
+                               case LDAP_SIZELIMIT_EXCEEDED:
 #ifdef SLAP_ZONE_ALLOC
                                        slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
@@ -895,16 +884,13 @@ fetch_entry_retry:
                                                &bdb->bi_cache, e, &lock);
                                        e = NULL;
                                        rs->sr_entry = NULL;
-                                       switch ( result ) {
-                                       case SLAPD_SEND_SIZELIMIT:
-                                               rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
+                                       if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
                                                rs->sr_ref = rs->sr_v2ref;
                                                send_ldap_result( op, rs );
                                                rs->sr_err = LDAP_SUCCESS;
-                                               break;
-                                       case -1:        /* connection closed */
+
+                                       } else {
                                                rs->sr_err = LDAP_OTHER;
-                                               break;
                                        }
                                        goto done;
                                }
@@ -928,8 +914,6 @@ loop_continue:
                        e = NULL;
                        rs->sr_entry = NULL;
                }
-               
-               ldap_pvt_thread_yield();
        }
 
 nochange:
@@ -1054,13 +1038,11 @@ static int search_candidates(
 #else
        AttributeAssertion aa_ref = { NULL, BER_BVNULL };
 #endif
-#ifdef BDB_SUBENTRIES
        Filter  sf;
 #ifdef LDAP_COMP_MATCH
        AttributeAssertion aa_subentry = { NULL, BER_BVNULL, NULL };
 #else
        AttributeAssertion aa_subentry = { NULL, BER_BVNULL };
-#endif
 #endif
 
        /*
@@ -1107,7 +1089,6 @@ static int search_candidates(
        /* Filter depth increased again, adding dummy clause */
        depth++;
 
-#ifdef BDB_SUBENTRIES
        if( get_subentries_visibility( op ) ) {
                struct berval bv_subentry = BER_BVC( "subentry" );
                sf.f_choice = LDAP_FILTER_EQUALITY;
@@ -1117,7 +1098,6 @@ static int search_candidates(
                sf.f_next = nf.f_next;
                nf.f_next = &sf;
        }
-#endif
 
        /* Allocate IDL stack, plus 1 more for former tmp */
        if ( depth+1 > bdb->bi_search_stack_depth ) {