diff --git a/oauth/LDAP/LDAP.php b/oauth/LDAP/LDAP.php index 8b7de1c..3d13cfe 100755 --- a/oauth/LDAP/LDAP.php +++ b/oauth/LDAP/LDAP.php @@ -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) { - $attribute=array("cn","mail"); + $attribute=array("cn","mail","displayName"); 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'); @@ -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.'); } - 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]); } /* diff --git a/oauth/resource.php b/oauth/resource.php index b378dd4..f2739b4 100755 --- a/oauth/resource.php +++ b/oauth/resource.php @@ -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. $resp = array( "id" => $assoc_id, - "name" => $data['cn'], + "name" => strlen($data['displayName']) > 0 ? $data['displayName'] : $data['cn'], "username" => $user, "state" => "active", "avatar_url" => "",