PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_ldap » Bug #1057

Port is not used

Details

Submitted2004-03-22 23:40 UTC
Fromtdr32 at cs dot byu dot edu
Assignedludoo
StatusClosed
PackageDB_ldap
PHP Version4.2.2
OSLinux
Roadmaps(Not assigned)

Comments

[2004-03-22 23:40 UTC] tdr32 at cs dot byu dot edu

Description:
------------
The DB package has a port variable to be passed in. But the DB_ldap package doesn't use this port variable. So, when I try to access my database (which needs a port), it tells me that connection failed. I think all it needs is a slight change in the construction method so that it takes in consideration a port number that is passed.

[2004-05-20 17:01 UTC] aaron dot hawley at uvm dot edu

http://www.uvm.edu/~ashawley/php/ldap.php-bug1057.diff-u

1.9 2002/02/11 12:59:37
--- ldap.php 2002-02-11 12:59:37 1.9
+++ ldap.php 2004-05-20 13:03:55-04
@@ -23,7 +23,7 @@
// - Piotr Roszatycki <Piotr_Roszatycki@netia.net.pl>
// DB_ldap::base() method, support for LDAP sequences, various fixes
//
-// $Id: ldap.php,v 1.1 2004-05-20 12:30:14-04 ashawley Exp $
+// $Id: ldap.php,v 1.1 2004-05-20 12:30:14-04 ashawley Exp ashawley $
//

require_once 'DB/common.php';
@@ -365,13 +365,23 @@
$this->dsn = $dsninfo;
$user = $dsninfo['username'];
$pw = $dsninfo['password'];
- $host = $dsninfo['hostspec'];
+ 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;
+ }
$this->base = $dsninfo['database'];

- if ($host) {
- $conn = ldap_connect($host);
+ if (empty($host)) {
+ return $this->raiseError("no host specified $host");
+ } // else ...
+
+ if (isset($port)) {
+ $conn = ldap_connect($host, $port);
} else {
- return $this->raiseError("unknown host $host");
+ $conn = ldap_connect($host);
}
if (!$conn) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED);

[2004-05-20 17:04 UTC] aaron dot hawley at uvm dot edu

This patch is against the 1.0 release of DB_Ldap

Ignore the "1.9" jumble

[2004-11-26 10:01 UTC] rafael at krysciak dot de

This patch do not work. The var $dsninfo['hostspec'] does not contain the port number.
For example:
print_r(DB::parseDSN("ldap://localhost:3891"));
// output:
Array
(
[phptype] => ldap
[dbsyntax] => ldap
[username] =>
[password] =>
[protocol] => tcp
[hostspec] => localhost
[port] => 3891
[socket] =>
[database] =>
)

The port number is in the $dsninfo['port'] key.

--- PROPOSED FIX ---

$user = $dsninfo['username'];
$pw = $dsninfo['password'];
- 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;
- }
+ $host = $dsninfo['hostspec'];
+ $port = $dsninfo['port'];