310562
diff --git a/bin/Makefile.in b/bin/Makefile.in
310562
index 187ec23..e6179e7 100644
310562
--- a/bin/Makefile.in
310562
+++ b/bin/Makefile.in
bc5dde
@@ -19,8 +19,8 @@ srcdir =	@srcdir@
bc5dde
 VPATH =		@srcdir@
bc5dde
 top_srcdir =	@top_srcdir@
bc5dde
 
d56ed2
-SUBDIRS =	named named-pkcs11 rndc dig dnssec dnssec-pkcs11 tools tests nsupdate \
bc5dde
-		check confgen @PYTHON_TOOLS@ @PKCS11_TOOLS@
d56ed2
+SUBDIRS =	named named-pkcs11 named-sdb rndc dig dnssec dnssec-pkcs11 tools tests nsupdate \
bc5dde
+		check confgen @PYTHON_TOOLS@ @PKCS11_TOOLS@ sdb_tools
bc5dde
 TARGETS =
bc5dde
 
bc5dde
 @BIND9_MAKE_RULES@
310562
diff --git a/bin/named-sdb/Makefile.in b/bin/named-sdb/Makefile.in
310562
index bc5be2a..71324d9 100644
310562
--- a/bin/named-sdb/Makefile.in
310562
+++ b/bin/named-sdb/Makefile.in
310562
@@ -34,10 +34,10 @@ top_srcdir =	@top_srcdir@
310562
 #
310562
 # Add database drivers here.
310562
 #
310562
-DBDRIVER_OBJS =
310562
-DBDRIVER_SRCS =
310562
+DBDRIVER_OBJS =	ldapdb.@O@ pgsqldb.@O@ dirdb.@O@
310562
+DBDRIVER_SRCS =	ldapdb.c pgsqldb.c dirdb.c
310562
 DBDRIVER_INCLUDES =
310562
-DBDRIVER_LIBS =
310562
+DBDRIVER_LIBS =	-lldap -llber -lpq
bc5dde
 
310562
 DLZ_DRIVER_DIR =	${top_srcdir}/contrib/dlz/drivers
bc5dde
 
