|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 02:00:01 2025 UTC |
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!"; } ?>