diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86e46b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +config_init.sh +config_ldap.php +config_db.php + diff --git a/oauth/LDAP/LDAP.php b/oauth/LDAP/LDAP.php index d2c5e49..8fbb941 100755 --- a/oauth/LDAP/LDAP.php +++ b/oauth/LDAP/LDAP.php @@ -115,8 +115,10 @@ class LDAP implements LDAPInterface } $data = ldap_first_entry($this->ldap_server, $result); - if (!$data) { - throw new Exception('An error has occured during ldap_first_entry execution. Please check parameter of LDAP/checkLogin.'); + + if (!$data) + { + throw new Exception('No result from LDAP server', 404); } $dn = ldap_get_dn($this->ldap_server, $data); if (!$dn) { diff --git a/oauth/resource.php b/oauth/resource.php index 8cdd113..762c105 100755 --- a/oauth/resource.php +++ b/oauth/resource.php @@ -73,7 +73,17 @@ try { // Below is the old version, still consistent with Mattermost before version 4.4 // $resp = array("name" => $data['cn'],"username" => $user,"id" => $assoc_id,"state" => "active","email" => $data['mail']); } catch (Exception $e) { - $resp = array("error" => "Impossible to get data", "message" => $e->getMessage()); + if ($e->getCode() == 404) { + $resp = [ + "error" => "User not found", + "message" => "$user is not in the group of authorized users." + ]; + } else { + $resp = array( + "error" => "Impossible to get data", + "message" => $e->getMessage() + ); + } } // send data or error message in JSON format