Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 133467
Collapse All | Expand All

(-)php-5.1.6/ext/ldap/ldap.c (-51 / +12 lines)
Lines 116-122 Link Here
116
	PHP_FE(ldap_first_attribute,	third_arg_force_ref)
116
	PHP_FE(ldap_first_attribute,	third_arg_force_ref)
117
	PHP_FE(ldap_next_attribute,		third_arg_force_ref)
117
	PHP_FE(ldap_next_attribute,		third_arg_force_ref)
118
	PHP_FE(ldap_get_attributes,							NULL)
118
	PHP_FE(ldap_get_attributes,							NULL)
119
	PHP_FE(ldap_get_values,								NULL)
119
	PHP_FALIAS(ldap_get_values,	ldap_get_values_len,				NULL)
120
/*	PHP_FE(ldap_get_values,								NULL) */
120
	PHP_FE(ldap_get_values_len,							NULL)
121
	PHP_FE(ldap_get_values_len,							NULL)
121
	PHP_FE(ldap_get_dn,									NULL)
122
	PHP_FE(ldap_get_dn,									NULL)
122
	PHP_FE(ldap_explode_dn,								NULL)
123
	PHP_FE(ldap_explode_dn,								NULL)
Lines 1033-1039 Link Here
1033
	BerElement *ber;
1034
	BerElement *ber;
1034
	char *attribute;
1035
	char *attribute;
1035
	size_t attr_len;
1036
	size_t attr_len;
1036
	char **ldap_value;
1037
	struct berval **ldap_value;
1037
	char *dn;
1038
	char *dn;
1038
1039
1039
	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &link, &result) == FAILURE) {
1040
	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &link, &result) == FAILURE) {
Lines 1064-1079 Link Here
1064
		attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber);
1065
		attribute = ldap_first_attribute(ldap, ldap_result_entry, &ber);
