diff options
Diffstat (limited to 'addressbook/backend/pas/pas-backend-ldap.c')
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 66 |
1 files changed, 35 insertions, 31 deletions
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 |