From 7e2012ddb4d9a83c4fb08edce2115c6089dcf41f Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Tue, 12 Apr 2022 15:39:57 +0200
Subject: [PATCH] Add some fallbacks in case of missing attributes

We don't allow null here sothings would fail if the attribute is missing
in LDAP.
---
 src/Service/LDAPApi.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Service/LDAPApi.php b/src/Service/LDAPApi.php
index cac8b9e..07d2371 100644
--- a/src/Service/LDAPApi.php
+++ b/src/Service/LDAPApi.php
@@ -264,12 +264,12 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
 //        $this->dispatcher->dispatch($preEvent, PersonFromUserItemPreEvent::NAME);
 //        $user = $preEvent->getUser();
 
-        $identifier = $user->getFirstAttribute($this->identifierAttributeName);
+        $identifier = $user->getFirstAttribute($this->identifierAttributeName) ?? '';
 
         $person = new Person();
         $person->setIdentifier($identifier);
-        $person->setGivenName($user->getFirstAttribute($this->givenNameAttributeName));
-        $person->setFamilyName($user->getFirstAttribute($this->familyNameAttributeName));
+        $person->setGivenName($user->getFirstAttribute($this->givenNameAttributeName) ?? '');
+        $person->setFamilyName($user->getFirstAttribute($this->familyNameAttributeName) ?? '');
 
         if ($this->emailAttributeName !== '') {
             $person->setEmail($user->getFirstAttribute($this->emailAttributeName) ?? '');
-- 
GitLab