diff options
author | George Wang <gwang@php.net> | 2014-10-03 16:43:08 -0400 |
---|---|---|
committer | George Wang <gwang@php.net> | 2014-10-03 16:43:08 -0400 |
commit | ef0eed7f5ff34236b39d9c5914e1627ef30c7cb7 (patch) | |
tree | aa1b356321816109d462cacbb0c7986e3abe3153 /ext/ldap/ldap.c | |
parent | 0cc2600ec64d882df7f44390bfd5411750f86947 (diff) | |
parent | d67c05bb899f4db42dd568376112b9144de2b5f1 (diff) | |
download | php-git-ef0eed7f5ff34236b39d9c5914e1627ef30c7cb7.tar.gz |
Merge branch 'PHP-5.5' of git.php.net:php-src into PHP-5.5
Diffstat (limited to 'ext/ldap/ldap.c')
-rw-r--r-- | ext/ldap/ldap.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index da5aa5f9cd..6de334df54 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -385,6 +385,23 @@ static int _get_lderrno(LDAP *ldap) } /* }}} */ +/* {{{ _set_lderrno + */ +static void _set_lderrno(LDAP *ldap, int lderr) +{ +#if !HAVE_NSLDAP +#if LDAP_API_VERSION > 2000 || HAVE_ORALDAP + /* New versions of OpenLDAP do it this way */ + ldap_set_option(ldap, LDAP_OPT_ERROR_NUMBER, &lderr); +#else + ldap->ld_errno = lderr; +#endif +#else + ldap_set_lderrno(ldap, lderr, NULL, NULL); +#endif +} +/* }}} */ + /* {{{ proto bool ldap_bind(resource link [, string dn [, string password]]) Bind to LDAP directory */ PHP_FUNCTION(ldap_bind) @@ -399,18 +416,20 @@ PHP_FUNCTION(ldap_bind) RETURN_FALSE; } + ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link); + if (ldap_bind_dn != NULL && memchr(ldap_bind_dn, '\0', ldap_bind_dnlen) != NULL) { + _set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS); php_error_docref(NULL TSRMLS_CC, E_WARNING, "DN contains a null byte"); RETURN_FALSE; } if (ldap_bind_pw != NULL && memchr(ldap_bind_pw, '\0', ldap_bind_pwlen) != NULL) { + _set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Password contains a null byte"); RETURN_FALSE; } - ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link); - if ((rc = ldap_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw, LDAP_AUTH_SIMPLE)) != LDAP_SUCCESS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc)); RETURN_FALSE; |