1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Allow custom LDAP port

Summary: Allow custom LDAP port to be defined in config file

Test Plan: Test login works by specifying a custom port

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3153
This commit is contained in:
Danny Su 2012-08-05 18:11:45 -04:00 committed by epriestley
parent ed8881784e
commit 92fd606df3
2 changed files with 15 additions and 8 deletions

View file

@ -627,6 +627,9 @@ return array(
// The LDAP server hostname
'ldap.hostname' => '',
// The LDAP server port
'ldap.port' => 389,
// The LDAP base domain name
'ldap.base_dn' => '',

View file

@ -42,6 +42,10 @@ final class PhabricatorLDAPProvider {
return PhabricatorEnv::getEnvConfig('ldap.hostname');
}
public function getPort() {
return PhabricatorEnv::getEnvConfig('ldap.port');
}
public function getBaseDN() {
return PhabricatorEnv::getEnvConfig('ldap.base_dn');
}
@ -78,7 +82,7 @@ final class PhabricatorLDAPProvider {
if (is_array($name_attributes)) {
foreach ($name_attributes AS $attribute) {
if (isset($data[$attribute][0])) {
$real_name .= $data[$attribute][0] . ' ';
$real_name .= $data[$attribute][0].' ';
}
}
@ -100,11 +104,11 @@ final class PhabricatorLDAPProvider {
public function getConnection() {
if (!isset($this->connection)) {
$this->connection = ldap_connect($this->getHostname());
$this->connection = ldap_connect($this->getHostname(), $this->getPort());
if (!$this->connection) {
throw new Exception('Could not connect to LDAP host at ' .
$this->getHostname());
throw new Exception('Could not connect to LDAP host at '.
$this->getHostname().':'.$this->getPort());
}
ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION,
@ -150,7 +154,7 @@ final class PhabricatorLDAPProvider {
PhabricatorEnv::getEnvConfig('ldap.activedirectory_domain');
if ($activeDirectoryDomain) {
$dn = $username . '@' . $activeDirectoryDomain;
$dn = $username.'@'.$activeDirectoryDomain;
} else {
$dn = ldap_sprintf(
'%Q=%s,%Q',
@ -198,7 +202,7 @@ final class PhabricatorLDAPProvider {
}
if ($entries['count'] > 1) {
throw new Exception('Found more then one user with this ' .
throw new Exception('Found more then one user with this '.
$attribute);
}