diff --git a/config.php.in b/config.php.in index 89a5c25d..b557a4df 100644 --- a/config.php.in +++ b/config.php.in @@ -68,6 +68,7 @@ $config['PURGE_BEACON'] = '/var/piler/stat/purge'; $config['ENABLE_LDAP_AUTH'] = 0; $config['LDAP_HOST'] = 'ldap.yourdomain.com'; +$config['LDAP_PORT'] = 389; $config['LDAP_HELPER_DN'] = 'cn=....'; $config['LDAP_HELPER_PASSWORD'] = 'xxxxxxx'; $config['LDAP_MAIL_ATTR'] = 'mail'; diff --git a/webui/model/user/auth.php b/webui/model/user/auth.php index a0bf285b..3e11ced9 100644 --- a/webui/model/user/auth.php +++ b/webui/model/user/auth.php @@ -99,6 +99,7 @@ class ModelUserAuth extends Model { // fallback local auth private function checkFallbackLogin($username = '', $password = '', $data = array()) { + $ok = 0; $session = Registry::get('session'); $query = $this->db->query("SELECT u.username, u.uid, u.realname, u.dn, u.password, u.isadmin, u.domain FROM " . TABLE_USER . " u, " . TABLE_EMAIL . " e WHERE e.email=? AND e.uid=u.uid", array($username)); @@ -179,6 +180,7 @@ class ModelUserAuth extends Model { $ldap_type = ''; $ldap_host = LDAP_HOST; + $ldap_port = LDAP_PORT; $ldap_base_dn = LDAP_BASE_DN; $ldap_helper_dn = LDAP_HELPER_DN; $ldap_helper_password = LDAP_HELPER_PASSWORD; @@ -210,7 +212,7 @@ class ModelUserAuth extends Model { if($ldap_host == '' || $ldap_helper_password == '') { return 0; } - $ldap = new LDAP($ldap_host, $ldap_helper_dn, $ldap_helper_password); + $ldap = new LDAP($ldap_host, $ldap_port, $ldap_helper_dn, $ldap_helper_password); if($ldap->is_bind_ok()) { @@ -541,7 +543,7 @@ class ModelUserAuth extends Model { public function increment_failed_login_count($n = 0) { $session = Registry::get('session'); - $n = $session->get('failed_logins') + 1; + $n = (int)$session->get('failed_logins') + 1; $session->set('failed_logins', $n); } diff --git a/webui/system/database/ldap.php b/webui/system/database/ldap.php index 49f30ff6..83ebf50f 100644 --- a/webui/system/database/ldap.php +++ b/webui/system/database/ldap.php @@ -6,9 +6,9 @@ class LDAP { private $link; private $bind; - public function __construct($ldaphost, $binddn, $bindpw) { + public function __construct($ldaphost, $ldapport, $binddn, $bindpw) { - $this->link = ldap_connect($ldaphost) or exit('Error: ldap_connect()'); + $this->link = ldap_connect($ldaphost, $ldapport) or exit('Error: ldap_connect()'); ldap_set_option($this->link, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($this->link, LDAP_OPT_REFERRALS, 0); diff --git a/webui/system/ldap.php b/webui/system/ldap.php index bd04105a..83381abc 100644 --- a/webui/system/ldap.php +++ b/webui/system/ldap.php @@ -5,12 +5,12 @@ class LDAPDB { private $driver; - public function __construct($driver, $ldaphost, $binddn, $bindpw) { + public function __construct($driver, $ldaphost, $ldapport, $binddn, $bindpw) { if (!@require_once(DIR_DATABASE . $driver . '.php')) { exit('Error: Could not load database file ' . $driver . '!'); } - $this->driver = new $driver($ldaphost, $binddn, $bindpw); + $this->driver = new $driver($ldaphost, $ldapport, $binddn, $bindpw); }