forked from services/mlmmj-light-web-ecg
Added error handling of missing ldap server connection and audit message for failed login
This commit is contained in:
20
login.php
20
login.php
@@ -18,7 +18,20 @@ if (!empty($login_username) && !empty($login_pass))
|
|||||||
$ldap_server = "localhost";
|
$ldap_server = "localhost";
|
||||||
$ldap_port = 30389;
|
$ldap_port = 30389;
|
||||||
|
|
||||||
$connect = ldap_connect($ldap_server, $ldap_port); #or die("Failed to connect to the LDAP server.");
|
$connect = ldap_connect($ldap_server, $ldap_port);
|
||||||
|
if (!$connect)
|
||||||
|
{
|
||||||
|
# If debug mode is on show error message
|
||||||
|
if ($debug)
|
||||||
|
{
|
||||||
|
echo "Failed to connect to the LDAP server.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shell_exec('curl -X POST -H \'Content-Type: application/json\' --data \'{"alias":"ECG Notification Bot","emoji":":ghost:","text":"Failed to connect to the LDAP server."}\' https://chat.ecogood.org/hooks/A' . $rc_webhook);
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
|
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
|
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
|
||||||
@@ -26,7 +39,7 @@ if (!empty($login_username) && !empty($login_pass))
|
|||||||
# bind user
|
# bind user
|
||||||
$auth_user = "uid=" . $login_username . ",ou=users,ou=ecg";
|
$auth_user = "uid=" . $login_username . ",ou=users,ou=ecg";
|
||||||
$auth_pass = $login_pass;
|
$auth_pass = $login_pass;
|
||||||
$bind = ldap_bind($connect, $auth_user, $auth_pass); #or die("Failed to bind to LDAP server.");
|
$bind = ldap_bind($connect, $auth_user, $auth_pass);
|
||||||
|
|
||||||
# If the bind was successfull
|
# If the bind was successfull
|
||||||
if ($bind)
|
if ($bind)
|
||||||
@@ -62,6 +75,9 @@ if (!empty($login_username) && !empty($login_pass))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
# Send audit message on failed login
|
||||||
|
shell_exec('curl -X POST -H \'Content-Type: application/json\' --data \'{"alias":"ECG Notification Bot","emoji":":ghost:","text":"Login failed: ' . $login_username . ' (' . $_SERVER["REMOTE_ADDR"] . ')"}\' https://chat.ecogood.org/hooks/' . $rc_webhook);
|
||||||
|
|
||||||
// Incorrect password
|
// Incorrect password
|
||||||
$_SESSION["error_code"] = 3;
|
$_SESSION["error_code"] = 3;
|
||||||
header("Location: error.php");
|
header("Location: error.php");
|
||||||
|
|||||||
Reference in New Issue
Block a user