Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.1

Bug #1863 Cannot connect using "ldaps" protocol
Submitted: 2004-07-13 17:38 UTC
From: pmjones Assigned: dufuz
Status: Closed Package: DB_ldap
PHP Version: Irrelevant OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2004-07-13 17:38 UTC] pmjones
Description: ------------ Cannot connect to secure LDAP source using "ldaps" protocol. If you use a phptype of "ldaps" then DB cannot find the "DB/ldaps.php" file (becuase it's just "DB/ldap.php"). If you set the DSN hostspec to "ldaps://example.com" then the connect() method attempts to split the hostspec at the colon into host and port. One fix is to change the host/port splitting algorithm in the connect() method to take full URLs into account. --- CURRENT CODE --- <?php // DB/ldap.php, line 403, the connect() method if (($colon_pos = strpos($dsninfo['hostspec'], ':')) !== false) { $host = substr($dsninfo['hostspec'], 0, $colon_pos); $port = substr($dsninfo['hostspec'], $colon_pos + 1); } else { $host = $dsninfo['hostspec']; $port = null; } ?> --- PROPOSED FIX --- <?php if (strpos($dsninfo['hostspec'], '://') === false) { if (($colon_pos = strpos($dsninfo['hostspec'], ':')) !== false) { $host = substr($dsninfo['hostspec'], 0, $colon_pos); $port = substr($dsninfo['hostspec'], $colon_pos + 1); } else { $host = $dsninfo['hostspec']; $port = null; } } else { // full URL was specified, e.g. 'ldaps:// example.com' $host = $dsninfo['hostspec']; $port = null; } ?> I have modified my own copy of DB/ldap.php and it appears to work properly.

Comments

 [2008-03-24 20:33 UTC] dufuz (Helgi Þormar Þorbjörnsson)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/DB_ldap Given this hostspec splitting business was removed from the latest release then I bet using ldaps will work perfectly.