diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c
index 1c6ab948457c1c6c7c8f4d3725d7eceacd84f635..189ea1bc95e3cedd21bfa2c6272d8b7844a0193b 100644
--- a/servers/slapd/acl.c
+++ b/servers/slapd/acl.c
@@ -794,8 +794,7 @@ acl_mask(
 				b->a_group_oc, b->a_group_at);
 			if ( ndn.bv_val )
 				free( ndn.bv_val );
-			if ( rc != 0 )
-			{
+			if ( rc != 0 ) {
 				continue;
 			}
 		}
diff --git a/servers/slapd/back-bdb/attribute.c b/servers/slapd/back-bdb/attribute.c
index d5b707e5ac7ad82e788c788022b0b5169253fe35..f2481638307ecf949d0cda91058b87bc0056f6f4 100644
--- a/servers/slapd/back-bdb/attribute.c
+++ b/servers/slapd/back-bdb/attribute.c
@@ -16,7 +16,6 @@
 #include "back-bdb.h"
 #include "proto-bdb.h"
 
-
 /* return LDAP_SUCCESS IFF we can retrieve the attributes
  * of entry with e_ndn
  */
@@ -31,6 +30,8 @@ bdb_attribute(
 	BerVarray *vals )
 {
 	struct bdbinfo *li = (struct bdbinfo *) be->be_private;
+	struct bdb_op_info *boi = (struct bdb_op_info *) op->o_private;
+	DB_TXN *txn = NULL;
 	Entry *e;
 	int	i, j, rc;
 	Attribute *attr;
@@ -58,6 +59,10 @@ bdb_attribute(
 		target ? target->e_ndn : "", 0, 0 ); 
 #endif
 
+	if( boi != NULL && be == boi->boi_bdb ) {
+		txn = boi->boi_txn;
+	}
+
 	if (target != NULL && dn_match(&target->e_nname, entry_ndn)) {
 		/* we already have a LOCKED copy of the entry */
 		e = target;
@@ -74,12 +79,15 @@ bdb_attribute(
 
 	} else {
 		/* can we find entry */
-		rc = bdb_dn2entry( be, NULL, entry_ndn, &e, NULL, 0 );
+		rc = bdb_dn2entry( be, txn, entry_ndn, &e, NULL, 0 );
 		switch( rc ) {
 		case DB_NOTFOUND:
 		case 0:
 			break;
 		default:
+			if( txn != NULL ) {
+				boi->boi_err = rc;
+			}
 			return LDAP_OTHER;
 		}
 		if (e == NULL) {
diff --git a/servers/slapd/back-bdb/group.c b/servers/slapd/back-bdb/group.c
index 9bd50a3a10816f5a04fe9d309348a37619852928..2e55471eafc1b625dc5f5f8c86e3d20774348dcf 100644
--- a/servers/slapd/back-bdb/group.c
+++ b/servers/slapd/back-bdb/group.c
@@ -34,6 +34,8 @@ bdb_group(
 )
 {
 	struct bdbinfo *li = (struct bdbinfo *) be->be_private;
+	struct bdb_op_info *boi = (struct bdb_op_info *) op->o_private;
+	DB_TXN *txn;
 	Entry *e;
 	int	rc = 1;
 	Attribute *attr;
@@ -69,6 +71,10 @@ bdb_group(
 		target->e_ndn, 0, 0 ); 
 #endif
 
+	if( boi != NULL && be == boi->boi_bdb ) {
+		txn = boi->boi_txn;
+	}
+
 	if (dn_match(&target->e_name, gr_ndn)) {
 		/* we already have a LOCKED copy of the entry */
 		e = target;
@@ -82,8 +88,11 @@ bdb_group(
 #endif
 	} else {
 		/* can we find group entry */
-		rc = bdb_dn2entry( be, NULL, gr_ndn, &e, NULL, 0 );
+		rc = bdb_dn2entry( be, txn, gr_ndn, &e, NULL, 0 );
 		if( rc ) {
+			if( txn ) {
+				boi->boi_err = rc;
+			}
 			return( 1 );
 		}
 		if (e == NULL) {
diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c
index 3e3956d74732daf57b1e984b54df397f7a3bf623..8c5e43103c2df0e0cd426cac3be19bf018d0f0ba 100644
--- a/servers/slapd/back-bdb/init.c
+++ b/servers/slapd/back-bdb/init.c
@@ -446,11 +446,20 @@ bdb_initialize(
 	bi->bi_op_abandon = 0;
 
 	bi->bi_extended = bdb_extended;
-	bi->bi_acl_group = bdb_group;
 
+#if 0
+	/*
+	 * these routines (and their callers) are not yet designed
+	 * to work with transaction.  Using them may cause deadlock.
+	 */
+	bi->bi_acl_group = bdb_group;
 	bi->bi_acl_attribute = bdb_attribute;
-	bi->bi_chk_referrals = bdb_referrals;
+#else
+	bi->bi_acl_group = 0;
+	bi->bi_acl_attribute = 0;
+#endif
 
+	bi->bi_chk_referrals = bdb_referrals;
 	bi->bi_entry_release_rw = bdb_entry_release;
 
 	/*