1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-27 06:58:17 +01:00

Added support for STARTTLS with LDAP

New config value 'ldap.start-tls' (defaults to false) for STARTTLS
support over LDAP
This commit is contained in:
Tristan Pemble 2013-01-11 16:04:18 -05:00 committed by epriestley
parent da6296a176
commit c7c25e141a
2 changed files with 14 additions and 0 deletions

View file

@ -712,6 +712,9 @@ return array(
// The password of the LDAP anonymous user. // The password of the LDAP anonymous user.
'ldap.anonymous-user-password' => null, 'ldap.anonymous-user-password' => null,
// Whether to use STARTTLS
'ldap.start-tls' => false,
// -- Disqus OAuth ---------------------------------------------------------- // // -- Disqus OAuth ---------------------------------------------------------- //

View file

@ -50,6 +50,10 @@ final class PhabricatorLDAPProvider {
return PhabricatorEnv::getEnvConfig('ldap.referrals'); return PhabricatorEnv::getEnvConfig('ldap.referrals');
} }
public function getLDAPStartTLS() {
return PhabricatorEnv::getEnvConfig('ldap.start-tls');
}
public function bindAnonymousUserEnabled() { public function bindAnonymousUserEnabled() {
return strlen(trim($this->getAnonymousUserName())) > 0; return strlen(trim($this->getAnonymousUserName())) > 0;
} }
@ -114,6 +118,13 @@ final class PhabricatorLDAPProvider {
$this->getLDAPVersion()); $this->getLDAPVersion());
ldap_set_option($this->connection, LDAP_OPT_REFERRALS, ldap_set_option($this->connection, LDAP_OPT_REFERRALS,
$this->getLDAPReferrals()); $this->getLDAPReferrals());
if ($this->getLDAPStartTLS()) {
if (!ldap_start_tls($this->getConnection())) {
throw new Exception('Unabled to initialize STARTTLS for LDAP host at '.
$this->getHostname().':'.$this->getPort());
}
}
} }
return $this->connection; return $this->connection;