[evolution-data-server/gnome-2-28] Bug #600573 - e-addressbook-factory aborts on ldap lookup



commit d9e2bc804b7f00ecd3397c8d134735bd1870cf76
Author: Milan Crha <mcrha redhat com>
Date:   Mon Nov 23 12:24:23 2009 +0100

    Bug #600573 - e-addressbook-factory aborts on ldap lookup

 addressbook/backends/ldap/e-book-backend-ldap.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c
index afae3ad..b8810ca 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -4796,7 +4796,7 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
 
 	if (!g_ascii_strncasecmp (auth_method, LDAP_SIMPLE_PREFIX, strlen (LDAP_SIMPLE_PREFIX))) {
 
-		if (!strcmp (auth_method, "ldap/simple-email")) {
+		if (bl->priv->ldap && !strcmp (auth_method, "ldap/simple-email")) {
 			LDAPMessage    *res, *e;
 			gchar *query = g_strdup_printf ("(mail=%s)", user);
 
@@ -4826,6 +4826,7 @@ e_book_backend_ldap_authenticate_user (EBookBackend *backend,
 
 				g_static_rec_mutex_lock (&eds_ldap_handler_lock);
 				entry_dn = ldap_get_dn (bl->priv->ldap, e);
+				bl->priv->connected = FALSE; /* to reconnect with credentials */
 				g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
 				dn = g_strdup(entry_dn);
 
@@ -5040,6 +5041,7 @@ e_book_backend_ldap_load_source (EBookBackend             *backend,
 	const gchar *str;
 	const gchar *offline;
 	gint result;
+	gboolean auth_required;
 
 	g_assert (bl->priv->connected == FALSE);
 
@@ -5127,7 +5129,8 @@ e_book_backend_ldap_load_source (EBookBackend             *backend,
 	}
 
 	str = e_source_get_property (source, "auth");
-	if (str && *str && !g_str_equal (str, "none") && !g_str_equal (str, "0")) {
+	auth_required = str && *str && !g_str_equal (str, "none") && !g_str_equal (str, "0");
+	if (auth_required && !g_str_equal (str, "ldap/simple-email")) {
 		/* Requires authentication, do not try to bind without it,
 		   but report success instead, as we are loaded. */
 		if (enable_debug)
@@ -5145,6 +5148,11 @@ e_book_backend_ldap_load_source (EBookBackend             *backend,
 		return result;
 	}
 
+	if (auth_required) {
+		e_book_backend_notify_auth_required (E_BOOK_BACKEND (bl));
+		return result;
+	}
+
 	if (bl->priv->marked_for_offline)
 		generate_cache (bl);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]