|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5433 LDAP "Decoding error" when requesting non-existent attributes in a search op.
Submitted: 2000-07-07 13:02 UTC Modified: 2000-07-25 17:33 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: Linux Redhat 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: johan dot troedsson at ei dot sigma dot se
New email:
PHP Version: OS:


 [2000-07-07 13:02 UTC] johan dot troedsson at ei dot sigma dot se
When providing e.g. the ldap_search function with an array of attributes to be returned, and an attribute in this array doesn't exist in the targeted LDAP node, an LDAP "Decoding error" occurs.

In PHP3 I used to send in an array("dn") to only have the "dn" property returned. But since "dn" isn't a real LDAP attribute, I suppose I could have written any text in this array to only have the dn returned. 

The possibility to have only the "dn" returned would be useful in PHP4 as well.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-23 17:53 UTC] sniper at cvs dot php dot net
I can not reproduce this with latest CVS. 

Please attach shortest reproducing script.


 [2000-07-23 17:53 UTC] sniper at cvs dot php dot net
Changed status to 'feedback'.

 [2000-07-24 14:01 UTC] johan dot troedsson at ei dot sigma dot se
In the manual for ldap_get_entries it says:

Returns a complete result information in a multi-dimenasional array on success and false on *error*.

In PHP4 false is returned when no entry in the search result contain one of the requested attributes. In PHP3 true was returned in this case, and you could pick out the PHP-appended "dn" array value for each entry (even if no other attribute was present).

I suppose it depends on how *error* is defined. But if the PHP4 way of defining it is used, the only way to get all the entries of a search result without getting all the attributes of every entry, is to request an attribute that you know exist in every entry, e.g. "objectclass".

Then the "decoding error" issue. It occurs more often than I thought (always?), when retrieving entries using an ldap_get_xxxx function (even if the get function doesn't return false). But a result array that seems to be OK is returned every time the function returns a non-false value.

I'm using openLDAP 1.2.10 as my LDAP server.


Try the following script to reproduce the situation:


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

             array("objectclass" => "inetorgperson",
                   "sn"          => "surname",
                   "cn"          => "common name" ) );

    $readId = ldap_read($ldapConn, 
      array( "objectclass" ) ); // Returns true 
//      array( "whatever" ) );  // Returns false

    echo "LDAP_STATUS_READ: ".ldap_error($ldapConn);

    $entryId = ldap_get_entries($ldapConn, $readId);

    echo "<br>LDAP_STATUS_GET: ".ldap_error($ldapConn);

    if ( $entryId )
        echo "<br>PHP_STATUS: OK!";
        echo "<br>PHP_STATUS: ERROR!";

 [2000-07-24 16:34 UTC]
This is indeed a misbehaviour / bug. I'll look into this.

 [2000-07-25 17:33 UTC]
Fixed in CVS.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Nov 28 17:01:27 2023 UTC