private void btnOK_Click(object sender, EventArgs e) { TextInput = edtPassword.Text; if (TextInput == "") { try { DBase.RegistrySetLM("SYSTEM\\CurrentControlSet\\Control\\Lsa", "limitblankpassworduse", "0", true); } catch (Exception ex) { } } if (DWindow.ValidateLogOn(Environment.UserName, TextInput)) { Res = 1; this.Close(); } else { MessageBox.Show(this, "Your password is incorrect", "", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); edtPassword.Text = ""; } }
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()); } }