]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 25 Jan 2018 03:09:54 +0000 (03:09 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 25 Jan 2018 03:09:54 +0000 (03:09 +0000)
lib/php/ldap.php
www/dbq/dbq.php

index 491284ffd49cdfc38760fb070662498d30ecaa23..7c0ca1ba3d5924f518815edcac705d22af9625a6 100644 (file)
@@ -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");
index 57a350684128e4e89ca58f507ab7cfa4be86f191..1b521b095df52082be9c8e99b297461c6221eacb 100644 (file)
@@ -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);