Browse Source

ws & cs

migration/unlabaled-1.3.2
foobar 23 years ago
parent
commit
c15b8fb19e
  1. 262
      ext/ldap/ldap.c

262
ext/ldap/ldap.c

@ -121,7 +121,7 @@ function_entry ldap_functions[] = {
PHP_FE(ldap_compare, NULL) PHP_FE(ldap_compare, NULL)
PHP_FE(ldap_sort, NULL) PHP_FE(ldap_sort, NULL)
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
PHP_FE(ldap_get_option, third_argument_force_ref) PHP_FE(ldap_get_option, third_argument_force_ref)
PHP_FE(ldap_set_option, NULL) PHP_FE(ldap_set_option, NULL)
PHP_FE(ldap_parse_result, arg3to6of6_force_ref) PHP_FE(ldap_parse_result, arg3to6of6_force_ref)
@ -158,16 +158,14 @@ zend_module_entry ldap_module_entry = {
NULL, NULL,
NULL, NULL,
PHP_MINFO(ldap), PHP_MINFO(ldap),
NO_VERSION_YET,
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES STANDARD_MODULE_PROPERTIES
}; };
#ifdef COMPILE_DL_LDAP #ifdef COMPILE_DL_LDAP
ZEND_GET_MODULE(ldap) ZEND_GET_MODULE(ldap)
#endif #endif
static void _close_ldap_link(zend_rsrc_list_entry *rsrc TSRMLS_DC) 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;
@ -183,7 +181,6 @@ static void _close_ldap_link(zend_rsrc_list_entry *rsrc TSRMLS_DC)
LDAPG(num_links)--; LDAPG(num_links)--;
} }
static void _free_ldap_result(zend_rsrc_list_entry *rsrc TSRMLS_DC) static void _free_ldap_result(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{ {
LDAPMessage *result = (LDAPMessage *)rsrc->ptr; LDAPMessage *result = (LDAPMessage *)rsrc->ptr;
@ -200,7 +197,7 @@ static void _free_ldap_result_entry(zend_rsrc_list_entry *rsrc TSRMLS_DC)
/* {{{ PHP_INI_BEGIN /* {{{ PHP_INI_BEGIN
*/ */
PHP_INI_BEGIN() PHP_INI_BEGIN()
STD_PHP_INI_ENTRY_EX("ldap.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_ldap_globals, ldap_globals, display_link_numbers)
STD_PHP_INI_ENTRY_EX("ldap.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_ldap_globals, ldap_globals, display_link_numbers)
PHP_INI_END() PHP_INI_END()
/* }}} */ /* }}} */
@ -226,7 +223,7 @@ PHP_MINIT_FUNCTION(ldap)
REGISTER_LONG_CONSTANT("LDAP_DEREF_FINDING", LDAP_DEREF_FINDING, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("LDAP_DEREF_FINDING", LDAP_DEREF_FINDING, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_DEREF_ALWAYS", LDAP_DEREF_ALWAYS, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("LDAP_DEREF_ALWAYS", LDAP_DEREF_ALWAYS, CONST_PERSISTENT | CONST_CS);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
/* LDAP options */ /* LDAP options */
REGISTER_LONG_CONSTANT("LDAP_OPT_DEREF", LDAP_OPT_DEREF, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("LDAP_OPT_DEREF", LDAP_OPT_DEREF, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_OPT_SIZELIMIT", LDAP_OPT_SIZELIMIT, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("LDAP_OPT_SIZELIMIT", LDAP_OPT_SIZELIMIT, CONST_PERSISTENT | CONST_CS);
@ -285,8 +282,8 @@ PHP_MINFO_FUNCTION(ldap)
#endif #endif
php_info_print_table_start(); php_info_print_table_start();
php_info_print_table_row(2, "LDAP Support", "enabled" );
php_info_print_table_row(2, "RCS Version", "$Id$" );
php_info_print_table_row(2, "LDAP Support", "enabled");
php_info_print_table_row(2, "RCS Version", "$Id$");
if (LDAPG(max_links) == -1) { if (LDAPG(max_links) == -1) {
snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links)); snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links));
@ -313,26 +310,26 @@ PHP_MINFO_FUNCTION(ldap)
#endif #endif
#if HAVE_NSLDAP #if HAVE_NSLDAP
SDKVersion = ldap_version( &ver );
snprintf(tmp, 31, "%f", SDKVersion/100.0 );
SDKVersion = ldap_version(&ver);
snprintf(tmp, 31, "%f", SDKVersion/100.0);
tmp[31] = '\0'; tmp[31] = '\0';
php_info_print_table_row(2, "SDK Version", tmp );
php_info_print_table_row(2, "SDK Version", tmp);
snprintf(tmp, 31, "%f", ver.protocol_version/100.0 );
snprintf(tmp, 31, "%f", ver.protocol_version/100.0);
tmp[31] = '\0'; tmp[31] = '\0';
php_info_print_table_row(2, "Highest LDAP Protocol Supported", tmp );
php_info_print_table_row(2, "Highest LDAP Protocol Supported", tmp);
snprintf(tmp, 31, "%f", ver.SSL_version/100.0 );
snprintf(tmp, 31, "%f", ver.SSL_version/100.0);
tmp[31] = '\0'; tmp[31] = '\0';
php_info_print_table_row(2, "SSL Level Supported", tmp );
php_info_print_table_row(2, "SSL Level Supported", tmp);
if ( ver.security_level != LDAP_SECURITY_NONE ) {
snprintf(tmp, 31, "%d", ver.security_level );
if (ver.security_level != LDAP_SECURITY_NONE) {
snprintf(tmp, 31, "%d", ver.security_level);
tmp[31] = '\0'; tmp[31] = '\0';
} else { } else {
strcpy(tmp, "SSL not enabled" );
strcpy(tmp, "SSL not enabled");
} }
php_info_print_table_row(2, "Level of Encryption", tmp );
php_info_print_table_row(2, "Level of Encryption", tmp);
#endif #endif
php_info_print_table_end(); php_info_print_table_end();
@ -364,7 +361,7 @@ PHP_FUNCTION(ldap_connect)
RETURN_FALSE; RETURN_FALSE;
} }
if (ZEND_NUM_ARGS() == 5 ) {
if (ZEND_NUM_ARGS() == 5) {
ssl = 1; ssl = 1;
} }
#else #else
@ -400,7 +397,7 @@ PHP_FUNCTION(ldap_connect)
ldap = ldap_open(host, port); ldap = ldap_open(host, port);
#endif #endif
if ( ldap == NULL ) {
if (ldap == NULL) {
efree(ld); efree(ld);
RETURN_FALSE; RETURN_FALSE;
} else { } else {
@ -490,7 +487,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
{ {
/* sizelimit */ /* sizelimit */
if (sizelimit > -1) { if (sizelimit > -1) {
#if ( LDAP_API_VERSION >= 2004 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
ldap_set_option(ldap, LDAP_OPT_SIZELIMIT, &sizelimit); ldap_set_option(ldap, LDAP_OPT_SIZELIMIT, &sizelimit);
#else #else
ldap->ld_sizelimit = sizelimit; ldap->ld_sizelimit = sizelimit;
@ -499,7 +496,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
/* timelimit */ /* timelimit */
if (timelimit > -1) { if (timelimit > -1) {
#if ( LDAP_API_VERSION >= 2004 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
ldap_set_option(ldap, LDAP_OPT_TIMELIMIT, &timelimit); ldap_set_option(ldap, LDAP_OPT_TIMELIMIT, &timelimit);
#else #else
ldap->ld_timelimit = timelimit; ldap->ld_timelimit = timelimit;
@ -508,7 +505,7 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
/* deref */ /* deref */
if (deref > -1) { if (deref > -1) {
#if ( LDAP_API_VERSION >= 2004 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION >= 2004) || HAVE_NSLDAP
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref); ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
#else #else
ldap->ld_deref = deref; ldap->ld_deref = deref;
@ -521,26 +518,26 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref)
*/ */
static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
{ {
pval **link, **base_dn, **filter, **attrs, **attr, **attrsonly, **sizelimit, **timelimit, **deref;
zval **link, **base_dn, **filter, **attrs, **attr, **attrsonly, **sizelimit, **timelimit, **deref;
char *ldap_base_dn = NULL; char *ldap_base_dn = NULL;
char *ldap_filter = NULL; char *ldap_filter = NULL;
char **ldap_attrs = NULL; char **ldap_attrs = NULL;
ldap_linkdata *ld; ldap_linkdata *ld;
LDAPMessage *ldap_res; LDAPMessage *ldap_res;
int ldap_attrsonly = 0;
int ldap_attrsonly = 0;
int ldap_sizelimit = -1; int ldap_sizelimit = -1;
int ldap_timelimit = -1; int ldap_timelimit = -1;
int ldap_deref = -1; int ldap_deref = -1;
int num_attribs = 0; int num_attribs = 0;
int i, errno; int i, errno;
int myargcount = ZEND_NUM_ARGS(); int myargcount = ZEND_NUM_ARGS();
if (myargcount < 3 || myargcount > 8 || zend_get_parameters_ex(myargcount, &link, &base_dn, &filter, &attrs, &attrsonly, &sizelimit, &timelimit, &deref) == FAILURE) { if (myargcount < 3 || myargcount > 8 || zend_get_parameters_ex(myargcount, &link, &base_dn, &filter, &attrs, &attrsonly, &sizelimit, &timelimit, &deref) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
} }
/* Reverse -> fall through */ /* Reverse -> fall through */
switch(myargcount) {
switch (myargcount) {
case 8 : case 8 :
convert_to_long_ex(deref); convert_to_long_ex(deref);
ldap_deref = Z_LVAL_PP(deref); ldap_deref = Z_LVAL_PP(deref);
@ -569,8 +566,8 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
RETURN_FALSE; RETURN_FALSE;
} }
for(i=0; i<num_attribs; i++) {
if(zend_hash_index_find(Z_ARRVAL_PP(attrs), i, (void **) &attr) == FAILURE) {
for (i = 0; i<num_attribs; i++) {
if (zend_hash_index_find(Z_ARRVAL_PP(attrs), i, (void **) &attr) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array initialization wrong"); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array initialization wrong");
efree(ldap_attrs); efree(ldap_attrs);
RETURN_FALSE; RETURN_FALSE;
@ -706,8 +703,8 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
} }
/* fix to make null base_dn's work */ /* fix to make null base_dn's work */
if ( strlen(ldap_base_dn) < 1 ) {
ldap_base_dn = NULL;
if (strlen(ldap_base_dn) < 1) {
ldap_base_dn = NULL;
} }
ld = (ldap_linkdata *) zend_fetch_resource(link TSRMLS_CC, -1, "ldap link", NULL, 1, le_link); ld = (ldap_linkdata *) zend_fetch_resource(link TSRMLS_CC, -1, "ldap link", NULL, 1, le_link);
@ -728,18 +725,18 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
} }
if (errno != LDAP_SUCCESS if (errno != LDAP_SUCCESS
&& errno != LDAP_SIZELIMIT_EXCEEDED
&& errno != LDAP_SIZELIMIT_EXCEEDED
#ifdef LDAP_ADMINLIMIT_EXCEEDED #ifdef LDAP_ADMINLIMIT_EXCEEDED
&& errno != LDAP_ADMINLIMIT_EXCEEDED
&& errno != LDAP_ADMINLIMIT_EXCEEDED
#endif #endif
#ifdef LDAP_REFERRAL #ifdef LDAP_REFERRAL
&& errno != LDAP_REFERRAL
&& errno != LDAP_REFERRAL
#endif #endif
) {
) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Search: %s", ldap_err2string(errno)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Search: %s", ldap_err2string(errno));
RETVAL_FALSE; RETVAL_FALSE;
} else { } else {
if (errno == LDAP_SIZELIMIT_EXCEEDED) {
if (errno == LDAP_SIZELIMIT_EXCEEDED) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Partial search results returned: Sizelimit exceeded."); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Partial search results returned: Sizelimit exceeded.");
} }
#ifdef LDAP_ADMINLIMIT_EXCEEDED #ifdef LDAP_ADMINLIMIT_EXCEEDED
@ -781,7 +778,7 @@ PHP_FUNCTION(ldap_search)
Free result memory */ Free result memory */
PHP_FUNCTION(ldap_free_result) PHP_FUNCTION(ldap_free_result)
{ {
pval **result;
zval **result;
LDAPMessage *ldap_result; LDAPMessage *ldap_result;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &result) == FAILURE) { if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &result) == FAILURE) {
@ -799,7 +796,7 @@ PHP_FUNCTION(ldap_free_result)
Count the number of entries in a search result */ Count the number of entries in a search result */
PHP_FUNCTION(ldap_count_entries) PHP_FUNCTION(ldap_count_entries)
{ {
pval **link, **result;
zval **link, **result;
ldap_linkdata *ld; ldap_linkdata *ld;
LDAPMessage *ldap_result; LDAPMessage *ldap_result;
@ -818,7 +815,7 @@ PHP_FUNCTION(ldap_count_entries)
Return first result id */ Return first result id */
PHP_FUNCTION(ldap_first_entry) PHP_FUNCTION(ldap_first_entry)
{ {
pval **link, **result;
zval **link, **result;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
LDAPMessage *ldap_result, *entry; LDAPMessage *ldap_result, *entry;
@ -846,7 +843,7 @@ PHP_FUNCTION(ldap_first_entry)
Get next result entry */ Get next result entry */
PHP_FUNCTION(ldap_next_entry) PHP_FUNCTION(ldap_next_entry)
{ {
pval **link, **result_entry;
zval **link, **result_entry;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry, *resultentry_next; ldap_resultentry *resultentry, *resultentry_next;
LDAPMessage *entry_next; LDAPMessage *entry_next;
@ -874,9 +871,9 @@ PHP_FUNCTION(ldap_next_entry)
Get all result entries */ Get all result entries */
PHP_FUNCTION(ldap_get_entries) PHP_FUNCTION(ldap_get_entries)
{ {
pval **link, **result;
zval **link, **result;
LDAPMessage *ldap_result, *ldap_result_entry; LDAPMessage *ldap_result, *ldap_result_entry;
pval *tmp1, *tmp2;
zval *tmp1, *tmp2;
ldap_linkdata *ld; ldap_linkdata *ld;
LDAP *ldap; LDAP *ldap;
int num_entries, num_attrib, num_values, i; int num_entries, num_attrib, num_values, i;
@ -905,7 +902,7 @@ PHP_FUNCTION(ldap_get_entries)
ldap_result_entry = ldap_first_entry(ldap, ldap_result); ldap_result_entry = ldap_first_entry(ldap, ldap_result);
if (ldap_result_entry == NULL) RETURN_FALSE; if (ldap_result_entry == NULL) RETURN_FALSE;
while(ldap_result_entry != NULL) {
while (ldap_result_entry != NULL) {
MAKE_STD_ZVAL(tmp1); MAKE_STD_ZVAL(tmp1);
array_init(tmp1); array_init(tmp1);
@ -920,22 +917,22 @@ PHP_FUNCTION(ldap_get_entries)
MAKE_STD_ZVAL(tmp2); MAKE_STD_ZVAL(tmp2);
array_init(tmp2); array_init(tmp2);
add_assoc_long(tmp2, "count", num_values); add_assoc_long(tmp2, "count", num_values);
for(i=0; i < num_values; i++) {
for (i = 0; i < num_values; i++) {
add_index_string(tmp2, i, ldap_value[i], 1); add_index_string(tmp2, i, ldap_value[i], 1);
} }
ldap_value_free(ldap_value); ldap_value_free(ldap_value);
attr_len = strlen(attribute); attr_len = strlen(attribute);
zend_hash_update(Z_ARRVAL_P(tmp1), php_strtolower(attribute, attr_len), attr_len+1, (void *) &tmp2, sizeof(pval *), NULL);
zend_hash_update(Z_ARRVAL_P(tmp1), php_strtolower(attribute, attr_len), attr_len+1, (void *) &tmp2, sizeof(zval *), NULL);
add_index_string(tmp1, num_attrib, attribute, 1); add_index_string(tmp1, num_attrib, attribute, 1);
num_attrib++; num_attrib++;
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
ldap_memfree(attribute); ldap_memfree(attribute);
#endif #endif
attribute = ldap_next_attribute(ldap, ldap_result_entry, ber); attribute = ldap_next_attribute(ldap, ldap_result_entry, ber);
} }
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
if (ber != NULL) if (ber != NULL)
ber_free(ber, 0); ber_free(ber, 0);
#endif #endif
@ -943,13 +940,13 @@ PHP_FUNCTION(ldap_get_entries)
add_assoc_long(tmp1, "count", num_attrib); add_assoc_long(tmp1, "count", num_attrib);
dn = ldap_get_dn(ldap, ldap_result_entry); dn = ldap_get_dn(ldap, ldap_result_entry);
add_assoc_string(tmp1, "dn", dn, 1); add_assoc_string(tmp1, "dn", dn, 1);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
ldap_memfree(dn); ldap_memfree(dn);
#else #else
free(dn); free(dn);
#endif #endif
zend_hash_index_update(Z_ARRVAL_P(return_value), num_entries, (void *) &tmp1, sizeof(pval *), NULL);
zend_hash_index_update(Z_ARRVAL_P(return_value), num_entries, (void *) &tmp1, sizeof(zval *), NULL);
num_entries++; num_entries++;
ldap_result_entry = ldap_next_entry(ldap, ldap_result_entry); ldap_result_entry = ldap_next_entry(ldap, ldap_result_entry);
@ -964,7 +961,7 @@ PHP_FUNCTION(ldap_get_entries)
Return first attribute */ Return first attribute */
PHP_FUNCTION(ldap_first_attribute) PHP_FUNCTION(ldap_first_attribute)
{ {
pval **link, **result_entry, **berp;
zval **link, **result_entry, **berp;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
BerElement *ber; BerElement *ber;
@ -983,7 +980,7 @@ PHP_FUNCTION(ldap_first_attribute)
ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry); ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry);
RETVAL_STRING(attribute, 1); RETVAL_STRING(attribute, 1);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
ldap_memfree(attribute); ldap_memfree(attribute);
#endif #endif
} }
@ -994,13 +991,13 @@ PHP_FUNCTION(ldap_first_attribute)
Get the next attribute in result */ Get the next attribute in result */
PHP_FUNCTION(ldap_next_attribute) PHP_FUNCTION(ldap_next_attribute)
{ {
pval **link, **result_entry, **berp;
zval **link, **result_entry, **berp;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
BerElement *ber; BerElement *ber;
char *attribute; char *attribute;
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &link, &result_entry, &berp) == FAILURE ) {
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &link, &result_entry, &berp) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
} }
@ -1014,7 +1011,7 @@ PHP_FUNCTION(ldap_next_attribute)
ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry); ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry);
RETVAL_STRING(attribute, 1); RETVAL_STRING(attribute, 1);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
ldap_memfree(attribute); ldap_memfree(attribute);
#endif #endif
} }
@ -1025,8 +1022,8 @@ PHP_FUNCTION(ldap_next_attribute)
Get attributes from a search result entry */ Get attributes from a search result entry */
PHP_FUNCTION(ldap_get_attributes) PHP_FUNCTION(ldap_get_attributes)
{ {
pval **link, **result_entry;
pval *tmp;
zval **link, **result_entry;
zval *tmp;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
char *attribute; char *attribute;
@ -1052,23 +1049,24 @@ PHP_FUNCTION(ldap_get_attributes)
MAKE_STD_ZVAL(tmp); MAKE_STD_ZVAL(tmp);
array_init(tmp); array_init(tmp);
add_assoc_long(tmp, "count", num_values); add_assoc_long(tmp, "count", num_values);
for(i=0; i<num_values; i++) {
for (i = 0; i < num_values; i++) {
add_index_string(tmp, i, ldap_value[i], 1); add_index_string(tmp, i, ldap_value[i], 1);
} }
ldap_value_free(ldap_value); ldap_value_free(ldap_value);
zend_hash_update(Z_ARRVAL_P(return_value), attribute, strlen(attribute)+1, (void *) &tmp, sizeof(pval *), NULL);
zend_hash_update(Z_ARRVAL_P(return_value), attribute, strlen(attribute)+1, (void *) &tmp, sizeof(zval *), NULL);
add_index_string(return_value, num_attrib, attribute, 1); add_index_string(return_value, num_attrib, attribute, 1);
num_attrib++; num_attrib++;
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
ldap_memfree(attribute); ldap_memfree(attribute);
#endif #endif
attribute = ldap_next_attribute(ld->link, resultentry->data, ber); attribute = ldap_next_attribute(ld->link, resultentry->data, ber);
} }
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
if (ber != NULL)
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
if (ber != NULL) {
ber_free(ber, 0); ber_free(ber, 0);
}
#endif #endif
add_assoc_long(return_value, "count", num_attrib); add_assoc_long(return_value, "count", num_attrib);
@ -1079,7 +1077,7 @@ PHP_FUNCTION(ldap_get_attributes)
Get all values from a result entry */ Get all values from a result entry */
PHP_FUNCTION(ldap_get_values) PHP_FUNCTION(ldap_get_values)
{ {
pval **link, **result_entry, **attr;
zval **link, **result_entry, **attr;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
char *attribute; char *attribute;
@ -1105,7 +1103,7 @@ PHP_FUNCTION(ldap_get_values)
array_init(return_value); array_init(return_value);
for(i=0; i<num_values; i++) {
for (i = 0; i<num_values; i++) {
add_next_index_string(return_value, ldap_value[i], 1); add_next_index_string(return_value, ldap_value[i], 1);
} }
@ -1119,7 +1117,7 @@ PHP_FUNCTION(ldap_get_values)
Get all values with lengths from a result entry */ Get all values with lengths from a result entry */
PHP_FUNCTION(ldap_get_values_len) PHP_FUNCTION(ldap_get_values_len)
{ {
pval **link, **result_entry, **attr;
zval **link, **result_entry, **attr;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
char* attribute; char* attribute;
@ -1158,7 +1156,7 @@ PHP_FUNCTION(ldap_get_values_len)
Get the DN of a result entry */ Get the DN of a result entry */
PHP_FUNCTION(ldap_get_dn) PHP_FUNCTION(ldap_get_dn)
{ {
pval **link, **result_entry;
zval **link, **result_entry;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
char *text; char *text;
@ -1171,9 +1169,9 @@ PHP_FUNCTION(ldap_get_dn)
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry); ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
text = ldap_get_dn(ld->link, resultentry->data); text = ldap_get_dn(ld->link, resultentry->data);
if ( text != NULL ) {
if (text != NULL) {
RETVAL_STRING(text, 1); RETVAL_STRING(text, 1);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
ldap_memfree(text); ldap_memfree(text);
#else #else
free(text); free(text);
@ -1188,7 +1186,7 @@ PHP_FUNCTION(ldap_get_dn)
Splits DN into its component parts */ Splits DN into its component parts */
PHP_FUNCTION(ldap_explode_dn) PHP_FUNCTION(ldap_explode_dn)
{ {
pval **dn, **with_attrib;
zval **dn, **with_attrib;
char **ldap_value; char **ldap_value;
int i, count; int i, count;
@ -1202,13 +1200,13 @@ PHP_FUNCTION(ldap_explode_dn)
ldap_value = ldap_explode_dn(Z_STRVAL_PP(dn), Z_LVAL_PP(with_attrib)); ldap_value = ldap_explode_dn(Z_STRVAL_PP(dn), Z_LVAL_PP(with_attrib));
i=0; i=0;
while(ldap_value[i] != NULL) i++;
while (ldap_value[i] != NULL) i++;
count = i; count = i;
array_init(return_value); array_init(return_value);
add_assoc_long(return_value, "count", count); add_assoc_long(return_value, "count", count);
for(i=0; i<count; i++) {
for (i = 0; i<count; i++) {
add_index_string(return_value, i, ldap_value[i], 1); add_index_string(return_value, i, ldap_value[i], 1);
} }
@ -1220,7 +1218,7 @@ PHP_FUNCTION(ldap_explode_dn)
Convert DN to User Friendly Naming format */ Convert DN to User Friendly Naming format */
PHP_FUNCTION(ldap_dn2ufn) PHP_FUNCTION(ldap_dn2ufn)
{ {
pval **dn;
zval **dn;
char *ufn; char *ufn;
if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &dn)==FAILURE) { if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &dn)==FAILURE) {
@ -1233,7 +1231,7 @@ PHP_FUNCTION(ldap_dn2ufn)
if (ufn !=NULL) { if (ufn !=NULL) {
RETVAL_STRING(ufn, 1); RETVAL_STRING(ufn, 1);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP || WINDOWS
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || WINDOWS
ldap_memfree(ufn); ldap_memfree(ufn);
#endif #endif
} else { } else {
@ -1243,13 +1241,13 @@ PHP_FUNCTION(ldap_dn2ufn)
/* }}} */ /* }}} */
/* added to fix use of ldap_modify_add for doing an ldap_add, gerrit thomson. */
/* added to fix use of ldap_modify_add for doing an ldap_add, gerrit thomson. */
#define PHP_LD_FULL_ADD 0xff #define PHP_LD_FULL_ADD 0xff
/* {{{ php_ldap_do_modify /* {{{ php_ldap_do_modify
*/ */
static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper) static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
{ {
pval **link, **dn, **entry, **value, **ivalue;
zval **link, **dn, **entry, **value, **ivalue;
ldap_linkdata *ld; ldap_linkdata *ld;
char *ldap_dn; char *ldap_dn;
LDAPMod **ldap_mods; LDAPMod **ldap_mods;
@ -1279,13 +1277,13 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(entry)); zend_hash_internal_pointer_reset(Z_ARRVAL_PP(entry));
/* added by gerrit thomson to fix ldap_add using ldap_mod_add */ /* added by gerrit thomson to fix ldap_add using ldap_mod_add */
if ( oper == PHP_LD_FULL_ADD ) {
if (oper == PHP_LD_FULL_ADD) {
oper = LDAP_MOD_ADD; oper = LDAP_MOD_ADD;
is_full_add = 1; is_full_add = 1;
} }
/* end additional , gerrit thomson */ /* end additional , gerrit thomson */
for(i=0; i<num_attribs; i++) {
for (i = 0; i < num_attribs; i++) {
ldap_mods[i] = emalloc(sizeof(LDAPMod)); ldap_mods[i] = emalloc(sizeof(LDAPMod));
ldap_mods[i]->mod_op = oper | LDAP_MOD_BVALUES; ldap_mods[i]->mod_op = oper | LDAP_MOD_BVALUES;
@ -1320,7 +1318,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
ldap_mods[i]->mod_bvalues[0]->bv_len = Z_STRLEN_PP(value); ldap_mods[i]->mod_bvalues[0]->bv_len = Z_STRLEN_PP(value);
ldap_mods[i]->mod_bvalues[0]->bv_val = Z_STRVAL_PP(value); ldap_mods[i]->mod_bvalues[0]->bv_val = Z_STRVAL_PP(value);
} else { } else {
for(j=0; j < num_values; j++) {
for (j = 0; j < num_values; j++) {
if (zend_hash_index_find(Z_ARRVAL_PP(value), j, (void **) &ivalue) == FAILURE) { if (zend_hash_index_find(Z_ARRVAL_PP(value), j, (void **) &ivalue) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Value array must have consecutive indices 0, 1, ..."); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Value array must have consecutive indices 0, 1, ...");
num_berval[i] = j; num_berval[i] = j;
@ -1353,9 +1351,9 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
} }
errexit: errexit:
for(i=0; i < num_attribs; i++) {
for (i = 0; i < num_attribs; i++) {
efree(ldap_mods[i]->mod_type); efree(ldap_mods[i]->mod_type);
for(j=0; j<num_berval[i]; j++) {
for (j = 0; j < num_berval[i]; j++) {
efree(ldap_mods[i]->mod_bvalues[j]); efree(ldap_mods[i]->mod_bvalues[j]);
} }
efree(ldap_mods[i]->mod_bvalues); efree(ldap_mods[i]->mod_bvalues);
@ -1399,7 +1397,7 @@ PHP_FUNCTION(ldap_mod_add)
Delete attribute values */ Delete attribute values */
PHP_FUNCTION(ldap_mod_del) PHP_FUNCTION(ldap_mod_del)
{ {
php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_DELETE);
php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_DELETE);
} }
/* }}} */ /* }}} */
@ -1407,7 +1405,7 @@ PHP_FUNCTION(ldap_mod_del)
Delete an entry from a directory */ Delete an entry from a directory */
PHP_FUNCTION(ldap_delete) PHP_FUNCTION(ldap_delete)
{ {
pval **link, **dn;
zval **link, **dn;
ldap_linkdata *ld; ldap_linkdata *ld;
char *ldap_dn; char *ldap_dn;
int rc; int rc;
@ -1434,7 +1432,7 @@ PHP_FUNCTION(ldap_delete)
Get the current ldap error number */ Get the current ldap error number */
PHP_FUNCTION(ldap_errno) PHP_FUNCTION(ldap_errno)
{ {
pval **link;
zval **link;
ldap_linkdata *ld; ldap_linkdata *ld;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ht, &link) == FAILURE) { if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ht, &link) == FAILURE) {
@ -1443,7 +1441,7 @@ PHP_FUNCTION(ldap_errno)
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link); ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
RETURN_LONG( _get_lderrno(ld->link) );
RETURN_LONG(_get_lderrno(ld->link));
} }
/* }}} */ /* }}} */
@ -1453,7 +1451,7 @@ PHP_FUNCTION(ldap_err2str)
{ {
zval **perrno; zval **perrno;
if ( ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ht, &perrno) == FAILURE) {
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ht, &perrno) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
} }
@ -1466,7 +1464,7 @@ PHP_FUNCTION(ldap_err2str)
Get the current ldap error string */ Get the current ldap error string */
PHP_FUNCTION(ldap_error) PHP_FUNCTION(ldap_error)
{ {
pval **link;
zval **link;
ldap_linkdata *ld; ldap_linkdata *ld;
int ld_errno; int ld_errno;
@ -1486,7 +1484,7 @@ PHP_FUNCTION(ldap_error)
Determine if an entry has a specific value for one of its attributes */ Determine if an entry has a specific value for one of its attributes */
PHP_FUNCTION(ldap_compare) PHP_FUNCTION(ldap_compare)
{ {
pval **link, **dn, **attr, **value;
zval **link, **dn, **attr, **value;
char *ldap_dn, *ldap_attr, *ldap_value; char *ldap_dn, *ldap_attr, *ldap_value;
ldap_linkdata *ld; ldap_linkdata *ld;
int errno; int errno;
@ -1507,14 +1505,14 @@ PHP_FUNCTION(ldap_compare)
errno = ldap_compare_s(ld->link, ldap_dn, ldap_attr, ldap_value); errno = ldap_compare_s(ld->link, ldap_dn, ldap_attr, ldap_value);
switch(errno) {
case LDAP_COMPARE_TRUE :
switch (errno) {
case LDAP_COMPARE_TRUE:
RETURN_TRUE; RETURN_TRUE;
break;
break;
case LDAP_COMPARE_FALSE :
case LDAP_COMPARE_FALSE:
RETURN_FALSE; RETURN_FALSE;
break;
break;
} }
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Compare: %s", ldap_err2string(errno)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Compare: %s", ldap_err2string(errno));
@ -1554,17 +1552,16 @@ PHP_FUNCTION(ldap_sort)
/* }}} */ /* }}} */
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
/* {{{ proto bool ldap_get_option(resource link, int option, mixed retval) /* {{{ proto bool ldap_get_option(resource link, int option, mixed retval)
Get the current value of various session-wide parameters */ Get the current value of various session-wide parameters */
PHP_FUNCTION(ldap_get_option) PHP_FUNCTION(ldap_get_option)
{ {
pval **link, **option, **retval;
zval **link, **option, **retval;
ldap_linkdata *ld; ldap_linkdata *ld;
int opt; int opt;
if (ZEND_NUM_ARGS() != 3 ||
zend_get_parameters_ex(3, &link, &option, &retval) == FAILURE) {
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &link, &option, &retval) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
} }
@ -1573,8 +1570,8 @@ PHP_FUNCTION(ldap_get_option)
convert_to_long_ex(option); convert_to_long_ex(option);
opt = Z_LVAL_PP(option); opt = Z_LVAL_PP(option);
switch(opt) {
/* options with int value */
switch (opt) {
/* options with int value */
case LDAP_OPT_DEREF: case LDAP_OPT_DEREF:
case LDAP_OPT_SIZELIMIT: case LDAP_OPT_SIZELIMIT:
case LDAP_OPT_TIMELIMIT: case LDAP_OPT_TIMELIMIT:
@ -1590,15 +1587,15 @@ PHP_FUNCTION(ldap_get_option)
RETURN_FALSE; RETURN_FALSE;
} }
zval_dtor(*retval); zval_dtor(*retval);
ZVAL_LONG(*retval, val);
ZVAL_LONG(*retval, val);
} break; } break;
/* options with string value */
/* options with string value */
case LDAP_OPT_HOST_NAME: case LDAP_OPT_HOST_NAME:
case LDAP_OPT_ERROR_STRING: case LDAP_OPT_ERROR_STRING:
#ifdef LDAP_OPT_MATCHED_DN #ifdef LDAP_OPT_MATCHED_DN
case LDAP_OPT_MATCHED_DN: case LDAP_OPT_MATCHED_DN:
#endif #endif
{
{
char *val; char *val;
if (ldap_get_option(ld->link, opt, &val)) { if (ldap_get_option(ld->link, opt, &val)) {
RETURN_FALSE; RETURN_FALSE;
@ -1624,13 +1621,12 @@ PHP_FUNCTION(ldap_get_option)
Set the value of various session-wide parameters */ Set the value of various session-wide parameters */
PHP_FUNCTION(ldap_set_option) PHP_FUNCTION(ldap_set_option)
{ {
pval **link, **option, **newval;
zval **link, **option, **newval;
ldap_linkdata *ld; ldap_linkdata *ld;
LDAP *ldap; LDAP *ldap;
int opt; int opt;
if (ZEND_NUM_ARGS() != 3 ||
zend_get_parameters_ex(3, &link, &option, &newval) == FAILURE) {
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &link, &option, &newval) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
} }
@ -1644,7 +1640,7 @@ PHP_FUNCTION(ldap_set_option)
convert_to_long_ex(option); convert_to_long_ex(option);
opt = Z_LVAL_PP(option); opt = Z_LVAL_PP(option);
switch(opt) {
switch (opt) {
/* options with int value */ /* options with int value */
case LDAP_OPT_DEREF: case LDAP_OPT_DEREF:
case LDAP_OPT_SIZELIMIT: case LDAP_OPT_SIZELIMIT:
@ -1701,8 +1697,8 @@ PHP_FUNCTION(ldap_set_option)
if ((Z_TYPE_PP(newval) != IS_ARRAY) || !(ncontrols = zend_hash_num_elements(Z_ARRVAL_PP(newval)))) { if ((Z_TYPE_PP(newval) != IS_ARRAY) || !(ncontrols = zend_hash_num_elements(Z_ARRVAL_PP(newval)))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected non-empty array value for this option"); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected non-empty array value for this option");
RETURN_FALSE;
}
RETURN_FALSE;
}
ctrls = safe_emalloc((1 + ncontrols), sizeof(*ctrls), 0); ctrls = safe_emalloc((1 + ncontrols), sizeof(*ctrls), 0);
*ctrls = NULL; *ctrls = NULL;
ctrlp = ctrls; ctrlp = ctrls;
@ -1744,7 +1740,7 @@ PHP_FUNCTION(ldap_set_option)
error = ldap_set_option(ldap, opt, ctrls); error = ldap_set_option(ldap, opt, ctrls);
} }
ctrlp = ctrls; ctrlp = ctrls;
while ( *ctrlp ) {
while (*ctrlp) {
efree(*ctrlp); efree(*ctrlp);
ctrlp++; ctrlp++;
} }
@ -1764,13 +1760,13 @@ PHP_FUNCTION(ldap_set_option)
Extract information from result */ Extract information from result */
PHP_FUNCTION(ldap_parse_result) PHP_FUNCTION(ldap_parse_result)
{ {
pval **link, **result, **errcode, **matcheddn, **errmsg, **referrals;
zval **link, **result, **errcode, **matcheddn, **errmsg, **referrals;
ldap_linkdata *ld; ldap_linkdata *ld;
LDAPMessage *ldap_result; LDAPMessage *ldap_result;
char **lreferrals, **refp; char **lreferrals, **refp;
char *lmatcheddn, *lerrmsg; char *lmatcheddn, *lerrmsg;
int rc, lerrcode, myargcount = ZEND_NUM_ARGS(); int rc, lerrcode, myargcount = ZEND_NUM_ARGS();
if (myargcount < 3 || myargcount > 6 || zend_get_parameters_ex(myargcount, &link, &result, &errcode, &matcheddn, &errmsg, &referrals) == FAILURE) { if (myargcount < 3 || myargcount > 6 || zend_get_parameters_ex(myargcount, &link, &result, &errcode, &matcheddn, &errmsg, &referrals) == FAILURE) {
WRONG_PARAM_COUNT; WRONG_PARAM_COUNT;
} }
@ -1778,13 +1774,13 @@ PHP_FUNCTION(ldap_parse_result)
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link); ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result); ZEND_FETCH_RESOURCE(ldap_result, LDAPMessage *, result, -1, "ldap result", le_result);
rc = ldap_parse_result( ld->link, ldap_result, &lerrcode,
rc = ldap_parse_result(ld->link, ldap_result, &lerrcode,
myargcount > 3 ? &lmatcheddn : NULL, myargcount > 3 ? &lmatcheddn : NULL,
myargcount > 4 ? &lerrmsg : NULL, myargcount > 4 ? &lerrmsg : NULL,
myargcount > 5 ? &lreferrals : NULL, myargcount > 5 ? &lreferrals : NULL,
NULL /* &serverctrls */, NULL /* &serverctrls */,
0 );
if (rc != LDAP_SUCCESS ) {
0);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to parse result: %s", ldap_err2string(rc)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to parse result: %s", ldap_err2string(rc));
RETURN_FALSE; RETURN_FALSE;
} }
@ -1793,8 +1789,8 @@ PHP_FUNCTION(ldap_parse_result)
ZVAL_LONG(*errcode, lerrcode); ZVAL_LONG(*errcode, lerrcode);
/* Reverse -> fall through */ /* Reverse -> fall through */
switch(myargcount) {
case 6 :
switch (myargcount) {
case 6:
zval_dtor(*referrals); zval_dtor(*referrals);
array_init(*referrals); array_init(*referrals);
if (lreferrals != NULL) { if (lreferrals != NULL) {
@ -1805,7 +1801,7 @@ PHP_FUNCTION(ldap_parse_result)
} }
ldap_value_free(lreferrals); ldap_value_free(lreferrals);
} }
case 5 :
case 5:
zval_dtor(*errmsg); zval_dtor(*errmsg);
if (lerrmsg == NULL) { if (lerrmsg == NULL) {
ZVAL_EMPTY_STRING(*errmsg); ZVAL_EMPTY_STRING(*errmsg);
@ -1813,7 +1809,7 @@ PHP_FUNCTION(ldap_parse_result)
ZVAL_STRING(*errmsg, lerrmsg, 1); ZVAL_STRING(*errmsg, lerrmsg, 1);
ldap_memfree(lerrmsg); ldap_memfree(lerrmsg);
} }
case 4 :
case 4:
zval_dtor(*matcheddn); zval_dtor(*matcheddn);
if (lmatcheddn == NULL) { if (lmatcheddn == NULL) {
ZVAL_EMPTY_STRING(*matcheddn); ZVAL_EMPTY_STRING(*matcheddn);
@ -1830,7 +1826,7 @@ PHP_FUNCTION(ldap_parse_result)
Return first reference */ Return first reference */
PHP_FUNCTION(ldap_first_reference) PHP_FUNCTION(ldap_first_reference)
{ {
pval **link, **result;
zval **link, **result;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
LDAPMessage *ldap_result, *entry; LDAPMessage *ldap_result, *entry;
@ -1858,7 +1854,7 @@ PHP_FUNCTION(ldap_first_reference)
Get next reference */ Get next reference */
PHP_FUNCTION(ldap_next_reference) PHP_FUNCTION(ldap_next_reference)
{ {
pval **link, **result_entry;
zval **link, **result_entry;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry, *resultentry_next; ldap_resultentry *resultentry, *resultentry_next;
LDAPMessage *entry_next; LDAPMessage *entry_next;
@ -1887,7 +1883,7 @@ PHP_FUNCTION(ldap_next_reference)
Extract information from reference entry */ Extract information from reference entry */
PHP_FUNCTION(ldap_parse_reference) PHP_FUNCTION(ldap_parse_reference)
{ {
pval **link, **result_entry, **referrals;
zval **link, **result_entry, **referrals;
ldap_linkdata *ld; ldap_linkdata *ld;
ldap_resultentry *resultentry; ldap_resultentry *resultentry;
char **lreferrals, **refp; char **lreferrals, **refp;
@ -1922,7 +1918,7 @@ PHP_FUNCTION(ldap_parse_reference)
Modify the name of an entry */ Modify the name of an entry */
PHP_FUNCTION(ldap_rename) PHP_FUNCTION(ldap_rename)
{ {
pval **link, **dn, **newrdn, **newparent, **deleteoldrdn;
zval **link, **dn, **newrdn, **newparent, **deleteoldrdn;
ldap_linkdata *ld; ldap_linkdata *ld;
int rc; int rc;
@ -1937,7 +1933,7 @@ PHP_FUNCTION(ldap_rename)
convert_to_string_ex(newparent); convert_to_string_ex(newparent);
convert_to_boolean_ex(deleteoldrdn); convert_to_boolean_ex(deleteoldrdn);
#if ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP
rc = ldap_rename_s(ld->link, Z_STRVAL_PP(dn), Z_STRVAL_PP(newrdn), Z_STRVAL_PP(newparent), Z_BVAL_PP(deleteoldrdn), NULL, NULL); rc = ldap_rename_s(ld->link, Z_STRVAL_PP(dn), Z_STRVAL_PP(newrdn), Z_STRVAL_PP(newparent), Z_BVAL_PP(deleteoldrdn), NULL, NULL);
#else #else
if (Z_STRLEN_PP(newparent) != 0) { if (Z_STRLEN_PP(newparent) != 0) {
@ -1960,7 +1956,7 @@ PHP_FUNCTION(ldap_rename)
Start TLS */ Start TLS */
PHP_FUNCTION(ldap_start_tls) PHP_FUNCTION(ldap_start_tls)
{ {
pval **link;
zval **link;
ldap_linkdata *ld; ldap_linkdata *ld;
int rc; int rc;
@ -1979,11 +1975,13 @@ PHP_FUNCTION(ldap_start_tls)
} }
/* }}} */ /* }}} */
#endif #endif
#endif /* ( LDAP_API_VERSION > 2000 ) || HAVE_NSLDAP */
#endif /* (LDAP_API_VERSION > 2000) || HAVE_NSLDAP */
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC) #if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgid, void *params) {
/* {{{ proto _ldap_rebind_proc()
*/
int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgid, void *params)
{
ldap_linkdata *ld; ldap_linkdata *ld;
int retval; int retval;
zval *cb_url; zval *cb_url;
@ -2002,7 +2000,7 @@ int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgi
/* callback */ /* callback */
MAKE_STD_ZVAL(cb_url); MAKE_STD_ZVAL(cb_url);
ZVAL_STRING(cb_url, estrdup(url), 0);
ZVAL_STRING(cb_url, estrdup(url), 0);
cb_args[0] = &cb_link; cb_args[0] = &cb_link;
cb_args[1] = &cb_url; cb_args[1] = &cb_url;
if (call_user_function_ex(EG(function_table), NULL, ld->rebindproc, &cb_retval, 2, cb_args, 0, NULL TSRMLS_CC) == SUCCESS && cb_retval) { if (call_user_function_ex(EG(function_table), NULL, ld->rebindproc, &cb_retval, 2, cb_args, 0, NULL TSRMLS_CC) == SUCCESS && cb_retval) {
@ -2017,7 +2015,7 @@ int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgi
FREE_ZVAL(cb_url); FREE_ZVAL(cb_url);
return retval; return retval;
} }
/* }}} */
/* {{{ proto bool ldap_set_rebind_proc(resource link, string callback) /* {{{ proto bool ldap_set_rebind_proc(resource link, string callback)
Set a callback function to do re-binds on referral chasing. */ Set a callback function to do re-binds on referral chasing. */
@ -2063,9 +2061,9 @@ PHP_FUNCTION(ldap_set_rebind_proc)
zval_copy_ctor(ld->rebindproc); zval_copy_ctor(ld->rebindproc);
RETURN_TRUE; RETURN_TRUE;
} }
/* }}} */
#endif #endif
#ifdef STR_TRANSLATION #ifdef STR_TRANSLATION
/* {{{ php_ldap_do_translate /* {{{ php_ldap_do_translate
*/ */
@ -2084,11 +2082,11 @@ static void php_ldap_do_translate(INTERNAL_FUNCTION_PARAMETERS, int way)
ldap_buf = Z_STRVAL_PP(value); ldap_buf = Z_STRVAL_PP(value);
ldap_len = Z_STRLEN_PP(value); ldap_len = Z_STRLEN_PP(value);
if(ldap_len == 0) {
if (ldap_len == 0) {
RETURN_FALSE; RETURN_FALSE;
} }
if(way == 1) {
if (way == 1) {
result = ldap_8859_to_t61(&ldap_buf, &ldap_len, 0); result = ldap_8859_to_t61(&ldap_buf, &ldap_len, 0);
} else { } else {
result = ldap_t61_to_8859(&ldap_buf, &ldap_len, 0); result = ldap_t61_to_8859(&ldap_buf, &ldap_len, 0);

Loading…
Cancel
Save