+ if( ! be_isroot( be, &op->o_ndn ) ) {
+ if ( be_issuffix( be, (struct berval *)&slap_empty_bv )
+ || be_isupdate( be, &op->o_ndn ) ) {
+ p = (Entry *)&slap_entry_root;
+
+ /* check parent for "children" acl */
+ rc = access_allowed( be, conn, op, p,
+ children, NULL, ACL_WRITE );
+ p = NULL;
+
+ switch( opinfo.boi_err ) {
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ goto retry;
+ }
+
+ if ( !rc ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<=- bdb_delete: no access "
+ "to parent\n", 0, 0, 0 );
+ rc = LDAP_INSUFFICIENT_ACCESS;
+ goto return_results;
+ }
+
+ } else {
+ Debug( LDAP_DEBUG_TRACE,
+ "<=- bdb_delete: no parent "
+ "and not root\n", 0, 0, 0);
+ rc = LDAP_INSUFFICIENT_ACCESS;
+ goto return_results;
+ }
+ }
+
+#if 0
+ if ( ltid ) {
+ DBT obj;
+ obj.data = ",";
+ obj.size = 1;
+ rc = LOCK_GET( bdb->bi_dbenv, lockid, 0, &obj,
+ DB_LOCK_WRITE, &lock);
+ }
+#endif
+ }
+
+ /* get entry for read/modify/write */
+ rc = bdb_dn2entry_w( be, ltid, ndn, &e, &matched, DB_RMW );
+
+ switch( rc ) {
+ case 0:
+ case DB_NOTFOUND:
+ break;
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ goto retry;
+ default:
+ rc = LDAP_OTHER;
+ text = "internal error";
+ goto return_results;
+ }
+
+ if ( e == NULL ) {
+ char *matched_dn = NULL;
+ BerVarray refs;
+
+ Debug( LDAP_DEBUG_ARGS,
+ "<=- bdb_delete: no such object %s\n",
+ dn->bv_val, 0, 0);
+
+ if ( matched != NULL ) {
+ matched_dn = ch_strdup( matched->e_dn );
+ refs = is_entry_referral( matched )
+ ? get_entry_referrals( be, conn, op, matched )
+ : NULL;
+ bdb_cache_return_entry_r(&bdb->bi_cache, matched );
+ matched = NULL;
+
+ } else {
+ refs = referral_rewrite( default_referral,
+ NULL, dn, LDAP_SCOPE_DEFAULT );