mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Patch from Rainer Jung to provide Solaris LDAP support
This commit is contained in:
parent
3ed58fb5d7
commit
40befb943c
@ -70,17 +70,24 @@
|
|||||||
#define PHP_LDAP_ESCAPE_FILTER 0x01
|
#define PHP_LDAP_ESCAPE_FILTER 0x01
|
||||||
#define PHP_LDAP_ESCAPE_DN 0x02
|
#define PHP_LDAP_ESCAPE_DN 0x02
|
||||||
|
|
||||||
#ifndef HAVE_LDAP_CONTROL_FIND
|
#if defined(LDAP_CONTROL_PAGEDRESULTS) && !defined(HAVE_LDAP_CONTROL_FIND)
|
||||||
LDAPControl *ldap_control_find( const char *oid, LDAPControl **ctrls, LDAPControl ***nextctrlp)
|
LDAPControl *ldap_control_find( const char *oid, LDAPControl **ctrls, LDAPControl ***nextctrlp)
|
||||||
{
|
{
|
||||||
assert(nextctrlp == NULL);
|
assert(nextctrlp == NULL);
|
||||||
return ldap_find_control(oid, ctrls);
|
return ldap_find_control(oid, ctrls);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(LDAP_API_FEATURE_X_OPENLDAP)
|
||||||
|
void ldap_memvfree(void **v)
|
||||||
|
{
|
||||||
|
ldap_value_free((char **)v);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
LDAP *link;
|
LDAP *link;
|
||||||
#if defined(HAVE_3ARG_SETREBINDPROC)
|
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
|
||||||
zval *rebindproc;
|
zval *rebindproc;
|
||||||
#endif
|
#endif
|
||||||
} ldap_linkdata;
|
} ldap_linkdata;
|
||||||
@ -104,10 +111,8 @@ static void _close_ldap_link(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
|
|||||||
{
|
{
|
||||||
ldap_linkdata *ld = (ldap_linkdata *)rsrc->ptr;
|
ldap_linkdata *ld = (ldap_linkdata *)rsrc->ptr;
|
||||||
|
|
||||||
/* ldap_unbind_s() is deprecated;
|
|
||||||
* the distinction between ldap_unbind() and ldap_unbind_s() is moot */
|
|
||||||
ldap_unbind_ext(ld->link, NULL, NULL);
|
ldap_unbind_ext(ld->link, NULL, NULL);
|
||||||
#ifdef HAVE_3ARG_SETREBINDPROC
|
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
|
||||||
|
|
||||||
if (ld->rebindproc != NULL) {
|
if (ld->rebindproc != NULL) {
|
||||||
zval_dtor(ld->rebindproc);
|
zval_dtor(ld->rebindproc);
|
||||||
@ -349,11 +354,8 @@ PHP_FUNCTION(ldap_connect)
|
|||||||
|
|
||||||
ld = ecalloc(1, sizeof(ldap_linkdata));
|
ld = ecalloc(1, sizeof(ldap_linkdata));
|
||||||
|
|
||||||
/* OpenLDAP provides a specific call to detect valid LDAP URIs;
|
|
||||||
* ldap_init()/ldap_open() is deprecated, use ldap_initialize() instead.
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
int rc;
|
int rc = LDAP_SUCCESS;
|
||||||
char *url = host;
|
char *url = host;
|
||||||
if (!ldap_is_ldap_url(url)) {
|
if (!ldap_is_ldap_url(url)) {
|
||||||
int urllen = hostlen + sizeof( "ldap://:65535" );
|
int urllen = hostlen + sizeof( "ldap://:65535" );
|
||||||
@ -367,7 +369,21 @@ PHP_FUNCTION(ldap_connect)
|
|||||||
snprintf( url, urllen, "ldap://%s:%ld", host ? host : "", port );
|
snprintf( url, urllen, "ldap://%s:%ld", host ? host : "", port );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LDAP_API_FEATURE_X_OPENLDAP
|
||||||
|
/* ldap_init() is deprecated, use ldap_initialize() instead.
|
||||||
|
*/
|
||||||
rc = ldap_initialize(&ldap, url);
|
rc = ldap_initialize(&ldap, url);
|
||||||
|
#else /* ! LDAP_API_FEATURE_X_OPENLDAP */
|
||||||
|
/* ldap_init does not support URLs.
|
||||||
|
* We must try the original host and port information.
|
||||||
|
*/
|
||||||
|
ldap = ldap_init(host, port);
|
||||||
|
if (ldap == NULL) {
|
||||||
|
efree(ld);
|
||||||
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create session handle");
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
#endif /* ! LDAP_API_FEATURE_X_OPENLDAP */
|
||||||
if (url != host) {
|
if (url != host) {
|
||||||
efree(url);
|
efree(url);
|
||||||
}
|
}
|
||||||
@ -465,14 +481,19 @@ PHP_FUNCTION(ldap_bind)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#ifdef LDAP_API_FEATURE_X_OPENLDAP
|
||||||
|
/* ldap_simple_bind_s() is deprecated, use ldap_sasl_bind_s() instead.
|
||||||
|
*/
|
||||||
struct berval cred;
|
struct berval cred;
|
||||||
|
|
||||||
/* ldap_bind_s() is deprecated; use ldap_sasl_bind_s() instead */
|
|
||||||
cred.bv_val = ldap_bind_pw;
|
cred.bv_val = ldap_bind_pw;
|
||||||
cred.bv_len = ldap_bind_pw ? ldap_bind_pwlen : 0;
|
cred.bv_len = ldap_bind_pw ? ldap_bind_pwlen : 0;
|
||||||
rc = ldap_sasl_bind_s(ld->link, ldap_bind_dn, LDAP_SASL_SIMPLE, &cred,
|
rc = ldap_sasl_bind_s(ld->link, ldap_bind_dn, LDAP_SASL_SIMPLE, &cred,
|
||||||
NULL, NULL, /* no controls right now */
|
NULL, NULL, /* no controls right now */
|
||||||
NULL); /* we don't care about the server's credentials */
|
NULL); /* we don't care about the server's credentials */
|
||||||
|
#else /* ! LDAP_API_FEATURE_X_OPENLDAP */
|
||||||
|
rc = ldap_simple_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw);
|
||||||
|
#endif /* ! LDAP_API_FEATURE_X_OPENLDAP */
|
||||||
}
|
}
|
||||||
if ( rc != LDAP_SUCCESS) {
|
if ( rc != LDAP_SUCCESS) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc));
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc));
|
||||||
@ -1304,7 +1325,6 @@ PHP_FUNCTION(ldap_explode_dn)
|
|||||||
add_index_string(return_value, i, ldap_value[i], 1);
|
add_index_string(return_value, i, ldap_value[i], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ldap_value_free() is deprecated */
|
|
||||||
ldap_memvfree((void **)ldap_value);
|
ldap_memvfree((void **)ldap_value);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
@ -2485,7 +2505,7 @@ PHP_FUNCTION(ldap_start_tls)
|
|||||||
#endif
|
#endif
|
||||||
#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP */
|
#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP */
|
||||||
|
|
||||||
#if defined(HAVE_3ARG_SETREBINDPROC)
|
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
|
||||||
/* {{{ _ldap_rebind_proc()
|
/* {{{ _ldap_rebind_proc()
|
||||||
*/
|
*/
|
||||||
int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgid, void *params)
|
int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgid, void *params)
|
||||||
@ -3138,7 +3158,7 @@ ZEND_END_ARG_INFO()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_3ARG_SETREBINDPROC)
|
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_set_rebind_proc, 0, 0, 2)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_set_rebind_proc, 0, 0, 2)
|
||||||
ZEND_ARG_INFO(0, link)
|
ZEND_ARG_INFO(0, link)
|
||||||
ZEND_ARG_INFO(0, callback)
|
ZEND_ARG_INFO(0, callback)
|
||||||
@ -3226,7 +3246,7 @@ const zend_function_entry ldap_functions[] = {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_3ARG_SETREBINDPROC)
|
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
|
||||||
PHP_FE(ldap_set_rebind_proc, arginfo_ldap_set_rebind_proc)
|
PHP_FE(ldap_set_rebind_proc, arginfo_ldap_set_rebind_proc)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user