From 3d572923fecb47b92d585f4b518ba17f3bdfa7e2 Mon Sep 17 00:00:00 2001
From: Jean-Philippe Metivier <jean-philippe.metivier@unicaen.fr>
Date: Fri, 12 Jan 2024 09:38:14 +0100
Subject: [PATCH] =?UTF-8?q?Ajustement=20de=20la=20m=C3=A9thode=20de=20rech?=
 =?UTF-8?q?erche?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Entity/LdapIndividu.php                           | 10 +++++-----
 .../Service/LdapService.php                           | 11 ++++++++---
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/UnicaenUtilisateurLdapAdapter/Entity/LdapIndividu.php b/src/UnicaenUtilisateurLdapAdapter/Entity/LdapIndividu.php
index 57c0d44..028ad8a 100644
--- a/src/UnicaenUtilisateurLdapAdapter/Entity/LdapIndividu.php
+++ b/src/UnicaenUtilisateurLdapAdapter/Entity/LdapIndividu.php
@@ -31,23 +31,23 @@ class LdapIndividu implements RechercheIndividuResultatInterface
 
     public function getId()
     {
-        return $this->people->getId();
+        return $this->people['uid'];
     }
 
     public function getUsername(string $attribut = "supannAliasLogin")
     {
-        return $this->people->get('supannAliasLogin');
+        return $this->people[$attribut];
     }
 
     public function getDisplayname()
     {
-        $tmp_name = $this->people->get('sn');
+        $tmp_name = $this->people['displayName'];
         if (!is_string($tmp_name)) $tmp_name = implode("-", $this->people->get('sn'));
-        return $tmp_name . " " . $this->people->get('givenName');
+        return $tmp_name; //$tmp_name . " " . $this->people->get('givenName');
     }
 
     public function getEmail()
     {
-        return $this->people->get('mail');
+        return $this->people['mail'];
     }
 }
\ No newline at end of file
diff --git a/src/UnicaenUtilisateurLdapAdapter/Service/LdapService.php b/src/UnicaenUtilisateurLdapAdapter/Service/LdapService.php
index daf74df..054d3f7 100644
--- a/src/UnicaenUtilisateurLdapAdapter/Service/LdapService.php
+++ b/src/UnicaenUtilisateurLdapAdapter/Service/LdapService.php
@@ -22,13 +22,17 @@ class LdapService implements RechercheIndividuServiceInterface
      */
     public function findById($id)
     {
+        $filter = PeopleFilter::uid($id);
         /**
          * @var PeopleEntity $people
          */
-        $people = $this->ldapPeopleService->get($id);
 
+        /** TODO retirer ce contournement une fois le problème compris */
+//        $people = $this->ldapPeopleService->get($id);
+        $people = $this->ldapPeopleService->searchAttributes($filter, ['id', 'uid', 'supannaliaslogin', 'supannAliasLogin','displayName', 'mail']);
+        $peep = $people[$id];
         $p = new LdapIndividu();
-        $p->setPeople($people);
+        $p->setPeople($peep);
         return $p;
     }
 
@@ -45,7 +49,8 @@ class LdapService implements RechercheIndividuServiceInterface
         );
         /** @var PeopleService $ldapService */
         try {
-            $people = $this->ldapPeopleService->search($filter);
+            $people = $this->ldapPeopleService->searchAttributes($filter, ['id', 'uid', 'supannaliaslogin', 'supannAliasLogin','displayName', 'mail']);
+//            $people = $this->ldapPeopleService->search($filter);
         } catch (Exception $e) {
             throw new RuntimeException("Un exception ldap est survenue :", $e);
         }
-- 
GitLab