From: php at monona dot us Operating system: Windows PHP version: 5.3.17 Package: LDAP related Bug Type: Bug Bug description:call to ldap_search returns null
Description: ------------ --- >From manual page: http://www.php.net/function.ldap-search#refsect1-function.ldap-search-returnvalues --- The documentation for function ldap_search says that it will either return a resource or it will return a boolean false. I have successfully bound to a microsoft Active Directory using ldap_connect and ldap_bind. When I call ldap_search with a null for the forth parameter($attributes) it returns a null while setting ldap_error() to "Sucess" and ldap_errno() to zero. The reason for passing a null for $attributes is so that I can explicity set a limit using the sixth parameter ($sizelimit) and because I want everything passed back, as if I had called ldap_search with only three parameters. Another factor that probably contributes to creating this bug is that if I make the call to ldap_search with just 3 paramters, it returns false with error set to "Operations error" and errno set to 1 so there is obviously something else wrong with the search. I would prefer that either this condition return false and a specific error message if there is something about the null $attributes that is an error or that it return false/1/Operations error because that error is in fact still true or that the documentation be updated to reflect when/why this function can return null/o/success when in fact there is nothing successful about the call. Test script: --------------- <?php // replace xxxxxx with your server name $ad=ldap_connect('ldap://xxxxxx'); ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ad, LDAP_OPT_REFERRALS, 0); ldap_bind($ad); // replace xxxxxx etc. with your base DN $result=@ldap_search($ad,'dc=xxxxxx,dc=com','(objectClass=*)',null,1,10); if(!$result){ die('Could not search AD because '.ldap_error($ad).'('.ldap_errno($ad).')'); } ldap_unbind($ad); ?> Expected result: ---------------- return false ldap_error() returns 'Operation error' ldap_error() errno=1 or return false ldap_error() returns 'Some message about invalid $attributes parameter' ldap_errno() returnd unique error number for above Actual result: -------------- Return value of NULL ldap_error() returns 'Success' ldap_errno() returns 0 -- Edit bug report at https://bugs.php.net/bug.php?id=63299&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63299&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63299&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63299&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63299&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63299&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63299&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63299&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63299&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63299&r=support Expected behavior: https://bugs.php.net/fix.php?id=63299&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63299&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63299&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63299&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63299&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63299&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63299&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63299&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63299&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63299&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63299&r=mysqlcfg