Exemple #1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     UserName = edtUserName.Text;
     Password = DHuy.HideFood(edtPassword.Text, "RELOGON", new byte[256]);
     Res      = 1;
     this.Close();
 }
Exemple #2
0
        private void Save_Click(object sender, EventArgs e)
        {
            DataTable dt = DHuy.SELECT_NEWROW("USER_PCS");

            dt.Rows[0]["ID"]       = ID;
            dt.Rows[0]["USERCODE"] = USERCODE;
            dt.Rows[0]["PCS_ID"]   = edtPCS_ID.Text;
            dt.Rows[0]["PASS"]     = edtPass.Text;
            if (edtPass.Text == "")
            {
                dt.Rows[0]["PASS"] = "";
            }
            else
            {
                dt.Rows[0]["PASS"] = DHuy.HideFood(edtPass.Text, "ForTheWin", new byte[256]);
            }
            dt.Rows[0]["PCS_NAME"] = edtPCS_NAME.Text;

            int kq = 0;

            if (isUpdate == 0)
            {
                kq = DHuy.INSERT_IDENTITY("USER_PCS", dt);
            }
            else
            {
                if (ID > 0)
                {
                    kq = DHuy.UPDATE("USER_PCS", dt, "ID");
                }
            }

            if (kq > 0)
            {
                Res = 1;
                // MessageBox.Show("Saved!");
                this.Close();
            }
        }
Exemple #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (edtPassword.Text == "")
                {
                    DBase.PasswordAuthen = "";
                }
                else
                {
                    DBase.PasswordAuthen = DHuy.HideFood(edtPassword.Text, "justicenzy", new byte[64]);
                }
                DBase.NickName = edtNickName.Text;
                DBase.LockDesktopWhenSessionFinish = edtLockAfterSession.Checked ? "1" : "0";
                DBase.AutoupdateWhenStart          = edtAutoUpdateWhenStart.Checked ? "1" : "0";
                DBase.DisableAreoThemWhenConnect   = edtDisableAreo.Checked ? "1" : "0";
                DBase.WallChange        = edtWallPapper.Checked ? 1 : 0;
                DBase.WallChangeSecond  = DBase.IntReturn(edtIntervalWall.Text);
                DBase.ActiveTranslation = edtActiveTranslator.Checked ? 1 : 0;
                DBase.SoundDeviceText   = edtSoundDevice.Text;
                if (edtDisableWindowsLock.Checked)
                {
                    DBase.RegistrySetCU("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoLogoff", "1", true);
                }
                else
                {
                    DBase.RegistrySetCU("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoLogoff", "0", true);
                }
            }
            catch (Exception ex) { }


            DBase.SaveSetting();
            M.RefreshButton();
            this.Close();
        }
Exemple #4
0
        private void edtPassword_KeyDown(object sender, KeyEventArgs e)
        {
            edtInvalid.Visible = false;
            int validLogon = 1;

            try
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (DBase.AutoLogOn != "1")
                    {
                        validLogon = 0;
                    }

                    if (DWindow.ValidateLogOn(edtUserName.Text, edtPassword.Text) || (validLogon == 0 && AllowBlankPass == 0 && DHuy.HideFood(edtPassword.Text, "justicenzy", new byte[64]) == DBase.PasswordAuthen))
                    {
                        allowClose = 1;

                        if (edtUserName.Text != Environment.UserName) // Logon to other user
                        {
                            int errorInProcess = 0;
                            try
                            {
                                DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoRestartShell", "0", true);
                                DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "ForceAutoLogon", "1", true);

                                DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultDomainName", Environment.MachineName);
                                DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultUserName", edtUserName.Text);
                                DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoAdminLogon", "1");

                                RegEncryption R = new RegEncryption("DefaultPassword"); R.SetSecret(edtPassword.Text);
                                DBase.AutoLogOn = "1";
                                DBase.SaveSetting();
                            }
                            catch (Exception ex)
                            {
                                errorInProcess = 1;
                            }

                            if (errorInProcess == 0) // everything ok --> auto logon log off
                            {
                                DBase.AutoLogOnUser_AfterLogOff(edtUserName.Text, edtPassword.Text);
                                this.Close();
                            }
                            else
                            {
                                edtInvalid.Text    = "Account permision deny!";
                                edtInvalid.Visible = true;
                            }
                        }
                        else //same user logon
                        {
                            //   Process.Start("Explorer");
                            this.Close();
                        }
                    }
                    else
                    {
                        edtPassword.Text   = "";
                        edtInvalid.Text    = "Invalid authencation !";
                        edtInvalid.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.ToString());
            }
        }
