Re: OpenLDAP 2.0 and PHP, things need be done

From: Date: Fri, 25 Aug 2000 20:25:15 +0000
Subject: Re: OpenLDAP 2.0 and PHP, things need be done
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-30691@lists.php.net to get a copy of this message
I got some comments regarding my last mail, and a patch that I really want to include in 4.0.2. On Fri, Aug 25, 2000 at 04:03:50PM +0200, Stig Venaas wrote: > I just tried to use PHP with OpenLDAP 2.0 gamma. 2.0 will be released RSN > so we should make sure 4.0.3 will work with it. Actually we should perhaps > do it for 4.0.2 since 4.0.3 will be out after the official release of > gamma. 2.0 is probably released on Monday, would be nice to support it in 4.0.2 that also is released about then. > The problem I've found so far is error reporting. Here is some typical > code from ldap.c: > > #if !HAVE_NSLDAP > #if LDAP_API_VERSION > 2000 > /* New versions of OpenLDAP do it this way */ > php_error(E_WARNING,"LDAP: Unable to bind to server: > %s",ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL))); > #else > php_error(E_WARNING,"LDAP: Unable to bind to server: > %s",ldap_err2string(ldap->ld_errno)); > #endif > #endif > > ldap_get_lderrno seems not to exist any longer, and is neither in the spec. I have a patch that I've tested with both old and the new OpenLDAP, it should not affect old LDAP versions or the Netscape SDK. I've added static int _get_lderrno(LDAP *ldap) { #if !HAVE_NSLDAP #if LDAP_API_VERSION > 2000 int lderr; /* New versions of OpenLDAP do it this way */ ldap_get_option(ldap, LDAP_OPT_ERROR_NUMBER, &lderr); return lderr; #else return ldap->ld_errno; #endif #else return ldap_get_lderrno(ldap,NULL,NULL); #endif } and then I've replaced code like: #if !HAVE_NSLDAP #if LDAP_API_VERSION > 2000 php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL))); #else php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(ldap->ld_errno)); #endif #else php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL))); #endif with php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(_get_lderrno(ldap))); This should only affect APIs other than NS where API_VERSION>2000. I've tested OpenLDAP and I doubt there are many using others. Can I put this into 4.0.2? Stig

« previous php.dev (#30691) next »