|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-12-08 14:59 UTC] binkleym at nukote dot 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];
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
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