Merge pull request #50 from grvsmth/abg_user_not_found
Friendlier error if user is not found in LDAP
This commit is contained in:
commit
930b007e07
|
@ -0,0 +1,4 @@
|
||||||
|
config_init.sh
|
||||||
|
config_ldap.php
|
||||||
|
config_db.php
|
||||||
|
|
|
@ -115,8 +115,10 @@ class LDAP implements LDAPInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = ldap_first_entry($this->ldap_server, $result);
|
$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);
|
$dn = ldap_get_dn($this->ldap_server, $data);
|
||||||
if (!$dn) {
|
if (!$dn) {
|
||||||
|
|
|
@ -73,7 +73,17 @@ try {
|
||||||
// Below is the old version, still consistent with Mattermost before version 4.4
|
// 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']);
|
// $resp = array("name" => $data['cn'],"username" => $user,"id" => $assoc_id,"state" => "active","email" => $data['mail']);
|
||||||
} catch (Exception $e) {
|
} 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
|
// send data or error message in JSON format
|
||||||
|
|
Loading…
Reference in New Issue