Added ldap port to gui

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2018-09-09 14:18:38 +00:00
parent 5a96b65ead
commit 4efe39b5f3
4 changed files with 9 additions and 6 deletions

View File

@ -68,6 +68,7 @@ $config['PURGE_BEACON'] = '/var/piler/stat/purge';
$config['ENABLE_LDAP_AUTH'] = 0; $config['ENABLE_LDAP_AUTH'] = 0;
$config['LDAP_HOST'] = 'ldap.yourdomain.com'; $config['LDAP_HOST'] = 'ldap.yourdomain.com';
$config['LDAP_PORT'] = 389;
$config['LDAP_HELPER_DN'] = 'cn=....'; $config['LDAP_HELPER_DN'] = 'cn=....';
$config['LDAP_HELPER_PASSWORD'] = 'xxxxxxx'; $config['LDAP_HELPER_PASSWORD'] = 'xxxxxxx';
$config['LDAP_MAIL_ATTR'] = 'mail'; $config['LDAP_MAIL_ATTR'] = 'mail';

View File

@ -99,6 +99,7 @@ class ModelUserAuth extends Model {
// fallback local auth // fallback local auth
private function checkFallbackLogin($username = '', $password = '', $data = array()) { private function checkFallbackLogin($username = '', $password = '', $data = array()) {
$ok = 0;
$session = Registry::get('session'); $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)); $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_type = '';
$ldap_host = LDAP_HOST; $ldap_host = LDAP_HOST;
$ldap_port = LDAP_PORT;
$ldap_base_dn = LDAP_BASE_DN; $ldap_base_dn = LDAP_BASE_DN;
$ldap_helper_dn = LDAP_HELPER_DN; $ldap_helper_dn = LDAP_HELPER_DN;
$ldap_helper_password = LDAP_HELPER_PASSWORD; $ldap_helper_password = LDAP_HELPER_PASSWORD;
@ -210,7 +212,7 @@ class ModelUserAuth extends Model {
if($ldap_host == '' || $ldap_helper_password == '') { return 0; } 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()) { if($ldap->is_bind_ok()) {
@ -541,7 +543,7 @@ class ModelUserAuth extends Model {
public function increment_failed_login_count($n = 0) { public function increment_failed_login_count($n = 0) {
$session = Registry::get('session'); $session = Registry::get('session');
$n = $session->get('failed_logins') + 1; $n = (int)$session->get('failed_logins') + 1;
$session->set('failed_logins', $n); $session->set('failed_logins', $n);
} }

View File

@ -6,9 +6,9 @@ class LDAP {
private $link; private $link;
private $bind; 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_PROTOCOL_VERSION, 3);
ldap_set_option($this->link, LDAP_OPT_REFERRALS, 0); ldap_set_option($this->link, LDAP_OPT_REFERRALS, 0);

View File

@ -5,12 +5,12 @@ class LDAPDB {
private $driver; private $driver;
public function __construct($driver, $ldaphost, $binddn, $bindpw) { public function __construct($driver, $ldaphost, $ldapport, $binddn, $bindpw) {
if (!@require_once(DIR_DATABASE . $driver . '.php')) { if (!@require_once(DIR_DATABASE . $driver . '.php')) {
exit('Error: Could not load database file ' . $driver . '!'); exit('Error: Could not load database file ' . $driver . '!');
} }
$this->driver = new $driver($ldaphost, $binddn, $bindpw); $this->driver = new $driver($ldaphost, $ldapport, $binddn, $bindpw);
} }