- /* get entry with reader lock */
- if ( deref & LDAP_DEREF_FINDING ) {
- e = deref_dn_r( be, nbase, &err, &matched, &text );
+ /* grab giant lock for reading */
+ ldap_pvt_thread_rdwr_rlock(&li->li_giant_rwlock);
+
+ if ( op->o_req_ndn.bv_len == 0 ) {
+ /* DIT root special case */
+ e = (Entry *) &slap_entry_root;
+
+ /* need normalized dn below */
+ ber_dupbv( &realbase, &e->e_nname );
+
+ candidates = search_candidates( op, e, op->ors_filter,
+ op->ors_scope, op->ors_deref,
+ manageDSAit || get_domainScope(op) );
+
+ goto searchit;
+
+ } else if ( op->ors_deref & LDAP_DEREF_FINDING ) {
+ /* deref dn and get entry with reader lock */
+ e = deref_dn_r( op->o_bd, &op->o_req_ndn,
+ &rs->sr_err, &matched, &rs->sr_text );
+
+ if( rs->sr_err == LDAP_NO_SUCH_OBJECT ) rs->sr_err = LDAP_REFERRAL;