|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8176 ldap_search munges binary data
Submitted: 2000-12-08 14:59 UTC Modified: 2000-12-08 21:01 UTC
From: binkleym at nukote dot com Assigned:
Status: Closed Package: LDAP related
PHP Version: 4.0.3pl1 OS: Debian Woody (with latest update
Private report: No CVE-ID: None
 [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("", "389");

$result = ldap_search($ldap, "", "uid=binkleym");

if ($result) {
   $temp = ldap_get_entries($ldap, $result);
   if ($temp["count"] == 1) $entry = $temp[0];


echo $entry["jpegphoto"][0];



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-08 21:01 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:


// Anonymous bind
if (!$r) {
    print ldap_error();

$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.


PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 14:01:33 2024 UTC