Ejemplo n.º 1
0
 // send mail
 $ldap_dn_search_response = cacti_ldap_search_dn($username, "", "", "", "", "", "", "", "", "", "", "", "", array("mail"));
 if ($ldap_dn_search_response["error_num"] == "0") {
     $message = file_get_contents("./text/deactivate_mail.txt");
     $message = str_replace("%USERNAME%", $username, $message);
     $errors = send_mail($ldap_dn_search_response["mail"]["0"], "", "Resmon acount deactivated", $message);
     if ($errors == "") {
         $caution_msg = "Send mail for account deactivated. Please read mail.";
         cacti_log("SIGNUP: send mail for account deactivated", false, "AUTH");
     }
 }
 // modify ldap, delete sql
 $rnd_hash = hash_hmac("sha256", time() . mt_rand(), FALSE);
 $ldap_dn_add_response = cacti_ldap_mod_dn(2, $username, array(description => "deactivate " . date("c"), mail => $rnd_hash, userPassword => $rnd_hash, pwdLockout => "TRUE"));
 if ($ldap_dn_add_response["error_num"] == "0") {
     $ldap_dn_add_response = cacti_ldap_mod_dn(3, $username);
     if ($ldap_dn_add_response["error_num"] == "0") {
         // notification lists
         db_execute("\r\n                        DELETE plugin_notification_lists FROM plugin_notification_lists \r\n                            INNER JOIN user_auth ON user_auth.id = '" . $_SESSION["sess_user_id"] . "' \r\n                        WHERE plugin_notification_lists.name = CONCAT(user_auth.username,'_alert') OR plugin_notification_lists.name = CONCAT(user_auth.username,'_warning')");
         // thold_data
         db_execute("\r\n                        DELETE thold_data FROM thold_data\r\n                            INNER JOIN host ON thold_data.host_id = host.id\r\n                            INNER JOIN user_auth_perms ON host.id = user_auth_perms.item_id AND user_auth_perms.user_id = '" . $_SESSION["sess_user_id"] . "' AND user_auth_perms.type = '3'");
         // plugin_thold_log
         db_execute("\r\n                        DELETE plugin_thold_log FROM plugin_thold_log\r\n                            INNER JOIN host ON plugin_thold_log.host_id = host.id\r\n                            INNER JOIN user_auth_perms ON host.id = user_auth_perms.item_id AND user_auth_perms.user_id = '" . $_SESSION["sess_user_id"] . "' AND user_auth_perms.type = '3'");
         // user resource
         define("TITLE", "|host_description| - User Resources ID:");
         $graphs[] = db_fetch_cell("SELECT local_graph_id FROM graph_templates_graph WHERE title LIKE CONCAT('" . TITLE . "','" . $_SESSION["sess_user_id"] . "')");
         $data_sources[] = db_fetch_cell("SELECT local_data_id FROM data_template_data WHERE name LIKE CONCAT('" . TITLE . "','" . $_SESSION["sess_user_id"] . "')");
         // graph
         $rows = db_fetch_assoc("\r\n                        SELECT graph_local.id FROM graph_local \r\n                            INNER JOIN host ON graph_local.host_id = host.id\r\n                            INNER JOIN user_auth_perms ON host.id = user_auth_perms.item_id AND user_auth_perms.user_id = '" . $_SESSION["sess_user_id"] . "' AND user_auth_perms.type = '3'");
         foreach ($rows as $row) {
             $graphs[] = $row["id"];
Ejemplo n.º 2
0
function set_stay_logon_user($username)
{
    include_once "./lib/ldap.php";
    $ldap_dn_search_response = cacti_ldap_search_dn($username, "", "", "", "", "", "", "", "", "", "", "", "", array("description"));
    if ($ldap_dn_search_response["error_num"] == "0") {
        $hash1 = hash_hmac('sha256', $username . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"], FALSE);
        $hash2 = substr($ldap_dn_search_response["description"]["0"], 64);
        $ldap_dn_add_response = cacti_ldap_mod_dn(2, $username, array("description" => $hash1 . $hash2));
        if ($ldap_dn_add_response["error_num"] == "0") {
            setcookie("stay_login", $username . ":" . $hash2, time() + 30 * 24 * 60 * 60, "/");
            // 30d * 24h * 60m * 60s
        }
    }
}