cvs: /php4/ext/ldap ldap.c php_ldap.h

From: Date: Fri, 07 Apr 2000 23:20:52 +0000
Subject: cvs: /php4/ext/ldap ldap.c php_ldap.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-13324@lists.php.net to get a copy of this message
sterling Fri Apr 7 16:20:52 2000 EDT Modified files: /php4/ext/ldap ldap.c php_ldap.h Log: @-Added ldap_get_values_len function from PHP3 to PHP4. (Sterling) Index: php4/ext/ldap/ldap.c diff -u php4/ext/ldap/ldap.c:1.33 php4/ext/ldap/ldap.c:1.34 --- php4/ext/ldap/ldap.c:1.33 Thu Apr 6 14:17:50 2000 +++ php4/ext/ldap/ldap.c Fri Apr 7 16:20:22 2000 @@ -21,7 +21,7 @@ */ -/* $Id: ldap.c,v 1.33 2000/04/06 21:17:50 cmv Exp $ */ +/* $Id: ldap.c,v 1.34 2000/04/07 23:20:22 sterling Exp $ */ #define IS_EXT_MODULE #include "php.h" @@ -74,6 +74,7 @@ PHP_FE(ldap_next_attribute, NULL) PHP_FE(ldap_get_attributes, NULL) PHP_FE(ldap_get_values, NULL) + PHP_FE(ldap_get_values_len, NULL) PHP_FE(ldap_get_dn, NULL) PHP_FE(ldap_explode_dn, NULL) PHP_FE(ldap_dn2ufn, NULL) @@ -177,7 +178,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "LDAP Support", "enabled" ); - php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.33 2000/04/06 21:17:50 cmv Exp $" ); + php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.34 2000/04/07 23:20:22 sterling Exp $" ); php_info_print_table_row(2, "Total Links", maxl ); #if HAVE_NSLDAP @@ -935,6 +936,58 @@ ldap_value_free(ldap_value); } /* }}} */ + +/* {{{ proto array ldap_get_values_len(int link, int result, string attribute) + Get all values from a result entry */ +PHP_FUNCTION(ldap_get_values_len) +{ + pval **link, **result_entry, **attr; + LDAP* ldap; + LDAPMessage* ldap_result_entry; + char* attribute; + struct berval **ldap_value_len; + int i, num_values; + + if (ARG_COUNT(ht) != 3 || + zend_get_parameters_ex(3, &link, &result_entry, &attr) == FAILURE) { + WRONG_PARAM_COUNT; + } + + if ((ldap = _get_ldap_link(link)) == NULL) { + RETURN_FALSE; + } + + ldap_result_entry = _get_ldap_result_entry(result_entry); + convert_to_string_ex(attr); + 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 + RETURN_FALSE; + } + + num_values = ldap_count_values_len(ldap_value_len); + if (array_init(return_value) == FAILURE) { + php_error(E_ERROR, "Cannot initialize return value"); + RETURN_FALSE; + } + + for (i=0; i<num_values; i++) { + add_next_index_string(return_value, ldap_value_len[i]->bv_val, 1); + } + + add_assoc_long(return_value, "count", num_values); +} +/* }}} */ + /* {{{ proto string ldap_get_dn(int link, int result) Get the DN of a result entry */ Index: php4/ext/ldap/php_ldap.h diff -u php4/ext/ldap/php_ldap.h:1.5 php4/ext/ldap/php_ldap.h:1.6 --- php4/ext/ldap/php_ldap.h:1.5 Thu Apr 6 05:36:47 2000 +++ php4/ext/ldap/php_ldap.h Fri Apr 7 16:20:22 2000 @@ -29,7 +29,7 @@ */ -/* $Id: php_ldap.h,v 1.5 2000/04/06 12:36:47 sterling Exp $ */ +/* $Id: php_ldap.h,v 1.6 2000/04/07 23:20:22 sterling Exp $ */ #ifndef _PHP_LDAP_H #define _PHP_LDAP_H @@ -69,6 +69,7 @@ PHP_FUNCTION(ldap_get_attributes); PHP_FUNCTION(ldap_get_values); +PHP_FUNCTION(ldap_get_values_len); PHP_FUNCTION(ber_free); PHP_FUNCTION(ldap_get_dn);

« previous php.version4 (#13324) next »