PHP 4.0 Bug #8176 Updated: ldap_search munges binary data
| From: | sniper@php.net | Date: | Sat, 09 Dec 2000 02:01:37 +0000 |
| Subject: | PHP 4.0 Bug #8176 Updated: ldap_search munges binary data | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-40627@lists.php.net to get a copy of this message | ||
ID: 8176
Updated by: sniper
Reported By: binkleym@nukote.com
Old-Status: Open
Status: Closed
Bug Type: LDAP related
Assigned To:
Comments:
ldap_get_entries() is not (yet) binary safe. But this might change in
future versions.
Use ldap_get_values_len() instead.
Here is an example:
<?php
$ds=ldap_connect("localhost");
// Anonymous bind
$r=ldap_bind($ds);
if (!$r) {
print ldap_error();
exit();
}
$filter = "cn=Test*";
$group = "dc=mydomain, dc=com";
$sr=ldap_search($ds,$group, $filter);
$entry = ldap_first_entry($ds,$sr);
$data = ldap_get_values_len($ds, $entry,"jpegphoto");
header("Content-type: image/jpeg");
echo $data[0];
?>
I just tried this and it works just fine.
--Jani
Previous Comments:
---------------------------------------------------------------------------
[2000-12-08 14:59:23] binkleym@nukote.com
I have a clean installation of Debian Woody with PHP4, OpenLDAP 2, and the latest stable
apt-get's. I am trying to fetch a jpeg picture from the LDAP server with PHP, but I'm
only getting 3-4 characters. This looks similar to a previous LDAP bug (#5759)
I've run the script using PHP 4.0.3.pl1-7 and PHP 4.0.4-0RC3.2, and OpenLDAP 2.0.7-1.
Here's a sample script which generates the bug:
<?
Header( "Content-type: image/jpeg");
$ldap = ldap_connect("data2.nukote.com", "389");
$result = ldap_search($ldap, "o=nukote.com", "uid=binkleym");
if ($result) {
$temp = ldap_get_entries($ldap, $result);
if ($temp["count"] == 1) $entry = $temp[0];
}
ldap_close($ldap);
echo $entry["jpegphoto"][0];
?>
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=8176