From 2a8eeb57dd8d2751ae099797a0b278afb458f4a9 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 25 Jan 2018 03:09:54 +0000 Subject: [PATCH] www/dbq/dbq.php --- lib/php/ldap.php | 18 ++++++++++-------- www/dbq/dbq.php | 4 +++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/php/ldap.php b/lib/php/ldap.php index 491284ff..7c0ca1ba 100644 --- a/lib/php/ldap.php +++ b/lib/php/ldap.php @@ -4,6 +4,7 @@ require_once(NB_ROOT.'/lib/php/http.php'); class Ldap { +/* public static function _connect(&$o=[]) { $host = '127.0.0.1'; if (preg_match('/^.*?([^\.]+\.[^\.]+)$/',$_SERVER['HTTP_HOST'],$m)) { @@ -112,20 +113,13 @@ class Ldap { } # < ldap_search + */ private $conn; private $host = '127.0.0.1'; private $base; private $user; private $password; - private static function ar_filter_keys($ar,$keys) { - $new = []; - foreach ($keys as $k) { - if (isset($ar[$k])) $new[$k] = $ar[$k]; - } - return $new; - } - public function __construct($opt = []) { foreach ($opt as $k => $v) if ((string)$v !== '') $this->$k = $v; } @@ -136,6 +130,14 @@ class Ldap { public static function bye($msg) { die($msg); } + private static function ar_filter_keys($ar,$keys) { + $new = []; + foreach ($keys as $k) { + if (isset($ar[$k])) $new[$k] = $ar[$k]; + } + return $new; + } + public function conn($exit=true) { if ($this->conn) return $this->conn; if (!$this->conn = @ldap_connect($this->host)) return self::bye("Could not connect to LDAP server"); diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 57a35068..1b521b09 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -172,7 +172,8 @@ class DbQ extends nb { public function page_ldap() { $this->deniedUnless($this->perm >= self::READ); - require_once(NB_ROOT.'/lib/php/ldap.php'); #debug($GLOBALS['DBQ_LDAP']); + require_once(NB_ROOT.'/lib/php/ldap.php'); + #debug($GLOBALS['DBQ_LDAP']); $ldap = new Ldap($GLOBALS['DBQ_LDAP']); if ($this->params['table'] == 'add') { @@ -211,6 +212,7 @@ class DbQ extends nb { } else { $search['filter'] = 'cn='.Http::user(); } + $search['filter'] = '(&('.$search['filter'].')(userPassword=*))'; } $rows = $ldap->search($GLOBALS['DBQ_LDAP'] + $search); -- 2.47.3