php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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.

/Johan

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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.

--Jani

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

--Jani
 [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.

/Johan


Try the following script to reproduce the situation:

<?php

    $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" ) );

    $readId = ldap_read($ldapConn, 
      "cn=person,dc=se",
      "(objectclass=inetorgperson)",                                    
      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!";
    }
    else
    {
        echo "<br>PHP_STATUS: ERROR!";
    }

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

--Jani
 [2000-07-25 17:33 UTC] sniper@php.net
Fixed in CVS.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 10:01:28 2024 UTC