Index: emsabp.c
===================================================================
--- emsabp.c	(revision 1356)
+++ emsabp.c	(working copy)
@@ -28,6 +28,7 @@
 
 #include "mapiproxy/dcesrv_mapiproxy.h"
 #include "dcesrv_exchange_nsp.h"
+#include <ldb_wrap.h>
 
 /**
    \details Initialize the EMSABP context and open connections to
@@ -44,9 +45,6 @@
 	TALLOC_CTX		*mem_ctx;
 	struct emsabp_context	*emsabp_ctx;
 	struct tevent_context	*ev;
-	char			*configuration = NULL;
-	char			*users = NULL;
-	int			ret;
 
 	/* Sanity checks */
 	if (!lp_ctx) return NULL;
@@ -71,34 +69,20 @@
 	emsabp_ctx->lp_ctx = lp_ctx;
 
 	/* Return an opaque context pointer on the configuration database */
-	configuration = private_path(mem_ctx, lp_ctx, "configuration.ldb");
-	emsabp_ctx->conf_ctx = ldb_init(mem_ctx, ev);
+	emsabp_ctx->conf_ctx = ldb_wrap_connect(mem_ctx, ev, lp_ctx, "configuration.ldb", 
+						NULL, NULL, 
+						LDB_FLG_RDONLY, NULL);
 	if (!emsabp_ctx->conf_ctx) {
-		talloc_free(configuration);
-		talloc_free(mem_ctx);
-		return NULL;
-	}
-
-	ret = ldb_connect(emsabp_ctx->conf_ctx, configuration, LDB_FLG_RDONLY, NULL);
-	talloc_free(configuration);
-	if (ret != LDB_SUCCESS) {
 		DEBUG(0, ("[%s:%d]: Connection to \"configuration.ldb\" failed\n", __FUNCTION__, __LINE__));
 		talloc_free(mem_ctx);
 		return NULL;
 	}
 
 	/* Return an opaque context pointer to the users database */
-	users = private_path(mem_ctx, lp_ctx, "users.ldb");
-	emsabp_ctx->users_ctx = ldb_init(mem_ctx, ev);
+	emsabp_ctx->users_ctx = ldb_wrap_connect(mem_ctx, ev, lp_ctx, "users.ldb", 
+						 NULL, NULL, 
+						 LDB_FLG_RDONLY, NULL);
 	if (!emsabp_ctx->users_ctx) {
-		talloc_free(users);
-		talloc_free(mem_ctx);
-		return NULL;
-	}
-
-	ret = ldb_connect(emsabp_ctx->users_ctx, users, LDB_FLG_RDONLY, NULL);
-	talloc_free(users);
-	if (ret != LDB_SUCCESS) {
 		DEBUG(0, ("[%s:%d]: Connection to \"users.ldb\" failed\n", __FUNCTION__, __LINE__));
 		talloc_free(mem_ctx);
 		return NULL;
