Re: OpenLDAP 2.0 and PHP, things need be done
| From: | Andi Gutmans | Date: | Sat, 26 Aug 2000 14:44:56 +0000 |
| Subject: | Re: OpenLDAP 2.0 and PHP, things need be done | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-30744@lists.php.net to get a copy of this message | ||
It looks like a small change and if it behaves exactly the same for the old databases I think it's OK to include this in 4.0.2, but we should probably hear from some other LDAP users on what LDAP databases they are using and to check it with those.
Andi
At 10:25 PM 8/25/00 +0200, Stig Venaas wrote:
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--- Andi Gutmans <andi@zend.com> http://www.zend.com//* 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)));#elsephp_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 > 2000int lderr;/* New versions of OpenLDAP do it this way */ ldap_get_option(ldap, LDAP_OPT_ERROR_NUMBER, &lderr); return lderr;#elsereturn ldap->ld_errno;#endif #elsereturn ldap_get_lderrno(ldap,NULL,NULL);#endif } and then I've replaced code like: #if !HAVE_NSLDAP #if LDAP_API_VERSION > 2000php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL)));#elsephp_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(ldap->ld_errno));#endif #elsephp_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL)));#endif withphp_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 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net