+ if ( e == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG ( OPERATION, ARGS,
+ "<=- bdb_delete: no such object %s\n", op->o_req_dn.bv_val, 0, 0);
+#else
+ Debug( LDAP_DEBUG_ARGS,
+ "<=- bdb_delete: no such object %s\n",
+ op->o_req_dn.bv_val, 0, 0);
+#endif
+
+ if ( matched != NULL ) {
+ rs->sr_matched = ch_strdup( matched->e_dn );
+ rs->sr_ref = is_entry_referral( matched )
+ ? get_entry_referrals( op, matched )
+ : NULL;
+ bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, matched);
+ matched = NULL;
+
+ } else {
+ rs->sr_ref = referral_rewrite( default_referral,
+ NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
+ }
+
+ rs->sr_err = LDAP_REFERRAL;
+ send_ldap_result( op, rs );
+
+ ber_bvarray_free( rs->sr_ref );
+ free( (char *)rs->sr_matched );
+ rs->sr_ref = NULL;
+ rs->sr_matched = NULL;
+
+ rs->sr_err = -1;
+ goto done;
+ }
+
+ rs->sr_err = access_allowed( op, e,
+ entry, NULL, ACL_WRITE, NULL );
+
+ if ( !rs->sr_err ) {
+ switch( opinfo.boi_err ) {
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ goto retry;
+ }
+
+#ifdef NEW_LOGGING
+ LDAP_LOG ( OPERATION, DETAIL1,
+ "<=- bdb_delete: no write access to entry\n", 0, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_TRACE,
+ "<=- bdb_delete: no write access to entry\n",
+ 0, 0, 0 );
+#endif
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+ rs->sr_text = "no write access to entry";
+ goto return_results;
+ }
+