| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
| Gerrit Thomson <334647@swin.edu.au> |
| Jani Taskinen <sniper@iki.fi> |
+ | Stig Venaas <venaas@uninett.no> |
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
}
+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
+}
+
+
#if 0
PHP_FUNCTION(ber_free)
{
if (ldap_bind_s(ldap, ldap_bind_rdn, ldap_bind_pw, LDAP_AUTH_SIMPLE) != LDAP_SUCCESS) {
#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
+ php_error(E_WARNING,"LDAP: Unable to bind to server: %s",ldap_err2string(_get_lderrno(ldap)));
#endif
RETURN_FALSE;
} else {
if (errno != LDAP_SUCCESS && errno != LDAP_SIZELIMIT_EXCEEDED) {
#if !HAVE_NSLDAP
-#if LDAP_API_VERSION > 2000
- php_error(E_WARNING,"LDAP: Unable to perform the search: %s",ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL)));
-#else
- php_error(E_WARNING, "LDAP: Unable to perform the search: %s", ldap_err2string(ldap->ld_errno));
-#endif
+ php_error(E_WARNING,"LDAP: Unable to perform the search: %s",ldap_err2string(_get_lderrno(ldap)));
#endif
RETVAL_FALSE;
} else {
if ((ldap_value = ldap_get_values(ldap, ldap_result_entry, attribute)) == NULL) {
#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
+ php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(_get_lderrno(ldap)));
#endif
RETURN_FALSE;
}
attribute = (*attr)->value.str.val;
if ((ldap_value_len = ldap_get_values_len(ldap, ldap_result_entry, attribute)) == NULL) {
-#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
+ php_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s", ldap_err2string(_get_lderrno(ldap)));
RETURN_FALSE;
}
RETURN_LONG(0);
}
-#if !HAVE_NSLDAP
-#if LDAP_API_VERSION > 2000
- RETURN_LONG( ldap_get_lderrno(ldap, NULL, NULL) );
-#else
- RETURN_LONG( ldap->ld_errno );
-#endif
-#else
- RETURN_LONG( ldap_get_lderrno(ldap, NULL, NULL) );
-#endif
+ RETURN_LONG( _get_lderrno(ldap) );
}
/* }}} */
RETURN_FALSE;
}
-#if !HAVE_NSLDAP
-#if LDAP_API_VERSION > 2000
- ld_errno = ldap_get_lderrno(ldap, NULL, NULL);
-#else
- ld_errno = ldap->ld_errno;
-#endif
-#else
- ld_errno = ldap_get_lderrno(ldap, NULL, NULL);
-#endif
+ ld_errno = _get_lderrno(ldap);
RETURN_STRING(ldap_err2string(ld_errno), 1);
}