Commit 2a6a6d623c2f40edf366493d4cd4a90428db8eec
1 parent
75a95155
Exists in
master
and in
2 other branches
LDAP refactorisation && optimisation (4)
- LdapConnectionsTable.php/searchLdap() simplification : - suppression getUserAttributes() - suppression getLdap1UserOrAllUsersAttributes() - LDAP refactor progressif pour remettre mode LDAP authentifié (pour CRAL)
Showing
2 changed files
with
36 additions
and
12 deletions
Show diff stats
README.md
... | ... | @@ -54,12 +54,13 @@ Logiciel testé et validé sur les configurations suivantes : |
54 | 54 | VERSION ACTUELLE |
55 | 55 | |
56 | 56 | Date: 22/02/2019 |
57 | -Version: 2.10.17 | |
57 | +Version: 2.10.18 | |
58 | 58 | Author: EP |
59 | - (IRAP ONLY) LDAP refactorisation && optimisation (3) | |
60 | - - LdapConnectionsTable.php/getUserAttributes() simplification (ldap only, not used by fake ldap !!) | |
61 | - - Nouveaux liens "What's New ?" et "Documentation technique" en bas de page web | |
62 | - - LDAP refactor pour ajouter mode LDAP authentifié | |
59 | + LDAP refactorisation && optimisation (4) | |
60 | + - LdapConnectionsTable.php/searchLdap() simplification : | |
61 | + - suppression getUserAttributes() | |
62 | + - suppression getLdap1UserOrAllUsersAttributes() | |
63 | + - LDAP refactor progressif pour remettre le mode LDAP authentifié (pour CRAL) | |
63 | 64 | |
64 | 65 | IMPORTANT: |
65 | 66 | - Pour connaitre la version actuelle, taper "./VERSION" | ... | ... |
src/Model/Table/LdapConnectionsTable.php
... | ... | @@ -6,10 +6,10 @@ namespace App\Model\Table; |
6 | 6 | |
7 | 7 | DONE: |
8 | 8 | - 1) remplacer ldapAuthentication() par ldapAuthenticationNEW() |
9 | - | |
10 | -TODO: | |
11 | 9 | - 2) remplacer getUserAttributes() par getLdap1UserOrAllUsersAttributes() |
12 | 10 | - 3) virer getLdap1UserOrAllUsersAttributes() et merger son code dans la seule fonction qui l'appelle : searchLdap() |
11 | + | |
12 | +TODO: | |
13 | 13 | - 4) getAllLdapUsersNEW() pour remplacer getAllLdapUsers() |
14 | 14 | - TableRegistry::get() à remplacer par TableRegistry::getTableLocator()->get() |
15 | 15 | |
... | ... | @@ -337,6 +337,10 @@ class LdapConnectionsTable extends AppTable |
337 | 337 | |
338 | 338 | |
339 | 339 | |
340 | + /* | |
341 | + CALL | |
342 | + $filter = "(&".$this->filter."(".$this->authenticationType . '=' . $user_login."))"; | |
343 | + */ | |
340 | 344 | |
341 | 345 | // REAL LDAP only |
342 | 346 | /* |
... | ... | @@ -349,7 +353,7 @@ class LdapConnectionsTable extends AppTable |
349 | 353 | //public function getUserAttributes($userName, $ldapConnection='', $filter='', $just_these=[]) |
350 | 354 | //public function getUserAttributes($ldapConnection='', $filter='', $just_these=[], $userName=NULL) |
351 | 355 | //public function getLdapUsersAttributes($ldapConnection, $filter='', $just_these=[]) |
352 | - public function getLdap1UserOrAllUsersAttributes($ldapConnection, $filter='', $just_these=[]) | |
356 | + public function getLdap1UserOrAllUsersAttributes($ldapConnection, $user_login, $filter='', $just_these=[]) | |
353 | 357 | { |
354 | 358 | try { |
355 | 359 | if ($this->checkConfiguration()) { |
... | ... | @@ -381,9 +385,14 @@ class LdapConnectionsTable extends AppTable |
381 | 385 | // NEW: $filter = "(&".$this->filter."(".$this->authenticationType . '=' . $user_login."))"; |
382 | 386 | |
383 | 387 | // OLD à virer |
384 | - $filter = '(' . $this->authenticationType . '=' . $userName . ')'; | |
388 | + /* | |
389 | + $filter = '(' . $this->authenticationType . '=' . $user_login . ')'; | |
385 | 390 | $just_these = []; |
391 | + $results = ldap_search($ldapConnection, $this->baseDn, $filter); | |
392 | + return ldap_get_entries($ldapConnection, $results); | |
393 | + */ | |
386 | 394 | |
395 | + // $filter = "(&".$this->filter. "(".$this->authenticationType . '=' . $user_login."))"; | |
387 | 396 | $results = ldap_search($ldapConnection, $this->baseDn, $filter, $just_these) |
388 | 397 | or die("Could not search to LDAP server response was: " . ldap_error($ldapConnection) ); |
389 | 398 | $res = ldap_get_entries($ldapConnection, $results); |
... | ... | @@ -397,7 +406,7 @@ class LdapConnectionsTable extends AppTable |
397 | 406 | |
398 | 407 | } |
399 | 408 | } catch (Exception $e) { |
400 | - echo 'Exception LDAP : ', $e->getMessage(), "\n"; | |
409 | + //echo 'Exception LDAP : ', $e->getMessage(), "\n"; | |
401 | 410 | } |
402 | 411 | |
403 | 412 | return false; |
... | ... | @@ -604,9 +613,23 @@ class LdapConnectionsTable extends AppTable |
604 | 613 | if ($ldapbind) { |
605 | 614 | |
606 | 615 | // OLD |
607 | - $search = $this->getUserAttributes($ldapConnection, $user_login); | |
616 | + //$search = $this->getUserAttributes($ldapConnection, $user_login); | |
608 | 617 | // NEW |
609 | - //$search = $this->getLdap1UserOrAllUsersAttributes($ldapConnection, $filter, $just_these); | |
618 | + //$search = $this->getLdap1UserOrAllUsersAttributes($ldapConnection, $user_login, $filter, $just_these); | |
619 | + | |
620 | + // OLD à virer | |
621 | + /* | |
622 | + $filter = '(' . $this->authenticationType . '=' . $user_login . ')'; | |
623 | + $just_these = []; | |
624 | + $results = ldap_search($ldapConnection, $this->baseDn, $filter); | |
625 | + return ldap_get_entries($ldapConnection, $results); | |
626 | + */ | |
627 | + // $filter = "(&".$this->filter."(".$this->authenticationType . '=' . $user_login."))"; | |
628 | + // ex: (&(compteinfo=Oui)(uid=epallier)) | |
629 | + $results = ldap_search($ldapConnection, $this->baseDn, $filter, $just_these) | |
630 | + or die("Could not search to LDAP server response was: " . ldap_error($ldapConnection) ); | |
631 | + $search = ldap_get_entries($ldapConnection, $results); | |
632 | + //echo $info["count"]." entries returned\n"; | |
610 | 633 | |
611 | 634 | if ($search === FALSE) die("Could not get user attributes from LDAP server, response was: " . ldap_error($ldapConnection) ); |
612 | 635 | //return $search[0]; | ... | ... |