Using displayName instead of cn for Full Name

This commit is contained in:
Sen Manho 2022-05-18 23:16:32 +09:00
parent 7a0d14f23d
commit 2a775074b9
2 changed files with 5 additions and 3 deletions

View File

@ -154,7 +154,7 @@ class LDAP implements LDAPInterface
*/ */
public function getDataForMattermost($ldap_base_dn, $ldap_filter, $ldap_bind_dn, $ldap_bind_pass, $ldap_search_attribute, $user) public function getDataForMattermost($ldap_base_dn, $ldap_filter, $ldap_bind_dn, $ldap_bind_pass, $ldap_search_attribute, $user)
{ {
$attribute=array("cn","mail"); $attribute=array("cn","mail","displayName");
if (!is_string($ldap_base_dn)) { if (!is_string($ldap_base_dn)) {
throw new InvalidArgumentException('First argument to LDAP/getData must be the ldap base directory name (string). Ex: o=Company'); throw new InvalidArgumentException('First argument to LDAP/getData must be the ldap base directory name (string). Ex: o=Company');
@ -212,7 +212,9 @@ class LDAP implements LDAPInterface
throw new Exception('An error has occured during ldap_get_values execution (complete name). Please check parameter of LDAP/getData.'); throw new Exception('An error has occured during ldap_get_values execution (complete name). Please check parameter of LDAP/getData.');
} }
return array("mail" => $mail[0], "cn" => $cn[0]); $displayName = ldap_get_values($this->ldap_server, $data, "displayName");
return array("mail" => $mail[0], "cn" => $cn[0], "displayName" => $displayName[0]);
} }
/* /*

View File

@ -36,7 +36,7 @@ try {
// Here is the patch for Mattermost 4.4 and newer. Gitlab has changed the JSON output of oauth service. Many data are not used by Mattermost, but there is a stack error if we delete them. That's the reason why date and many parameters are null or empty. // Here is the patch for Mattermost 4.4 and newer. Gitlab has changed the JSON output of oauth service. Many data are not used by Mattermost, but there is a stack error if we delete them. That's the reason why date and many parameters are null or empty.
$resp = array( $resp = array(
"id" => $assoc_id, "id" => $assoc_id,
"name" => $data['cn'], "name" => strlen($data['displayName']) > 0 ? $data['displayName'] : $data['cn'],
"username" => $user, "username" => $user,
"state" => "active", "state" => "active",
"avatar_url" => "", "avatar_url" => "",