PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_LDAP » Bug #4975

Net_LDAP::connect always throws an exception

Details

Submitted2005-08-02 21:02 UTC
Fromchristoph dot rauch at gmail dot com
Assigneddelatbabel
StatusClosed
PackageNet_LDAP
PHP Version5.0.4
OSLinux
Roadmaps(Not assigned)

Comments

[2005-08-02 21:02 UTC] christoph dot rauch at gmail dot com

Description:
------------
Due to an bug in line 209 in Net_LDAP 1.19.2.10, raiseError always gets called with an exception if the bind fails because of invalid credentials.

The new line 209 should be like this or similar

return $this->raiseError("Bind failed " . ldap_error($this->_link) );

The ldap_errno has nothing to do with the PEAR error cases.

I looked in 1.19.2.11 and this bug has not been fixed yet.

[2006-02-06 15:16 UTC] scott at crisscott dot com

I think the real problem here is that the Net_LDAP_Error constructor is missing a message argument which means that when PEAR trys to create the error class, the error code is treated as the error mode.

Net_LDAP_Error constructor:
function Net_LDAP_Error($code = NET_LDAP_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null)

PEAR_Error constructor:
function PEAR_Error($message = 'unknown error', $code = null, $mode = null, $options = null, $userinfo = null)

Notice the missing message argument. When the error class is instantiated, a message is always passed becuase the skipmsg argument (the last argument to raiseError) is never set to true. This message throws the arguments off by one and the error mode on a failed bind becomes 49 instead of 1.

[2006-02-06 15:23 UTC] scott at crisscott dot com

Possible patch for error message issue:

function Net_LDAP_Error(...)
{
if (is_string($code)) {
// A message was given. Drop it and call this
// method again.
$args = func_get_args();
array_shift($args);
return call_user_func_array(array('Net_LDAP_Error', 'Net_LDAP_Error'), $args);
}

// ...
}

[2006-02-24 01:13 UTC] delatbabel at php dot net

Writing test case for this with PHPUnit.

[2006-02-24 01:47 UTC] delatbabel at php dot net

This should be fixed by adding the extra parameter back to the Net_LDAP_Error constructor -- this works in my local copy and will be committed back to CVS on the next run.

[2006-02-24 03:41 UTC] delatbabel at php dot net

This bug has been fixed in CVS.

If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.