Commit e664af68 authored by John Kelsh's avatar John Kelsh Committed by Gerrit Code Review
Browse files

LDAP support for LDAP URLs with non-standard ports



Bug 1215190

Change-Id: I9cc40f1a528bd92398b16df833fcaf8aaf314ff7
Signed-off-by: Aaron Wells's avatarAaron Wells <aaronw@catalyst.net.nz>
parent 2e97b3db
......@@ -249,13 +249,22 @@ class AuthLdap extends Auth {
continue;
}
$lastcolon = strrpos($server, ":");
if ($lastcolon !== FALSE && preg_match('/^([0-9]+)$/', $port = substr($server, $lastcolon + 1))) {
$server = substr($server, 0, $lastcolon);
$connresult = ldap_connect($server, $port);
// If ldap_connect's first argument has a protocol (ldap://, ldaps://, ldapi://, etc)
// in front of it, it ignores the second argument.
if (preg_match('#^[a-z]+://#i', $server)) {
$connresult = ldap_connect($server);
}
// ... but if ldap_connect's first argument doesn't have a protocol, the port number
// needs to be sent separately, as the second argument
else {
$connresult = ldap_connect($server);
$lastcolon = strrpos($server, ":");
if ($lastcolon !== FALSE && preg_match('/^([0-9]+)$/', $port = substr($server, $lastcolon + 1))) {
$server = substr($server, 0, $lastcolon);
$connresult = ldap_connect($server, $port);
}
else {
$connresult = ldap_connect($server);
}
}
// ldap_connect returns ALWAYS true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment