Handle instance where user is not found in LDAP more gracefully
This commit is contained in:
parent
f46d2f7802
commit
e34253faf8
|
@ -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)
|
||||
|
|
|
@ -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" => "<b>$user</b> 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
|
||||
|
|
Loading…
Reference in New Issue