Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,20 +700,17 @@ public function connect($host = null, $port = null, $useSsl = null, $useStartTls
throw new Exception\LdapException(null, 'A host parameter is required');
}

$useUri = false;
/* Because ldap_connect doesn't really try to connect, any connect error
* will actually occur during the ldap_bind call. Therefore, we save the
* connect string here for reporting it in error handling in bind().
*/
$hosts = [];
if (preg_match_all('~ldap(?:i|s)?://~', $host, $hosts, PREG_SET_ORDER) > 0) {
$this->connectString = $host;
$useUri = true;
$useSsl = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heiglandreas
I leaved this assignment untouched for now, but should we recognize $useSsl here depending on schema? I mean ldaps:// should switch $useSsl to true, shouldn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good catch! Would you add that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

} else {
if ($useSsl) {
$this->connectString = 'ldaps://' . $host;
$useUri = true;
} else {
$this->connectString = 'ldap://' . $host;
}
Expand All @@ -724,12 +721,9 @@ public function connect($host = null, $port = null, $useSsl = null, $useStartTls

$this->disconnect();


/* Only OpenLDAP 2.2 + supports URLs so if SSL is not requested, just
* use the old form.
*/
// We supporting here only OpenLDAP 2.2 + which supports URLs (drop support of old-style host/port connections).
ErrorHandler::start();
$resource = ($useUri) ? ldap_connect($this->connectString) : ldap_connect($host, $port);
$resource = ldap_connect($this->connectString);
ErrorHandler::stop();

if (is_resource($resource) === true) {
Expand Down