diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-12-19 05:36:44 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-12-19 05:36:44 +0800 |
commit | 87c51e6a0a55869faf5ce3f958732c2f55807354 (patch) | |
tree | e923d54eba0d380c1c354eb19ce8f09714462911 /addressbook | |
parent | 956ed2760e1d11c66eb1be60fdb9aa1cd9337e64 (diff) | |
download | gsoc2013-evolution-87c51e6a0a55869faf5ce3f958732c2f55807354.tar.gz gsoc2013-evolution-87c51e6a0a55869faf5ce3f958732c2f55807354.tar.zst gsoc2013-evolution-87c51e6a0a55869faf5ce3f958732c2f55807354.zip |
always use LDAP_NAME_ERROR (in the openldap1 case it's #defined to
2000-12-18 Chris Toshok <toshok@helixcode.com>
* backend/pas/pas-backend-ldap.c (ldap_error_to_response): always
use LDAP_NAME_ERROR (in the openldap1 case it's #defined to
NAME_ERROR).
(build_card_from_entry): ldap_get_values can return NULL. also,
openldap2 keeps us from getting at ldap->ld_errno, so we can't
tell if there was a decoding error like we used to. the double
free problem where ldap would free the ber if there was a decoding
problem might be fixed now.. further investigation is needed.
for now we leak in openldap2.
(ldap_search_handler): the ldap structure is opaque, so use
ldap_search_ext to give the extra information (the max responses,
timeout, etc.) in the openldap2 case.
svn path=/trunk/; revision=7073
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 15 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 66 |
2 files changed, 62 insertions, 19 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 036ba2cd7e..07dee161a6 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,18 @@ +2000-12-18 Chris Toshok <toshok@helixcode.com> + + * backend/pas/pas-backend-ldap.c (ldap_error_to_response): always + use LDAP_NAME_ERROR (in the openldap1 case it's #defined to + NAME_ERROR). + (build_card_from_entry): ldap_get_values can return NULL. also, + openldap2 keeps us from getting at ldap->ld_errno, so we can't + tell if there was a decoding error like we used to. the double + free problem where ldap would free the ber if there was a decoding + problem might be fixed now.. further investigation is needed. + for now we leak in openldap2. + (ldap_search_handler): the ldap structure is opaque, so use + ldap_search_ext to give the extra information (the max responses, + timeout, etc.) in the openldap2 case. + 2000-12-13 Christopher James Lahey <clahey@helixcode.com> * backend/pas/pas-backend-ldap.c (ldap_error_to_response): Test diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index 5c7be3335a..4d86538a6e 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -22,6 +22,16 @@ #undef LDAP_DEBUG #endif +#if LDAP_VENDOR_VERSION > 20000 +#define OPENLDAP2 +#else +#define OPENLDAP1 +#endif + +#ifdef OPENLDAP1 +#define LDAP_NAME_ERROR(x) NAME_ERROR(x) +#endif + #include "pas-backend-ldap.h" #include "pas-book.h" #include "pas-card-cursor.h" @@ -330,11 +340,7 @@ ldap_error_to_response (int ldap_error) { if (ldap_error == LDAP_SUCCESS) return GNOME_Evolution_Addressbook_BookListener_Success; -#ifdef LDAP_NAME_ERROR else if (LDAP_NAME_ERROR (ldap_error)) -#else - else if (NAME_ERROR (ldap_error)) -#endif return GNOME_Evolution_Addressbook_BookListener_CardNotFound; else if (ldap_error == LDAP_INSUFFICIENT_ACCESS) return GNOME_Evolution_Addressbook_BookListener_PermissionDenied; @@ -1304,27 +1310,31 @@ build_card_from_entry (LDAP *ldap, LDAPMessage *e) char **values; values = ldap_get_values (ldap, e, attr); - if (info->prop_type & PROP_TYPE_NORMAL) { + if (values) { + if (info->prop_type & PROP_TYPE_NORMAL) { /* if it's a normal property just set the string */ - e_card_simple_set (card, info->field_id, values[0]); + e_card_simple_set (card, info->field_id, values[0]); - } - else if (info->prop_type & PROP_TYPE_LIST) { + } + else if (info->prop_type & PROP_TYPE_LIST) { /* if it's a list call the ecard-populate function, which calls gtk_object_set to set the property */ - info->populate_ecard_func(card, - values); - } + info->populate_ecard_func(card, + values); + } - ldap_value_free (values); + ldap_value_free (values); + } } } +#ifndef OPENLDAP2 /* if ldap->ld_errno == LDAP_DECODING_ERROR there was an error decoding an attribute, and we shouldn't free ber, since the ldap library already did it. */ if (ldap->ld_errno != LDAP_DECODING_ERROR && ber) ber_free (ber, 0); +#endif e_card_simple_sync_card (card); @@ -1408,16 +1418,34 @@ ldap_search_handler (PASBackend *backend, LDAPOp *op) PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); PASBackendLDAPBookView *view = search_op->view; LDAP *ldap = bl->priv->ldap; - + int ldap_err; + +#ifdef OPENLDAP2 + ldap_err = ldap_search_ext (ldap, bl->priv->ldap_rootdn, + bl->priv->ldap_scope, + search_op->ldap_query, + NULL, 0, + NULL, /* XXX */ + NULL, /* XXX */ + NULL, + LDAP_MAX_SEARCH_RESPONSES, &view->search_msgid); + + if (ldap_err != LDAP_SUCCESS) { + pas_book_view_notify_status_message (view->book_view, ldap_err2string(ldap_err)); + return TRUE; /* act synchronous in this case */ + } +#else ldap->ld_sizelimit = LDAP_MAX_SEARCH_RESPONSES; ldap->ld_deref = LDAP_DEREF_ALWAYS; + view->search_msgid = ldap_search (ldap, bl->priv->ldap_rootdn, + bl->priv->ldap_scope, + search_op->ldap_query, + NULL, 0); + ldap_err = ldap->ld_errno; +#endif - if ((view->search_msgid = ldap_search (ldap, - bl->priv->ldap_rootdn, - bl->priv->ldap_scope, - search_op->ldap_query, - NULL, 0)) == -1) { - pas_book_view_notify_status_message (view->book_view, ldap_err2string(ldap->ld_errno)); + if (view->search_msgid == -1) { + pas_book_view_notify_status_message (view->book_view, ldap_err2string(ldap_err)); return TRUE; /* act synchronous in this case */ } else { |