Re: cvs: php4 /ext/ldap ldap.c
| From: | derick@php.net | Date: | Wed, 26 Jun 2002 10:07:11 +0000 |
| Subject: | Re: cvs: php4 /ext/ldap ldap.c | ||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-12545@lists.php.net to get a copy of this message | ||
On Wed, 26 Jun 2002, Stig Venaas wrote:
> Thanks for doing this. I've spotted at least one problem though.
>
> On Wed, Jun 26, 2002 at 06:49:25AM -0000, Derick Rethans wrote:
> > - if (ldap_bind_s(ld->link, ldap_bind_rdn, ldap_bind_pw, LDAP_AUTH_SIMPLE) !=
> > LDAP_SUCCESS) {
> > - php_error(E_WARNING, "LDAP: Unable to bind to server: %s",
> > ldap_err2string(_get_lderrno(ld->link)));
> > + if ((rc = ldap_bind_s(ld->link, ldap_bind_rdn, ldap_bind_pw, LDAP_AUTH_SIMPLE)) !=
> > LDAP_SUCCESS) {
> > + php_error(E_WARNING, "%s(): Unable to bind to server: %s",
> > get_active_function_name(TSRMLS_C), ldap_err2string(rc));
> > RETURN_FALSE;
> > } else {
> > RETURN_TRUE;
>
> This doesn't work. ldap_bind_s() returns -1 on error, not the error code.
> So you need to use _get_lderrno() to get the error code. The LDAP API
> isn't consistent in this respect. If you have done the same other places,
> please check the spec first. I suggest you look at
> draft-ietf-ldapext-ldap-c-api-05.txt. Look for it in the OpenLDAP 2.x
> tarball (or you could get it from ftp.venaas.no/pub/internet-drafts)
> or some other places.
The RFC says this:
ldap_err2string() is used to convert a numeric LDAP error code, as
returned by ldap_result2error() or one of the synchronous API operation
calls, into an informative NULL-terminated character string message
describing the error. It returns a pointer to static data.
And if I interpret it correctly, the new code should be ok (for the
ldap_bind_s case). I'm checking the rest now.
Derick
---------------------------------------------------------------------------
Did I help you? http://www.derickrethans.nl/link.php?url=giftlist
Frequent ranting: http://www.derickrethans.nl/
---------------------------------------------------------------------------
PHP: Scripting the Web - derick@php.net
All your branches are belong to me!
SRM: Script Running Machine - www.vl-srm.net
---------------------------------------------------------------------------