1065
1066
1066
		while (attribute != NULL) {
1067
		while (attribute != NULL) {
1067
			ldap_value = ldap_get_values(ldap, ldap_result_entry, attribute);
1068
			ldap_value = ldap_get_values_len(ldap, ldap_result_entry, attribute);
1068
			num_values = ldap_count_values(ldap_value);
1069
			num_values = ldap_count_values_len(ldap_value);
1069
1070
1070
			MAKE_STD_ZVAL(tmp2);
1071
			MAKE_STD_ZVAL(tmp2);
1071
			array_init(tmp2);
1072
			array_init(tmp2);
1072
			add_assoc_long(tmp2, "count", num_values);
1073
			add_assoc_long(tmp2, "count", num_values);
1073
			for (i = 0; i < num_values; i++) {
1074
			for (i = 0; i < num_values; i++) {
1074
				add_index_string(tmp2, i, ldap_value[i], 1);
1075
				add_index_stringl(tmp2, i, ldap_value[i]->bv_val, ldap_value[i]->bv_len, 1);
1075
			}	
1076
			}	
1076
			ldap_value_free(ldap_value);
1077
			ldap_value_free_len(ldap_value);
1077
1078
1078
			attr_len = strlen(attribute);
1079
			attr_len = strlen(attribute);
1079
			zend_hash_update(Z_ARRVAL_P(tmp1), php_strtolower(attribute, attr_len), attr_len+1, (void *) &tmp2, sizeof(zval *), NULL);
1080
			zend_hash_update(Z_ARRVAL_P(tmp1), php_strtolower(attribute, attr_len), attr_len+1, (void *) &tmp2, sizeof(zval *), NULL);
Lines 1180-1186 Link Here
1180
	ldap_linkdata *ld;
1181
	ldap_linkdata *ld;
1181
	ldap_resultentry *resultentry;
1182
	ldap_resultentry *resultentry;
1182
	char *attribute;
1183
	char *attribute;
1183
	char **ldap_value;
1184
	struct berval **ldap_value;
1184
	int i, num_values, num_attrib;
1185
	int i, num_values, num_attrib;
1185
	BerElement *ber;
1186
	BerElement *ber;
1186
1187
Lines 1196-1211 Link Here
1196
	
1197
	
1197
	attribute = ldap_first_attribute(ld->link, resultentry->data, &ber);
1198
	attribute = ldap_first_attribute(ld->link, resultentry->data, &ber);
1198
	while (attribute != NULL) {
1199
	while (attribute != NULL) {
1199
		ldap_value = ldap_get_values(ld->link, resultentry->data, attribute);
1200
		ldap_value = ldap_get_values_len(ld->link, resultentry->data, attribute);
1200
		num_values = ldap_count_values(ldap_value);
1201
		num_values = ldap_count_values_len(ldap_value);
1201
1202
1202
		MAKE_STD_ZVAL(tmp);
1203
		MAKE_STD_ZVAL(tmp);
1203
		array_init(tmp);
1204
		array_init(tmp);
1204
		add_assoc_long(tmp, "count", num_values);
1205
		add_assoc_long(tmp, "count", num_values);
1205
		for (i = 0; i < num_values; i++) {
1206
		for (i = 0; i < num_values; i++) {
1206
			add_index_string(tmp, i, ldap_value[i], 1);
1207
			add_index_stringl(tmp, i, ldap_value[i]->bv_val, ldap_value[i]->bv_len, 1);
1207
		}
1208
		}
1208
		ldap_value_free(ldap_value);
1209
		ldap_value_free_len(ldap_value);
1209
1210
1210
		zend_hash_update(Z_ARRVAL_P(return_value), attribute, strlen(attribute)+1, (void *) &tmp, sizeof(zval *), NULL);
1211
		zend_hash_update(Z_ARRVAL_P(return_value), attribute, strlen(attribute)+1, (void *) &tmp, sizeof(zval *), NULL);
1211
		add_index_string(return_value, num_attrib, attribute, 1);
1212
		add_index_string(return_value, num_attrib, attribute, 1);
Lines 1226-1271 Link Here
1226
}
1227
}
1227
/* }}} */
1228
/* }}} */
1228
1229
1229
/* {{{ proto array ldap_get_values(resource link, resource result_entry, string attribute)
1230
   Get all values from a result entry */
1231
PHP_FUNCTION(ldap_get_values)
1232
{
1233
	zval **link, **result_entry, **attr;
1234
	ldap_linkdata *ld;
1235
	ldap_resultentry *resultentry;
1236
	char *attribute;
1237
	char **ldap_value;
1238
	int i, num_values;
1239
1240
	if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &link, &result_entry, &attr) == FAILURE) {
1241
		WRONG_PARAM_COUNT;
1242
	}
1243
1244
	ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link", le_link);
1245
	ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1, "ldap result entry", le_result_entry);
1246
1247
	convert_to_string_ex(attr);
1248
	attribute = Z_STRVAL_PP(attr);
1249
1250
	if ((ldap_value = ldap_get_values(ld->link, resultentry->data, attribute)) == NULL) {
1251
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot get the value(s) of attribute %s", ldap_err2string(_get_lderrno(ld->link)));
1252
		RETURN_FALSE;
1253
	}
1254
1255
	num_values = ldap_count_values(ldap_value);
1256
1257
	array_init(return_value);
1258
1259
	for (i = 0; i<num_values; i++) {
1260
		add_next_index_string(return_value, ldap_value[i], 1);
1261
	}
1262
	
1263
	add_assoc_long(return_value, "count", num_values);
1264
	ldap_value_free(ldap_value);
1265
1266
}
1267
/* }}} */
1268
1269
/* {{{ proto array ldap_get_values_len(resource link, resource result_entry, string attribute)
1230
/* {{{ proto array ldap_get_values_len(resource link, resource result_entry, string attribute)
1270
   Get all values with lengths from a result entry */
1231
   Get all values with lengths from a result entry */
1271
PHP_FUNCTION(ldap_get_values_len)
1232
PHP_FUNCTION(ldap_get_values_len)

Return to bug 133467