On Mon, Sep 16, 2002 at 04:37:21PM +0300, Mike Jackson wrote:
> Hi,
> I made a small fix, since the v2 libs didn't support ldap_set_option(),
> I just removed it from the v2 section. Sorry for missing it the first
> time!
>
I finaly found some time to have a closer look at your patch.
I started to add it to our patch but I have some question and comments:
Your mentioning that ldap_set_option() is not supported in the v2 libs.
I realized that in my old OpenLDAP 1.2.x libs there is no such function
ldap_set_option() (this is why we had the block #ifdef-ed).
I also see that my OpenLDAP 2.0.x libs do have both ldap_set_option() and
LDAP_VERSION2 so I do not understand your comment about the
ldap_set_option() support.
I removed the stuff with the error number LDAP_VERSION_ERROR, it is not
needed becasue it is not en error.
If the connect with version 2 is successful there is no need for an error.
> --- qmail-ldap.orig/qldap-errno.c Sun Sep 8 17:01:31 2002
> +++ qmail-ldap.v3/qldap-errno.c Mon Sep 16 15:25:54 2002
> @@ -12,6 +12,8 @@
> return error_str(errno);
> case LDAP_INIT:
> return "initalizing of ldap connection failed";
> + case LDAP_VERSION_ERROR:
> + return "LDAPv3 not supported, dropping to LDAPv2";
> case LDAP_BIND:
> return "binding to ldap server failed";
> case LDAP_SEARCH:
> diff -u qmail-ldap.orig/qldap-errno.h qmail-ldap.v3/qldap-errno.h
> --- qmail-ldap.orig/qldap-errno.h Sun Sep 8 17:01:31 2002
> +++ qmail-ldap.v3/qldap-errno.h Mon Sep 16 15:26:09 2002
> @@ -9,6 +9,7 @@
>
> /* first the LDAP errnos */
> #define LDAP_INIT 2 /* error while
>initalizing ldap connection */
> +#define LDAP_VERSION_ERROR 32 /* error using
>specified protocol version */
> #define LDAP_BIND 3 /* error while binding
>to ldap server */
> #define LDAP_BIND_UNREACH 31 /* ldap server down or
>unreachable */
> #define LDAP_SEARCH 4 /* error on ldap
>search */
> diff -u qmail-ldap.orig/qldap-ldaplib.c qmail-ldap.v3/qldap-ldaplib.c
> --- qmail-ldap.orig/qldap-ldaplib.c Sun Sep 8 17:01:31 2002
> +++ qmail-ldap.v3/qldap-ldaplib.c Mon Sep 16 16:32:44 2002
> @@ -231,16 +231,20 @@
> }
> log(128, "init successful");
>
> -#ifdef LDAP_OPT_PROTOCOL_VERSION
> - /* set LDAP connection options (only with Mozilla LDAP SDK) */
> - version = LDAP_VERSION2;
> + /* set LDAP connection options according to RFC 2251, Section 4.2*/
> + version = LDAP_VERSION3;
> if ( ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version)
> - != LDAP_SUCCESS ) {
> - qldap_errno = LDAP_INIT;
> - return -1;
> + == LDAP_OPT_SUCCESS) {
> + log(128, ", set_option to LDAPv3 successful");
> + } else {
> + ldap_unbind(ld);
> + qldap_errno = LDAP_VERSION_ERROR;
> + if ( (ld = ldap_init(qldap_server.s,PORT_LDAP)) == 0 ) {
> + qldap_errno = LDAP_INIT;
> + return -1;
> + }
> + log(128, "init successful, using LDAPv2");
> }
> - log(128, ", set_option successful");
> -#endif
>
> /* connect to the LDAP server */
> if ( (rc = ldap_simple_bind_s(ld,qldap_user.s,qldap_password.s))
--
:wq Claudio