From: Nicolas Boisselier Date: Thu, 25 Jan 2018 05:29:22 +0000 (+0000) Subject: lib/php/ldap.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=41a378076722e43e03e1d48604ab0fb8c3c35ecd;p=nb.git lib/php/ldap.php --- diff --git a/lib/php/ldap.php b/lib/php/ldap.php index 7c0ca1ba..91997970 100644 --- a/lib/php/ldap.php +++ b/lib/php/ldap.php @@ -158,11 +158,14 @@ class Ldap { $conn = $this->conn(); + if (!isset($o['dn'])) $o['dn'] = true; + if (!isset($o['base'])) $o['base'] = null; +# NB 25.01.18 if (!isset($o['filter'])) $o['filter'] = null; + if (!isset($o['filter'])) $o = array_merge($o,[ 'filter' => 'objectClass=*', 'attrs' => ['dn','objectClass'], 'dn' => true ]); if (!isset($o['attrs'])) $o['attrs'] = []; + if (!is_array($o['attrs'])) $o['attrs'] = [$o['attrs']]; if (!isset($o['limit'])) $o['limit'] = 0; - if (!isset($o['base'])) $o['base'] = null; - if (!isset($o['filter'])) $o['filter'] = null; - $read = ldap_search($conn, $o['base'], $o['filter'], $o['attrs'], $o['limit']) or self::bye("Unable to search ldap server"); + $read = ldap_search($conn, $o['base'], $o['filter'], $o['attrs'], 0, $o['limit']) or self::bye("Unable to search ldap server"); # ldap_get_entries is shite !! It does not workds with binary datas, put all attrs in lower case $info = []; @@ -204,6 +207,14 @@ class Ldap { public function delete($dn) { return ldap_delete($this->conn(), $dn); + /* + foreach ($ldap->search([ + 'base' => $this->user, + 'filter' => 'ObjectClass=*', + ]) as $row) { + #$this->delete($dn); + } + */ } }