Index: Makefile
===================================================================
--- Makefile	(revision 9b8a38bfa9a89e9741521ac522927c80b68976cf)
+++ Makefile	(revision 728a981e422539df38d27d87e33829082d376ac6)
@@ -13,4 +13,6 @@
 headers = account.h bitlbee.h commands.h conf.h config.h crypting.h help.h ini.h ipc.h irc.h log.h nick.h query.h set.h sock.h storage.h url.h user.h protocols/http_client.h protocols/md5.h protocols/nogaim.h protocols/proxy.h protocols/sha.h protocols/ssl_client.h
 subdirs = protocols
+
+objects += $(LDB_OBJ)
 
 # Expansion of variables
Index: configure
===================================================================
--- configure	(revision 9b8a38bfa9a89e9741521ac522927c80b68976cf)
+++ configure	(revision 728a981e422539df38d27d87e33829082d376ac6)
@@ -28,4 +28,5 @@
 strip=1
 ipv6=1
+ldb=auto
 ssl=auto
 
@@ -63,4 +64,6 @@
 
 --ipv6=0/1	IPv6 socket support			$ipv6
+
+--ldb=0/1/auto	LDB support				$ldb
 
 --ssl=...	SSL library to use (gnutls, nss, openssl, bogus, auto)
@@ -221,4 +224,18 @@
 }
 
+detect_ldb()
+{
+	if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG ldb; then
+		cat<<EOF>>Makefile.settings
+EFLAGS+=`$PKG_CONFIG --libs ldb`
+CFLAGS+=`$PKG_CONFIG --cflags ldb`
+EOF
+		ldb=1
+		ret=1
+	else
+		ret=0
+	fi
+}
+
 if [ "$msn" = 1 -o "$jabber" = 1 ]; then
 	if [ "$ssl" = "auto" ]; then
@@ -281,4 +298,16 @@
 fi
 
+if [ "$ldb" = "auto" ]; then
+	detect_ldb
+fi
+
+if [ "$ldb" = 0 ]; then
+	echo "LDB_OBJ=\# no ldb" >> Makefile.settings
+	echo "#undef LDB" >> config.h
+elif [ "$ldb" = 1 ]; then
+	echo "#define LDB 1" >> config.h
+	echo "LDB_OBJ=storage_ldb.o" >> Makefile.settings
+fi
+
 if [ "$strip" = 0 ]; then
 	echo "STRIP=\# skip strip" >> Makefile.settings;
@@ -431,2 +460,8 @@
 	echo '  Building without IM-protocol support. We wish you a lot of fun...';
 fi
+
+if [ "$ldb" = "0" ]; then
+	echo "  LDB storage backend disabled."
+else
+	echo "  LDB storage backend enabled."
+fi
Index: doc/bitlbee.schema
===================================================================
--- doc/bitlbee.schema	(revision 728a981e422539df38d27d87e33829082d376ac6)
+++ doc/bitlbee.schema	(revision 728a981e422539df38d27d87e33829082d376ac6)
@@ -0,0 +1,28 @@
+## LDAP Schema file for BitlBee
+##
+## We need the following object classes and related attributes:
+## bitlBeeNick:
+##  - nick
+##  - password
+##  - setting (multiple values)
+## 
+## bitlBeeAccount:
+##  - protocol (msn, oscar, jabber, yahoo, ...)
+##  - username
+##  - password
+##  - server name
+##  - autoconnect (true/false)
+##
+## bitlBeeBuddy:
+##  - nick
+##  - handle
+
+## each bitlBeeNick has zero or more bitlBeeAccount subentries
+## and bitlBeeAccount entries contain zero or more bitlBeeBuddy entries
+
+## The admin needs to setup the LDAP server to:
+## - allow anonymous users to auth against bitlBeeNick objects on the 
+##   password field
+## - allow anonymous users to create new objects that start with nick=
+## - allow read/write for a user that is authenticated only to his/her own 
+##   object and subentries
Index: storage.c
===================================================================
--- storage.c	(revision 9b8a38bfa9a89e9741521ac522927c80b68976cf)
+++ storage.c	(revision 728a981e422539df38d27d87e33829082d376ac6)
@@ -6,4 +6,6 @@
 
 /* Support for multiple storage backends */
+
+/* Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org> */
 
 /*
Index: storage_ldb.c
===================================================================
--- storage_ldb.c	(revision 728a981e422539df38d27d87e33829082d376ac6)
+++ storage_ldb.c	(revision 728a981e422539df38d27d87e33829082d376ac6)
@@ -0,0 +1,63 @@
+  /********************************************************************\
+  * BitlBee -- An IRC to other IM-networks gateway                     *
+  *                                                                    *
+  * Copyright 2002-2004 Wilmer van der Gaast and others                *
+  \********************************************************************/
+
+/* Storage backend that uses the LDB embedded LDAP-like database */
+
+/* Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org> */
+
+/*
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License with
+  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
+  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+  Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#define BITLBEE_CORE
+#include "bitlbee.h"
+#include <ldb.h>
+
+static void sldb_init (void)
+{
+}
+
+static storage_status_t sldb_load ( const char *my_nick, const char* password, irc_t *irc )
+{
+	return STORAGE_OK;
+}
+
+static storage_status_t sldb_save( irc_t *irc, int overwrite )
+{
+	return STORAGE_OK;
+}
+
+static storage_status_t sldb_check_pass( const char *nick, const char *password )
+{
+	return STORAGE_OK;
+}
+
+static storage_status_t sldb_remove( const char *nick, const char *password )
+{
+	return STORAGE_OK;
+}
+
+storage_t storage_ldb = {
+	.name = "ldb",
+	.init = sldb_init,
+	.check_pass = sldb_check_pass,
+	.remove = sldb_remove,
+	.load = sldb_load,
+	.save = sldb_save
+};
