diff --git a/oauth/LDAP/LDAP.php b/oauth/LDAP/LDAP.php index d9f79b8..42ed2fc 100755 --- a/oauth/LDAP/LDAP.php +++ b/oauth/LDAP/LDAP.php @@ -134,7 +134,7 @@ 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.'); + 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 b083bb8..bd131d8 100755 --- a/oauth/resource.php +++ b/oauth/resource.php @@ -86,7 +86,17 @@ try } 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