X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/5164375b18f0af6dfb6b3bd35542e40bf2406176..refs/pull/5721/head:/app/Access/LdapService.php diff --git a/app/Access/LdapService.php b/app/Access/LdapService.php index e5037ad2f..0f456efc2 100644 --- a/app/Access/LdapService.php +++ b/app/Access/LdapService.php @@ -112,10 +112,14 @@ class LdapService return null; } - $userCn = $this->getUserResponseProperty($user, 'cn', null); + $nameDefault = $this->getUserResponseProperty($user, 'cn', null); + if (is_null($nameDefault)) { + $nameDefault = ldap_explode_dn($user['dn'], 1)[0] ?? $user['dn']; + } + $formatted = [ 'uid' => $this->getUserResponseProperty($user, $idAttr, $user['dn']), - 'name' => $this->getUserDisplayName($user, $displayNameAttrs, $userCn), + 'name' => $this->getUserDisplayName($user, $displayNameAttrs, $nameDefault), 'dn' => $user['dn'], 'email' => $this->getUserResponseProperty($user, $emailAttr, null), 'avatar' => $thumbnailAttr ? $this->getUserResponseProperty($user, $thumbnailAttr, null) : null,