diff options
Diffstat (limited to 'addressbook/backend')
-rw-r--r-- | addressbook/backend/ebook/e-book.c | 2 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book.h | 1 | ||||
-rw-r--r-- | addressbook/backend/ebook/test-client.c | 4 | ||||
-rw-r--r-- | addressbook/backend/idl/addressbook.idl | 3 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 66 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.c | 6 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.h | 1 |
7 files changed, 47 insertions, 36 deletions
diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c index d787ee8e01..fdc7252cfa 100644 --- a/addressbook/backend/ebook/e-book.c +++ b/addressbook/backend/ebook/e-book.c @@ -888,6 +888,7 @@ void e_book_authenticate_user (EBook *book, const char *user, const char *passwd, + const char *auth_method, EBookCallback cb, gpointer closure) { @@ -908,6 +909,7 @@ e_book_authenticate_user (EBook *book, GNOME_Evolution_Addressbook_Book_authenticateUser (book->priv->corba_book, user, passwd, + auth_method, &ev); if (ev._major != CORBA_NO_EXCEPTION) { diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h index cf90c8c57d..1403a23f60 100644 --- a/addressbook/backend/ebook/e-book.h +++ b/addressbook/backend/ebook/e-book.h @@ -74,6 +74,7 @@ guint e_book_get_supported_fields (EBook *book, void e_book_authenticate_user (EBook *book, const char *user, const char *passwd, + const char *auth_method, EBookCallback cb, gpointer closure); diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c index 44b20ebdde..900edcd024 100644 --- a/addressbook/backend/ebook/test-client.c +++ b/addressbook/backend/ebook/test-client.c @@ -128,7 +128,7 @@ auth_user_cb (EBook *book, EBookStatus status, gpointer closure) static void book_open_cb (EBook *book, EBookStatus status, gpointer closure) { - e_book_authenticate_user (book, "username", "password", auth_user_cb, NULL); + e_book_authenticate_user (book, "username", "password", "auth_method", auth_user_cb, NULL); } static guint @@ -146,7 +146,7 @@ ebook_create (void) } - if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) { + if (! e_book_load_default_book (book, book_open_cb, NULL)) { printf ("error calling load_uri!\n"); } diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl index 342482d573..21479d1de2 100644 --- a/addressbook/backend/idl/addressbook.idl +++ b/addressbook/backend/idl/addressbook.idl @@ -47,7 +47,8 @@ module Addressbook { */ void getVCard (in CardId id); - void authenticateUser (in string user, in string passwd); + void authenticateUser (in string user, in string passwd, + in string authMethod); /* * Adding and deleting cards in the book. diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index ff5c29168b..cfd6b0d1d5 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -2412,46 +2412,50 @@ pas_backend_ldap_process_authenticate_user (PASBackend *backend, { PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); int ldap_error; - char *query; - LDAPMessage *res, *e; - - query = g_strdup_printf ("(mail=%s)", req->user); - - ldap_error = ldap_search_s (bl->priv->ldap, - bl->priv->ldap_rootdn, - bl->priv->ldap_scope, - query, - NULL, 0, &res); - - if (ldap_error == LDAP_SUCCESS) { - char *dn; + char *dn = NULL; - e = ldap_first_entry (bl->priv->ldap, res); - dn = ldap_get_dn (bl->priv->ldap, e); + if (!strcmp (req->auth_method, "ldap/simple-email")) { + LDAPMessage *res, *e; + char *query = g_strdup_printf ("(mail=%s)", req->user); - printf ("authenticating as %s\n", dn); + ldap_error = ldap_search_s (bl->priv->ldap, + bl->priv->ldap_rootdn, + bl->priv->ldap_scope, + query, + NULL, 0, &res); + g_free (query); - ldap_error = ldap_simple_bind_s(bl->priv->ldap, - dn, - req->passwd); + if (ldap_error == LDAP_SUCCESS) { + e = ldap_first_entry (bl->priv->ldap, res); + dn = g_strdup(ldap_get_dn (bl->priv->ldap, e)); + ldap_msgfree (res); + } + else { + pas_book_respond_authenticate_user (book, + GNOME_Evolution_Addressbook_BookListener_PermissionDenied); + return; + } + } + else { + dn = g_strdup (req->user); + } - pas_book_respond_authenticate_user (book, - ldap_error_to_response (ldap_error)); + /* now authenticate against the DN we were either supplied or queried for */ + printf ("authenticating as %s\n", dn); + ldap_error = ldap_simple_bind_s(bl->priv->ldap, + dn, + req->passwd); + g_free (dn); - bl->priv->writable = (ldap_error == LDAP_SUCCESS); + pas_book_respond_authenticate_user (book, + ldap_error_to_response (ldap_error)); - if (!bl->priv->evolutionPersonChecked) - check_schema_support (bl); + bl->priv->writable = (ldap_error == LDAP_SUCCESS); - ldap_msgfree (res); - } - else { - pas_book_respond_authenticate_user (book, GNOME_Evolution_Addressbook_BookListener_PermissionDenied); - } + if (!bl->priv->evolutionPersonChecked) + check_schema_support (bl); pas_book_report_writable (book, bl->priv->writable); - - g_free (query); } static void diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c index d51d182dad..b0b35b2c0f 100644 --- a/addressbook/backend/pas/pas-book.c +++ b/addressbook/backend/pas/pas-book.c @@ -129,7 +129,7 @@ pas_book_queue_get_vcard (PASBook *book, const char *id) static void pas_book_queue_authenticate_user (PASBook *book, - const char *user, const char *passwd) + const char *user, const char *passwd, const char *auth_method) { PASRequest *req; @@ -137,6 +137,7 @@ pas_book_queue_authenticate_user (PASBook *book, req->op = AuthenticateUser; req->user = g_strdup(user); req->passwd = g_strdup(passwd); + req->auth_method = g_strdup(auth_method); pas_book_queue_request (book, req); } @@ -226,11 +227,12 @@ static void impl_GNOME_Evolution_Addressbook_Book_authenticateUser (PortableServer_Servant servant, const char* user, const char* passwd, + const char* auth_method, CORBA_Environment *ev) { PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); - pas_book_queue_authenticate_user (book, user, passwd); + pas_book_queue_authenticate_user (book, user, passwd, auth_method); } static void diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h index 6f5832d914..8afba26b45 100644 --- a/addressbook/backend/pas/pas-book.h +++ b/addressbook/backend/pas/pas-book.h @@ -45,6 +45,7 @@ typedef struct { char *change_id; char *user; char *passwd; + char *auth_method; GNOME_Evolution_Addressbook_BookViewListener listener; GNOME_Evolution_Addressbook_stringlist fields; } PASRequest; |