cvs: /php3/functions ldap.c php3_ldap.h
| From: | Stig Venaas | Date: | Sat, 07 Aug 1999 14:12:41 +0000 |
| Subject: | cvs: /php3/functions ldap.c php3_ldap.h | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-9611@lists.php.net to get a copy of this message | ||
venaas Sat Aug 7 10:12:41 1999 EDT
Modified files:
/php3/functions ldap.c php3_ldap.h
Log:
New function ldap_get_values_len
Index: php3/functions/ldap.c
diff -u php3/functions/ldap.c:1.69 php3/functions/ldap.c:1.70
--- php3/functions/ldap.c:1.69 Thu Jul 1 08:28:16 1999
+++ php3/functions/ldap.c Sat Aug 7 10:12:41 1999
@@ -30,7 +30,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ldap.c,v 1.69 1999/07/01 12:28:16 sas Exp $ */
+/* $Id: ldap.c,v 1.70 1999/08/07 14:12:41 venaas Exp $ */
#define IS_EXT_MODULE
#if !PHP_31 && defined(THREAD_SAFE)
#undef THREAD_SAFE
@@ -133,6 +133,9 @@
{"ldap_error", php3_ldap_error, NULL},
{"ldap_str2err", php3_ldap_str2err, NULL},
/* end kk mod */
+/* additional function that handles binary data, Stig Venaas */
+ {"ldap_get_values_len", php3_ldap_get_values_len, NULL},
+/* end sv mod */
{NULL, NULL, NULL}
};
@@ -315,7 +318,7 @@
php3_printf("<table>"
"<tr><td>Total links:</td><td>%d/%s</td></tr>\n"
- "<tr><td>RCS Version:</td><td>$Id: ldap.c,v 1.69 1999/07/01
12:28:16 sas Exp $</td></tr>\n"
+ "<tr><td>RCS Version:</td><td>$Id: ldap.c,v 1.70 1999/08/07
14:12:41 venaas Exp $</td></tr>\n"
#if HAVE_NSLDAP
"<tr><td>SDK Version:</td><td>%f</td></tr>"
"<tr><td>Highest LDAP Protocol
Supported:</td><td>%f</td></tr>"
@@ -1136,6 +1139,62 @@
add_assoc_long(return_value, "count", num_values);
ldap_value_free(ldap_value);
+}
+/* }}} */
+
+/* {{{ proto array ldap_get_values_len(int link, int result, string attribute)
+ Get all values from a result entry */
+void php3_ldap_get_values_len(INTERNAL_FUNCTION_PARAMETERS)
+{
+ pval *link, *result_entry, *attr;
+ LDAP *ldap;
+ LDAPMessage *ldap_result_entry;
+ char *attribute;
+ struct berval **ldap_value_len;
+ pval tmp;
+
+ int i, num_values;
+
+ if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &link, &result_entry, &attr) ==
FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ ldap = _get_ldap_link(link, list);
+ if (ldap == NULL) RETURN_FALSE;
+
+ ldap_result_entry = _get_ldap_result_entry(result_entry, list);
+ if (ldap_result_entry == NULL) RETURN_FALSE;
+
+ convert_to_string(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
+ php3_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s",
ldap_err2string(ldap_get_lderrno(ldap,NULL,NULL)));
+#else
+ php3_error(E_WARNING, "LDAP: Cannot get the value(s) of attribute %s",
ldap_err2string(ldap->ld_errno));
+#endif
+#endif
+ RETURN_FALSE;
+ }
+
+ num_values = ldap_count_values_len(ldap_value_len);
+
+ if (array_init(return_value) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ for(i=0; i<num_values; i++) {
+ tmp.type = IS_STRING;
+ tmp.value.str.len = ldap_value_len[i]->bv_len;
+ tmp.value.str.val = estrndup(ldap_value_len[i]->bv_val, tmp.value.str.len);
+ _php3_hash_next_index_insert(return_value->value.ht, &tmp, sizeof(pval),NULL);
+ }
+
+ add_assoc_long(return_value, "count", num_values);
+
+ ldap_value_free_len(ldap_value_len);
}
/* }}} */
Index: php3/functions/php3_ldap.h
diff -u php3/functions/php3_ldap.h:1.26 php3/functions/php3_ldap.h:1.27
--- php3/functions/php3_ldap.h:1.26 Thu Jul 1 05:15:33 1999
+++ php3/functions/php3_ldap.h Sat Aug 7 10:12:41 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: php3_ldap.h,v 1.26 1999/07/01 09:15:33 kk Exp $ */
+/* $Id: php3_ldap.h,v 1.27 1999/08/07 14:12:41 venaas Exp $ */
#ifndef _PHP3_LDAP_H
#define _PHP3_LDAP_H
@@ -75,6 +75,7 @@
extern void php3_ldap_get_attributes(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ldap_get_values(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_ldap_get_values_len(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ber_free(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ldap_get_dn(INTERNAL_FUNCTION_PARAMETERS);