310562
@@ -83,7 +83,7 @@ NOSYMLIBS =	${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
bc5dde
 
bc5dde
 SUBDIRS =	unix
bc5dde
 
310562
-TARGETS =	named@EXEEXT@ lwresd@EXEEXT@
310562
+TARGETS =	named-sdb@EXEEXT@
bc5dde
 
310562
 GEOIPLINKOBJS = geoip.@O@
bc5dde
 
310562
@@ -146,7 +146,7 @@ config.@O@: config.c bind.keys.h
310562
 		-DNS_SYSCONFDIR=\"${sysconfdir}\" \
310562
 		-c ${srcdir}/config.c
bc5dde
 
310562
-named@EXEEXT@: ${OBJS} ${UOBJS} ${DEPLIBS}
310562
+named-sdb@EXEEXT@: ${OBJS} ${UOBJS} ${DEPLIBS}
310562
 	export MAKE_SYMTABLE="yes"; \
310562
 	export BASEOBJS="${OBJS} ${UOBJS}"; \
310562
 	${FINALBUILDCMD}
310562
@@ -177,15 +177,9 @@ statschannel.@O@: bind9.xsl.h bind9.ver3.xsl.h
bc5dde
 
310562
 installdirs:
310562
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
310562
-	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man5
310562
-	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
bc5dde
-
310562
-install:: named@EXEEXT@ lwresd@EXEEXT@ installdirs
310562
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named@EXEEXT@ ${DESTDIR}${sbindir}
310562
-	(cd ${DESTDIR}${sbindir}; rm -f lwresd@EXEEXT@; @LN@ named@EXEEXT@ lwresd@EXEEXT@)
310562
-	${INSTALL_DATA} ${srcdir}/named.8 ${DESTDIR}${mandir}/man8
310562
-	${INSTALL_DATA} ${srcdir}/lwresd.8 ${DESTDIR}${mandir}/man8
310562
-	${INSTALL_DATA} ${srcdir}/named.conf.5 ${DESTDIR}${mandir}/man5
310562
+
310562
+install:: named-sdb@EXEEXT@ installdirs
310562
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-sdb@EXEEXT@ ${DESTDIR}${sbindir}
310562
 
310562
 @DLZ_DRIVER_RULES@
310562
 
310562
diff --git a/bin/named-sdb/main.c b/bin/named-sdb/main.c
310562
index a00687f..4fba625 100644
310562
--- a/bin/named-sdb/main.c
310562
+++ b/bin/named-sdb/main.c
310562
@@ -86,6 +86,9 @@
bc5dde
  * Include header files for database drivers here.
bc5dde
  */
bc5dde
 /* #include "xxdb.h" */
bc5dde
+#include "ldapdb.h"
bc5dde
+#include "pgsqldb.h"
bc5dde
+#include "dirdb.h"
bc5dde
 
bc5dde
 #ifdef CONTRIB_DLZ
bc5dde
 /*
310562
@@ -817,6 +820,10 @@ setup(void) {
bc5dde
 		ns_main_earlyfatal("isc_app_start() failed: %s",
bc5dde
 				   isc_result_totext(result));
bc5dde
 
bc5dde
+	ldapdb_clear();
bc5dde
+	pgsqldb_clear();
bc5dde
+	dirdb_clear();
bc5dde
+
bc5dde
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
 		      ISC_LOG_NOTICE, "starting %s %s%s", ns_g_product,
bc5dde
 		      ns_g_version, saved_command_line);
310562
@@ -929,6 +936,57 @@ setup(void) {
bc5dde
 				   isc_result_totext(result));
bc5dde
 #endif
bc5dde
 
bc5dde
+        result = ldapdb_init();
bc5dde
+        if (result != ISC_R_SUCCESS)
bc5dde
+        {
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_ERROR, 
bc5dde
+                          "SDB ldap module initialisation failed: %s.",
bc5dde
+                          isc_result_totext(result)
bc5dde
+                );
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_ERROR, 
bc5dde
+                          "SDB ldap zone database will be unavailable."
bc5dde
+                );
bc5dde
+        }else
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_NOTICE, "SDB ldap zone database module loaded."
bc5dde
+                         );
bc5dde
+
bc5dde
+        result = pgsqldb_init();
bc5dde
+        if (result != ISC_R_SUCCESS)
bc5dde
+        {
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_ERROR, 
bc5dde
+                          "SDB pgsql module initialisation failed: %s.",
bc5dde
+                          isc_result_totext(result)
bc5dde
+                );
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_ERROR, 
bc5dde
+                          "SDB pgsql zone database will be unavailable."
bc5dde
+                );
bc5dde
+        }else
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_NOTICE, "SDB postgreSQL DB zone database module loaded."
bc5dde
+                         );
bc5dde
+
bc5dde
+        result = dirdb_init();
bc5dde
+        if (result != ISC_R_SUCCESS)
bc5dde
+        {
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_ERROR, 
bc5dde
+                          "SDB directory DB module initialisation failed: %s.",
bc5dde
+                          isc_result_totext(result)
bc5dde
+                );
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_ERROR, 
bc5dde
+                          "SDB directory DB zone database will be unavailable."
bc5dde
+                );
bc5dde
+        }else
bc5dde
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
+                          ISC_LOG_NOTICE, "SDB directory DB zone database module loaded."
bc5dde
+                         );
bc5dde
+
bc5dde
 	ns_server_create(ns_g_mctx, &ns_g_server);
bc5dde
 }
bc5dde
 
310562
@@ -960,6 +1018,10 @@ cleanup(void) {
bc5dde
 
bc5dde
 	dns_name_destroy();
bc5dde
 
bc5dde
+        ldapdb_clear();
bc5dde
+        pgsqldb_clear();
bc5dde
+        dirdb_clear();
bc5dde
+
bc5dde
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
bc5dde
 		      ISC_LOG_NOTICE, "exiting");
bc5dde
 	ns_log_shutdown();
310562
diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in
310562
index bc5be2a..3c69c9b 100644
310562
--- a/bin/named/Makefile.in
310562
+++ b/bin/named/Makefile.in
310562
@@ -51,7 +51,7 @@ CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
310562
 		${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
310562
 		${DLZDRIVER_INCLUDES} ${DBDRIVER_INCLUDES} @DST_OPENSSL_INC@
bc5dde
 
310562
-CDEFINES =      @CONTRIB_DLZ@ @CRYPTO@
310562
+CDEFINES =      @CRYPTO@
bc5dde
 
310562
 CWARNINGS =
bc5dde
 
310562
@@ -75,11 +75,11 @@ DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
bc5dde
 
310562
 LIBS =		${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
310562
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} \
310562
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
310562
+		@LIBS@
bc5dde
 
310562
 NOSYMLIBS =	${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
310562
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCNOSYMLIBS} \
310562
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
310562
+		@LIBS@
bc5dde
 
310562
 SUBDIRS =	unix
bc5dde
 
310562
@@ -94,8 +94,7 @@ OBJS =		builtin.@O@ client.@O@ config.@O@ control.@O@ \
310562
 		tkeyconf.@O@ tsigconf.@O@ update.@O@ xfrout.@O@ \
310562
 		zoneconf.@O@ \
310562
 		lwaddr.@O@ lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \
310562
-		lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \
310562
-		${DLZDRIVER_OBJS} ${DBDRIVER_OBJS}
310562
+		lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@
bc5dde
 
310562
 UOBJS =		unix/os.@O@ unix/dlz_dlopen_driver.@O@
bc5dde
 
310562
@@ -110,8 +109,7 @@ SRCS =		builtin.c client.c config.c control.c \
310562
 		tkeyconf.c tsigconf.c update.c xfrout.c \
310562
 		zoneconf.c \
310562
 		lwaddr.c lwresd.c lwdclient.c lwderror.c lwdgabn.c \
310562
-		lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \
310562
-		${DLZDRIVER_SRCS} ${DBDRIVER_SRCS}
310562
+		lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c
bc5dde
 
310562
 MANPAGES =	named.8 lwresd.8 named.conf.5
310562
 
310562
@@ -187,7 +185,5 @@ install:: named@EXEEXT@ lwresd@EXEEXT@ installdirs
310562
 	${INSTALL_DATA} ${srcdir}/lwresd.8 ${DESTDIR}${mandir}/man8
310562
 	${INSTALL_DATA} ${srcdir}/named.conf.5 ${DESTDIR}${mandir}/man5
310562
 
310562
-@DLZ_DRIVER_RULES@
310562
-
310562
 named-symtbl.@O@: named-symtbl.c
310562
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c named-symtbl.c
310562
diff --git a/configure.in b/configure.in
310562
index 9bb9a2a..d72093f 100644
310562
--- a/configure.in
310562
+++ b/configure.in
310562
@@ -4018,12 +4018,15 @@ AC_CONFIG_FILES([
d56ed2
 	bin/named-pkcs11/Makefile
d56ed2
 	bin/named-pkcs11/unix/Makefile
bc5dde
 	bin/named/unix/Makefile
bc5dde
+	bin/named-sdb/Makefile
bc5dde
+	bin/named-sdb/unix/Makefile
bc5dde
 	bin/nsupdate/Makefile
bc5dde
 	bin/pkcs11/Makefile
bc5dde
 	bin/python/Makefile
bc5dde
 	bin/python/dnssec-checkds.py
bc5dde
 	bin/python/dnssec-coverage.py
bc5dde
 	bin/rndc/Makefile
bc5dde
+	bin/sdb_tools/Makefile
bc5dde
 	bin/tests/Makefile
bc5dde
 	bin/tests/atomic/Makefile
bc5dde
 	bin/tests/db/Makefile