diff --git a/README.md b/README.md index 5dc2f83..ff4d4b4 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,13 @@ Logiciel testé et validé sur les configurations suivantes : VERSION ACTUELLE Date: 22/02/2019 -Version: 2.10.17 +Version: 2.10.18 Author: EP - (IRAP ONLY) LDAP refactorisation && optimisation (3) - - LdapConnectionsTable.php/getUserAttributes() simplification (ldap only, not used by fake ldap !!) - - Nouveaux liens "What's New ?" et "Documentation technique" en bas de page web - - LDAP refactor pour ajouter mode LDAP authentifié + LDAP refactorisation && optimisation (4) + - LdapConnectionsTable.php/searchLdap() simplification : + - suppression getUserAttributes() + - suppression getLdap1UserOrAllUsersAttributes() + - LDAP refactor progressif pour remettre le mode LDAP authentifié (pour CRAL) IMPORTANT: - Pour connaitre la version actuelle, taper "./VERSION" diff --git a/src/Model/Table/LdapConnectionsTable.php b/src/Model/Table/LdapConnectionsTable.php index 476916d..027098e 100755 --- a/src/Model/Table/LdapConnectionsTable.php +++ b/src/Model/Table/LdapConnectionsTable.php @@ -6,10 +6,10 @@ namespace App\Model\Table; DONE: - 1) remplacer ldapAuthentication() par ldapAuthenticationNEW() - -TODO: - 2) remplacer getUserAttributes() par getLdap1UserOrAllUsersAttributes() - 3) virer getLdap1UserOrAllUsersAttributes() et merger son code dans la seule fonction qui l'appelle : searchLdap() + +TODO: - 4) getAllLdapUsersNEW() pour remplacer getAllLdapUsers() - TableRegistry::get() à remplacer par TableRegistry::getTableLocator()->get() @@ -337,6 +337,10 @@ class LdapConnectionsTable extends AppTable + /* + CALL + $filter = "(&".$this->filter."(".$this->authenticationType . '=' . $user_login."))"; + */ // REAL LDAP only /* @@ -349,7 +353,7 @@ class LdapConnectionsTable extends AppTable //public function getUserAttributes($userName, $ldapConnection='', $filter='', $just_these=[]) //public function getUserAttributes($ldapConnection='', $filter='', $just_these=[], $userName=NULL) //public function getLdapUsersAttributes($ldapConnection, $filter='', $just_these=[]) - public function getLdap1UserOrAllUsersAttributes($ldapConnection, $filter='', $just_these=[]) + public function getLdap1UserOrAllUsersAttributes($ldapConnection, $user_login, $filter='', $just_these=[]) { try { if ($this->checkConfiguration()) { @@ -381,9 +385,14 @@ class LdapConnectionsTable extends AppTable // NEW: $filter = "(&".$this->filter."(".$this->authenticationType . '=' . $user_login."))"; // OLD à virer - $filter = '(' . $this->authenticationType . '=' . $userName . ')'; + /* + $filter = '(' . $this->authenticationType . '=' . $user_login . ')'; $just_these = []; + $results = ldap_search($ldapConnection, $this->baseDn, $filter); + return ldap_get_entries($ldapConnection, $results); + */ + // $filter = "(&".$this->filter. "(".$this->authenticationType . '=' . $user_login."))"; $results = ldap_search($ldapConnection, $this->baseDn, $filter, $just_these) or die("Could not search to LDAP server response was: " . ldap_error($ldapConnection) ); $res = ldap_get_entries($ldapConnection, $results); @@ -397,7 +406,7 @@ class LdapConnectionsTable extends AppTable } } catch (Exception $e) { - echo 'Exception LDAP : ', $e->getMessage(), "\n"; + //echo 'Exception LDAP : ', $e->getMessage(), "\n"; } return false; @@ -604,9 +613,23 @@ class LdapConnectionsTable extends AppTable if ($ldapbind) { // OLD - $search = $this->getUserAttributes($ldapConnection, $user_login); + //$search = $this->getUserAttributes($ldapConnection, $user_login); // NEW - //$search = $this->getLdap1UserOrAllUsersAttributes($ldapConnection, $filter, $just_these); + //$search = $this->getLdap1UserOrAllUsersAttributes($ldapConnection, $user_login, $filter, $just_these); + + // OLD à virer + /* + $filter = '(' . $this->authenticationType . '=' . $user_login . ')'; + $just_these = []; + $results = ldap_search($ldapConnection, $this->baseDn, $filter); + return ldap_get_entries($ldapConnection, $results); + */ + // $filter = "(&".$this->filter."(".$this->authenticationType . '=' . $user_login."))"; + // ex: (&(compteinfo=Oui)(uid=epallier)) + $results = ldap_search($ldapConnection, $this->baseDn, $filter, $just_these) + or die("Could not search to LDAP server response was: " . ldap_error($ldapConnection) ); + $search = ldap_get_entries($ldapConnection, $results); + //echo $info["count"]." entries returned\n"; if ($search === FALSE) die("Could not get user attributes from LDAP server, response was: " . ldap_error($ldapConnection) ); //return $search[0]; -- libgit2 0.21.2