PHP 4.0 Bug #5433 Updated: LDAP "Decoding error" when requesting non-existent attributes in a search op.
| From: | Bug Database | Date: | Mon, 24 Jul 2000 12:01:20 +0000 |
| Subject: | PHP 4.0 Bug #5433 Updated: LDAP "Decoding error" when requesting non-existent attributes in a search op. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-25699@lists.php.net to get a copy of this message | ||
ID: 5433
User Update by: johan.troedsson@ei.sigma.se
Status: Feedback
Bug Type: LDAP related
Description: LDAP "Decoding error" when requesting non-existent attributes in a search op.
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!";
}
?>
Full Bug description available at: http://bugs.php.net/?id=5433