php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18023 blank fields in chosen sort order cause decode error
Submitted: 2002-06-27 15:25 UTC Modified: 2002-06-28 23:53 UTC
From: patrick dot buick at wrx-ca dot com Assigned:
Status: Not a bug Package: LDAP related
PHP Version: 4.2.1 OS: Windows 2000 Advanced Server
Private report: No CVE-ID: None
 [2002-06-27 15:25 UTC] patrick dot buick at wrx-ca dot com
Using PHP 4.2.1 on Windows 2000 Advanced Server under Apache 1.3.24, I do an LDAP Connect, Bind and Search just fine. 

I then use the (relatively) new ldap_sort() with a sort order of "sn", with no error returned by the sort routine.

When I then attempt a ldap_get_entries on the sorted result, I get a Decoding Error, LDAP error code 0x54.

If I ignore the error and print the array, it all prints fine with no errors. (IE: No missing fields etc.)

The only oddity I can see in the output data is that one of the "sn" fields is empty and by sort-order gets placed as the first item in the array.

I haven't yet tried printing the entire raw array to see if there are any other anomalies introduced into the data that echo "overlooks".

So, in Bill 'n Ted's example format:

What I did: 
Obtained LDAP data and sorted it using ldap_sort() by "sn".
Attempted to use get_ldap_entries() and got error 0x54 decoding error.

What I wanted to happen:
I wanted an entry array sorted by "sn".

What I got:
An error, though if I ignore the error, I got an array
sorted by "sn".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-28 03:03 UTC] derick@php.net
Please add a short, reproducing script.
 [2002-06-28 12:13 UTC] patrick dot buick at wrx-ca dot com
<?php
/* sample script to reproduce ldap_search error 0x45 on blank values.
   This is VERY cut-down from the original script and doesn't represent my 
   programming style whatsoever! 
*/

function quit_gracefully($errmsg) {
  exit ("<p><strong><em>".$errmsg."</strong></em></p></body></html>\n");
};

function check_ldap_success($rlid, $msg) {
      $errcode = ldap_errno($rlid);
       if ($errcode != 0x00) {
         echo ("<h2>An error has been generated</h2><br />\n");
         echo ("<p>LDAP Error Message: &lt;".ldap_error($rlid)."&gt;</p>\n");
         echo ("<p>Error Code: &lt;0x".dechex($errcode)."&gt;</p>\n");
         if ($errcode == 0x54) {
           echo ("<p>The results may not be right. This has been submitted" .
                 " as a bug report.</p>\n" .
                 "<p>Programmer Message: &lt;".$msg."&gt;</p>\n");
         }
         else quit_gracefully("<p>Programmer Message: &lt".$msg."&gt;</p>\n");
       }; 
}
    
// Beginning of Main Program
?>
<html>
  <head>
    <title>Test Blank Entries</title>
  </head>
  <body>
  <h2>Test Blank Entries</h2>
<?php

// Set Variables  
$server = "cal-exch.wrx-ca.com";
$baseDN = "o=Wireless Matrix";
$searchFilter = "objectclass=groupOfNames";
$sortOrder = "sn";
$attributes = array("rfc822mailbox","rdn");

// Do Work
$link=ldap_connect($server);
check_ldap_success($link, "Server Connect");
$r=ldap_bind($link);
check_ldap_success($link, "Binding");
$sr=ldap_search($link,$baseDN, $searchFilter, $attributes);
check_ldap_success($link, "Searching");
ldap_sort($link, $sr, $sortOrder);
check_ldap_success($link, "Sorting");
$info = ldap_get_entries($link, $sr);
check_ldap_success($link, "Getting Entries");
// If the error is ignored by check_ldap_success, then it prints fine
// print_array($info);
ldap_close($link);
?>
  </body>
</html>
 [2002-06-28 23:53 UTC] sniper@php.net
This is not any bug in PHP but you could say it's 
bug in openldap's ldap_sort_entries() function.

You can safely ignore that decoding error.
(it's coming from ldap_sort() btw.)



 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC