NOW MANAGED ON CODEBERG
Issue #1306 - Specify display name attribute from LDAP
Daniel Fanara55b07c7076d3
diff --git a/app/Auth/Access/LdapService.php b/app/Auth/Access/LdapService.phpindex 654ea2f99..c8548b98a 100644--- a/app/Auth/Access/LdapService.php+++ b/app/Auth/Access/LdapService.php@@ -80,7 +80,9 @@ class LdapServicepublic function getUserDetails($userName){$emailAttr = $this->config['email_attribute'];- $user = $this->getUserWithAttributes($userName, ['cn', 'uid', 'dn', $emailAttr]);+ $displayNameAttr = $this->config['display_name_attribute'];++ $user = $this->getUserWithAttributes($userName, ['cn', 'uid', 'dn', $emailAttr, $displayNameAttr]);if ($user === null) {return null;@@ -88,7 +90,7 @@ class LdapServicereturn ['uid' => (isset($user['uid'])) ? $user['uid'][0] : $user['dn'],- 'name' => $user['cn'][0],+ 'name' => (isset($uset[$displayNameAttr])) ? (is_array($user[$displayNameAttr]) ? $user[$displayNameAttr][0] : $user[$displayNameAttr]) : $user['cn'][0],'dn' => $user['dn'],'email' => (isset($user[$emailAttr])) ? (is_array($user[$emailAttr]) ? $user[$emailAttr][0] : $user[$emailAttr]) : null];diff --git a/config/services.php b/config/services.phpindex f713f9d38..97cb71ddc 100644--- a/config/services.php+++ b/config/services.php@@ -141,6 +141,7 @@ return ['user_filter' => env('LDAP_USER_FILTER', '(&(uid=${user}))'),'version' => env('LDAP_VERSION', false),'email_attribute' => env('LDAP_EMAIL_ATTRIBUTE', 'mail'),+ 'display_name_attribute' => env('LDAP_DISPLAY_NAME_ATTRIBUTE', 'cn'),'follow_referrals' => env('LDAP_FOLLOW_REFERRALS', false),'user_to_groups' => env('LDAP_USER_TO_GROUPS',false),'group_attribute' => env('LDAP_GROUP_ATTRIBUTE', 'memberOf'),