Exemple #5
0
        // Advanced Config
        private void edtAutoLogon_Click(object sender, EventArgs e)
        {
            int canEditReg = 1;

            try
            {
                DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultDomainName", Environment.MachineName);
            }
            catch (Exception ex)
            {
                canEditReg = 0;
            }
            if (canEditReg == 0)
            {
                MessageBox.Show("Administrator Only!");
                edtAutoLogon.Checked = edtAutoLogon.Checked ? false : true;
                return;
            }

            if (edtAutoLogon.Checked)
            {
                try
                {
                    ConfigAutoLogOn C = new ConfigAutoLogOn();
                    C.Location = new Point(this.Location.X, this.Location.Y + 30);

                    C.ShowDialog(this);
                    if (C.Res == 1)
                    {
                        try
                        {
                            DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoRestartShell", "0", true);
                            DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "ForceAutoLogon", "1", true);

                            DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultDomainName", Environment.MachineName);
                            DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultUserName", Environment.UserName);
                            DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoAdminLogon", "1");
                            DBase.RegistrySetLM("SYSTEM\\CurrentControlSet\\Control", "WaitToKillServiceTimeout", "1000");

                            RegEncryption R = new RegEncryption("DefaultPassword"); R.SetSecret(C.TextInput);
                            DBase.AutoLogOn     = "1";
                            DBase.LogOnPassword = DHuy.HideFood(C.TextInput, "Asdasd123!", new byte[512]);
                            DBase.SaveSetting();
                        }
                        catch (Exception ex) { DBase.AutoLogOn = "0"; }
                        try
                        {
                            DBase.RegistryDeleteCU("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", "PCT");
                            RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                            if (rk.GetValue("PCT") != null)
                            {
                                rk.DeleteValue("PCT");
                            }
                            if (DBase.AutoLogOn == "1")
                            {
                                rk.SetValue("PCT", "\"" + Application.ExecutablePath.ToString() + "\" STARTUP_LOGON");
                            }
                            else
                            {
                                rk.SetValue("PCT", "\"" + Application.ExecutablePath.ToString() + "\" STARTUP");
                            }

                            M.cmsStartWithWindow.Image = global::GB.Properties.Resources._011_yes_16;
                        }
                        catch (Exception ex) { }
                    }
                    else
                    {
                        DBase.AutoLogOn      = "0";
                        edtAutoLogon.Checked = false;
                        try
                        {
                            RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", true);
                            if (rk.GetValue("DefaultDomainName") != null)
                            {
                                rk.DeleteValue("DefaultDomainName");
                            }
                            if (rk.GetValue("ForceAutoLogon") != null)
                            {
                                rk.DeleteValue("ForceAutoLogon");
                            }
                            if (rk.GetValue("DefaultUserName") != null)
                            {
                                rk.DeleteValue("DefaultUserName");
                            }
                            DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoAdminLogon", "0");
                            if (rk.GetValue("DefaultPassword") != null)
                            {
                                rk.DeleteValue("DefaultPassword");
                            }
                            DBase.LogOnPassword = "";
                        }
                        catch (Exception ex) {}
                    }
                }
                catch (Exception ex) { }
            }
            else
            {
                try
                {
                    DBase.AutoLogOn = "0";
                    RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", true);
                    if (rk.GetValue("DefaultDomainName") != null)
                    {
                        rk.DeleteValue("DefaultDomainName");
                    }
                    if (rk.GetValue("ForceAutoLogon") != null)
                    {
                        rk.DeleteValue("ForceAutoLogon");
                    }
                    if (rk.GetValue("DefaultUserName") != null)
                    {
                        rk.DeleteValue("DefaultUserName");
                    }
                    if (rk.GetValue("AutoAdminLogon") != null)
                    {
                        rk.DeleteValue("AutoAdminLogon");
                    }
                    if (rk.GetValue("DefaultPassword") != null)
                    {
                        rk.DeleteValue("DefaultPassword");
                    }
                    DBase.LogOnPassword = "";
                }
                catch (Exception ex) { }

                try
                {
                    RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                    if (rk.GetValue("PCT") != null)
                    {
                        rk.DeleteValue("PCT");
                    }
                    rk.SetValue("PCT", "\"" + Application.ExecutablePath.ToString() + "\" STARTUP");
                    M.cmsStartWithWindow.Image = global::GB.Properties.Resources._011_yes_16;
                }
                catch (Exception ex) { }
            }
            DBase.SaveSetting();
        }