php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5759 Unable to add binary data to LDAP
Submitted: 2000-07-24 16:07 UTC Modified: 2000-07-28 23:43 UTC
From: johan dot troedsson at ei dot sigma dot se Assigned: sniper (profile)
Status: Closed Package: LDAP related
PHP Version: 4.0.1 OS: Redhat 6.2
Private report: No CVE-ID: None
 [2000-07-24 16:07 UTC] johan dot troedsson at ei dot sigma dot se
It is not possible to add binary data using ldap_add functions in PHP. 

This is not the same as bug #5702, where John Hallam tries to fill the jpegphoto attribute with a base64 encoded jpeg picture, i.e. non-binary (an approach I think is not correct by the way, since the LDAP server wants binary data in binary form).

Try the following script:

<?php

	$userfile = "./test.jpg";
	$fd = fopen ($userfile, "r");
    $fsize = filesize ($userfile);
    echo "FILE_LEN: ".$fsize;
  	$jpegStr = fread ($fd, $fsize);
  	fclose ($fd);

    echo "  STR_LEN: ".strlen($jpegStr);
    
    echo "  DATA: $jpegStr";

    $ldapServerAddress = "ldap";
    $ldapLoginName = "cn=admin,dc=se";
    $ldapLoginPassword = "secret";
    
    $ldapConn = ldap_connect($ldapServerAddress);
    ldap_bind($ldapConn, 
              $ldapLoginName, 
              $ldapLoginPassword);

    ldap_add($ldapConn, 
             "cn=person,dc=se",
             array("objectclass" => "inetorgperson",
                   "sn"          => "surname",
                   "cn"          => "common name",
                   "jpegphoto"   => $jpegStr ) );
                   

?>

Look at the result in e.g. Netscape's addressbook. It will only be a couple of bytes in length.

/Johan


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-24 16:24 UTC] johan dot troedsson at ei dot sigma dot se
Agreeing with Stig Venaas, this is rather feedback than a bug, i.e. something that should be implemented...

/Johan
 [2000-07-24 16:31 UTC] sniper@php.net
>It is not possible to add binary data using ldap_add >functions in PHP

This is a known bug. And I am going to try to fix this if
someone else doesn't. 

>This is not the same as bug #5702, where John Hallam tries
>to fill the jpegphoto attribute
>with a base64 encoded jpeg picture, i.e. non-binary (an
>approach I think is not correct by

You're right about it not being the right approach.
But it is the same bug. =) Which by the way is now closed.

Fix to this bug will fix #5702 too.

--Jani
 [2000-07-28 23:43 UTC] sniper@php.net
Fixed in CVS.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 23:01:30 2024 UTC