private bool CheckedUser() { String strName = TextBoxName.Text.Trim(); if (_strDic.Count > 0 && _strDic.ContainsKey(strName)) { MessageBox.Show("用户名【" + strName + "】已经存在,请重新输入!", "操作提示"); return(false); } if (!strName.Equals("260905")) { if (strName.Equals(string.Empty)) { TextBoxName.Clear(); TextBoxName.Focus(); MessageBox.Show("用户名不能为空!", "操作提示"); return(false); } else if (TextBoxPassword.Text.Trim().Equals(string.Empty)) { TextBoxPassword.Clear(); TextBoxPassword.Focus(); MessageBox.Show("密码不能为空!", "操作提示"); return(false); } } else { MessageBox.Show("不能创建该用户!", "操作提示"); return(false); } return(true); }
private void TextBoxID_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) // 엔터 { TextBoxPassword.Focus(); } }
private void TextBoxAccount_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { TextBoxPassword.Focus(); } }
private void TextBoxAccount_OnKeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter) { TextBoxPassword.Focus(FocusState.Keyboard); } }
public void TextBoxUsername_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { TextBoxPassword.Focus(); e.Handled = true; } }
/// <summary> /// Displays requested screen section based on received request. /// </summary> private void ManageScreenVisualization() { // Initially hide everything on all screens LoginSection.Visibility = Visibility.Collapsed; AccessDeniedSection.Visibility = Visibility.Collapsed; ChangePasswordSection.Visibility = Visibility.Collapsed; TextBlockApplicationLogin.Visibility = Visibility.Collapsed; TextBlockAccessDenied.Visibility = Visibility.Collapsed; TextBlockChangePassword.Visibility = Visibility.Collapsed; // Reset all default buttons ButtonLogin.IsDefault = false; ButtonOK.IsDefault = false; ButtonChange.IsDefault = false; if (m_displayType == DisplayType.Login) { TextBoxPassword.Password = ""; ButtonLogin.IsDefault = true; TextBlockApplicationLogin.Visibility = Visibility.Visible; LoginSection.Visibility = Visibility.Visible; if (string.IsNullOrWhiteSpace(TextBoxUserName.Text)) { TextBoxUserName.Focus(); } else { TextBoxPassword.Focus(); } } else if (m_displayType == DisplayType.AccessDenied) { ButtonOK.IsDefault = true; TextBlockAccessDenied.Visibility = Visibility.Visible; AccessDeniedSection.Visibility = Visibility.Visible; } else if (m_displayType == DisplayType.ChangePassword) { TextBoxOldPassword.Password = ""; TextBoxNewPassword.Password = ""; TextBoxConfirmPassword.Password = ""; ButtonChange.IsDefault = true; TextBlockChangePassword.Visibility = Visibility.Visible; ChangePasswordSection.Visibility = Visibility.Visible; if (string.IsNullOrWhiteSpace(TextBoxChangePasswordUserName.Text)) { TextBoxChangePasswordUserName.Focus(); } else { TextBoxOldPassword.Focus(); } } }
/// <summary> /// Verify that the user's account exists on the Unity Connection server and that they have administrator rights. The login /// to CUPI for admins will fail otherwise. /// If the login goes through add the user information to the session variable - this doesn't get used for anything other than /// as verification that the currently logged in user is authenticated - the credentials have to be resent with each CUPI command /// regardless. This just makes sure the user isn't getting cute and going directly to the user selection page. /// </summary> protected void ButtonLogin_Click(object sender, EventArgs e) { ConnectionServerRest currentConnectionServer; //check for empty strings - yes, you can use ASP form control checks for these but then you have difficulty with the Java Script //method of enabling/disabling the login button on the client side so I do the checks manually here and just use a single status //label for feedback - not quite as slick but the trade off is worth it. if (string.IsNullOrEmpty(TextBoxServerName.Text.Trim())) { LabelStatus.Text = "You must provide a Connection server name"; TextBoxServerName.Focus(); return; } if (string.IsNullOrEmpty(TextBoxName.Text.Trim())) { LabelStatus.Text = "You must provide a login name"; TextBoxName.Focus(); return; } if (string.IsNullOrEmpty(TextBoxPassword.Text.Trim())) { LabelStatus.Text = "You must provide a password"; TextBoxPassword.Focus(); return; } LabelStatus.Text = ""; try { currentConnectionServer = new ConnectionServerRest(new RestTransportFunctions(), TextBoxServerName.Text.Trim(), TextBoxName.Text.Trim(), TextBoxPassword.Text.Trim()); } catch { LabelStatus.Text = "Login failed, make sure the server name is valid, DNS is working properly and the user name and login are valid"; ButtonLogin.Enabled = true; return; } //if the class creation failed but the server login still didn't complete (this should really never happen, but just in case) if (currentConnectionServer.ServerName.Length == 0) { //login failed = give the user the chance to try again. LabelStatus.Text = "Login failed, make sure the server name is valid, DNS is working properly and the user name and login are valid"; ButtonLogin.Enabled = true; return; } //stuff the current connection server object into the session state where we can pull it out later. Then redirect to the select user //page which is where all the action takes place. Session["CurrentConnectionServer"] = currentConnectionServer; Response.Redirect("~/SelectUser.aspx"); }
private void _btnAceptar_Click(object sender, EventArgs e) { string username = TextBoxUsuario.Text.Trim(); string password = TextBoxPassword.Text.Trim(); bool usuarioNoValido = false; ErrorInicioSession error = ErrorInicioSession.SinError; if (ValidateUser(username, password)) { error = Sesion.Instancia.IniciarSesion(username, password); if (error == ErrorInicioSession.SinError) { RegistradorArchLocal.Instancia.NombreArchivo = Sesion.Instancia.EmpresaActual.Sigla; MessageMgr.Instance.SetConexion(Sesion.Instancia.Conexion); this.Hide(); DialogResult = System.Windows.Forms.DialogResult.OK; } else if (error == ErrorInicioSession.UsuarioNoValido || error == ErrorInicioSession.UsuarioNoValidoParaSisFalla) { usuarioNoValido = true; } else { MessageBox.Show(GetMensaje(error)); DialogResult = System.Windows.Forms.DialogResult.Cancel; } } else { usuarioNoValido = true; error = ErrorInicioSession.UsuarioNoValido; } if (usuarioNoValido) { if (error == ErrorInicioSession.UsuarioNoValido) { cndcLabelInfo.Text = "Usuario o contraseña incorrecto...(Intento " + NumIntentos + " de " + MaxIntentos + ")"; } else if (error == ErrorInicioSession.UsuarioNoValidoParaSisFalla) { cndcLabelInfo.Text = "Usuario no válido para SisFalla (Intento " + NumIntentos + " de " + MaxIntentos + ")"; } TextBoxPassword.Text = ""; TextBoxPassword.Focus(); NumIntentos++; if (NumIntentos > MaxIntentos) { MessageBox.Show("Tercer intento fallido, se cerrará la aplicación.");//MessageMgr.Instance.GetMessage("TERCER_INTENTO")); TextBoxUsuario.Enabled = false; TextBoxPassword.Enabled = false; DialogResult = System.Windows.Forms.DialogResult.Cancel; } } }
protected override void Page_Load(object sender, EventArgs e) { DataSet ds = null; Streamline.UserBusinessServices.MedicationLogin objMedicationLogin = new Streamline.UserBusinessServices.MedicationLogin(); try { clearBrowserCache(); if (!IsPostBack) { // Check if the Staff folder is created or not if (!System.IO.Directory.Exists(Server.MapPath("RDLC\\" + Context.User.Identity.Name) + "\\")) { System.IO.Directory.CreateDirectory(Server.MapPath("RDLC\\" + Context.User.Identity.Name) + "\\"); } RadioPassword.Checked = true; RadioPassword.Attributes.Add("onclick", "onRadioPasswordChange();"); RadioSignaturePad.Attributes.Add("onclick", "onRadioSignatureMouseTouchPadChange();"); RadioCanvasSignature.Attributes.Add("onclick", "onRadioSignatureMouseTouchPadChange();"); CheckBoxSignedPaperDocument.Attributes.Add("onclick", "onCheckBoxSignedPaperDocumentChange();"); HiddenFiledApplicationPath.Value = Server.MapPath("RDLC\\" + Context.User.Identity.Name); ButtonSign.Attributes.Add("onclick", "UpdateDocuments('', 'False');"); TextBoxPassword.Attributes.Add("onkeydown", CommonFunctions.ReturnJSForClickEvent(ButtonSign.UniqueID)); CheckBoxSignedPaperDocument.Attributes.Add("onkeydown", CommonFunctions.ReturnJSForClickEvent(ButtonSign.UniqueID)); RadioSignaturePad.Attributes.Add("onkeydown", CommonFunctions.ReturnJSForClickEvent(ButtonSign.UniqueID)); TextBoxPassword.Focus(); } } catch (Exception ex) { if (ex.Data["CustomExceptionInformation"] == null) { ex.Data["CustomExceptionInformation"] = ""; } else { ex.Data["CustomExceptionInformation"] = ""; } if (ex.Data["DatasetInfo"] == null) { ex.Data["DatasetInfo"] = null; } Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this); } }
private void ShowNotAuthorisedDialog() { using (var dlg = new ErrorDialog(Messages.USER_NOT_AUTHORIZED) { WindowTitle = Messages.PERMISSION_DENIED }) { dlg.ShowDialog(this); } TextBoxPassword.Focus(); TextBoxPassword.SelectAll(); }
private void ShowNotAuthorisedDialog() { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, Messages.USER_NOT_AUTHORIZED, Messages.PERMISSION_DENIED))) { dlg.ShowDialog(this); } TextBoxPassword.Focus(); TextBoxPassword.SelectAll(); }
private void Login() { var online = true; if (TextBoxUsername.Text == "") { labelLogin.Text = "Username cannot be empty"; return; } if (TextBoxPassword.Text == "") { labelLogin.Text = "Password cannot be empty"; return; } try { _user = Database.SearchByUsername(TextBoxUsername.Text) ?? null; } catch (SqlException) { online = false; _user = new User { Name = TextBoxUsername.Text }; } if (_user == null) { labelLogin.Text = "user '" + TextBoxUsername.Text + "' not found"; TextBoxUsername.Clear(); TextBoxPassword.Clear(); TextBoxUsername.Focus(); return; } if (online && !_user.CheckPassword(TextBoxPassword.Text)) { labelLogin.Text = "wrong password :("; TextBoxPassword.Text = ""; TextBoxPassword.Focus(); return; } StartGame(online); }
public void Show() { mLoginWindow.IsHidden = false; if (!mForgotPassswordButton.IsHidden) { mForgotPassswordButton.IsHidden = !Options.Instance.SmtpValid; } // Set focus to the appropriate elements. if (!string.IsNullOrWhiteSpace(mUsernameTextbox.Text)) { mPasswordTextbox.Focus(); } else { mUsernameTextbox.Focus(); } }
private void ImagePassword_PreviewMouseDown(object sender, MouseButtonEventArgs e) { if (padlock == 0) { PasswordBoxPassword.Visibility = System.Windows.Visibility.Collapsed; TextBoxPassword.Visibility = System.Windows.Visibility.Visible; TextBoxPassword.Text = PasswordBoxPassword.Password; TextBoxPassword.Focus(); TextBoxPassword.SelectionStart = TextBoxPassword.Text.Length; padlock = 1; if (kolor == 1) { imagePassword.Source = new BitmapImage(new Uri(@"/Images/GrafikiPanel/unlockAqua.png", UriKind.Relative)); } else if (kolor == 0) { imagePassword.Source = new BitmapImage(new Uri(@"/Images/GrafikiPanel/unlock.png", UriKind.Relative)); } } else if (padlock == 1) { PasswordBoxPassword.Visibility = System.Windows.Visibility.Visible; TextBoxPassword.Visibility = System.Windows.Visibility.Collapsed; PasswordBoxPassword.Password = TextBoxPassword.Text; SetSelection(PasswordBoxPassword, (TextBoxPassword.Text).Length, 0); PasswordBoxPassword.Focus(); SetSelection(PasswordBoxPassword, (TextBoxPassword.Text).Length, 0); // PasswordBoxPassword. = PasswordBoxPassword.Password.Length; // SetSelection(PasswordBoxPassword, 2, 0); padlock = 0; if (kolor == 1) { imagePassword.Source = new BitmapImage(new Uri(@"/Images/GrafikiPanel/lockAqua.png", UriKind.Relative)); } else if (kolor == 0) { imagePassword.Source = new BitmapImage(new Uri(@"/Images/GrafikiPanel/lock.png", UriKind.Relative)); } } }
/// <summary> /// 验证信息完整性 /// </summary> /// <returns></returns> private bool Check() { String str = String.Empty; str = TextBoxItemName.Text.Trim(); if (str.Length == 0) { MessageBox.Show(this, "请设置【项目名称】!", "操作提示", MessageBoxButton.OK, MessageBoxImage.Warning); TextBoxItemName.Focus(); return(false); } if (ComboBoxMethod.SelectedIndex < 0) { MessageBox.Show(this, "请设置【检测方法】!", "操作提示", MessageBoxButton.OK, MessageBoxImage.Warning); ComboBoxMethod.Focus(); return(false); } str = TextBoxUnit.Text.Trim(); if (str.Length == 0) { MessageBox.Show(this, "请设置【单位】!", "操作提示", MessageBoxButton.OK, MessageBoxImage.Warning); TextBoxUnit.Focus(); return(false); } str = ComboBoxWave.Text.Trim(); if (str.Length == 0) { MessageBox.Show(this, "请设置【波长】!", "操作提示", MessageBoxButton.OK, MessageBoxImage.Warning); ComboBoxWave.Focus(); return(false); } str = TextBoxPassword.Text.Trim(); if (str.Length == 0) { if (MessageBox.Show("【未设置密码】 确定保存无密码的检测项目吗?", "操作提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { TextBoxPassword.Focus(); return(false); } } return(true); }
private bool Validate() { if (string.IsNullOrWhiteSpace(TextBoxUserName.Text)) { MessageBox.Show("Username is mandatory for new users"); TextBoxUserName.Focus(); return(false); } if (string.IsNullOrWhiteSpace(TextBoxPassword.Text)) { MessageBox.Show("Password is mandatory for new users"); TextBoxPassword.Focus(); return(false); } if (ComboBoxAdmin.SelectedIndex < 0) { MessageBox.Show("Admin status is mandatory for new users"); ComboBoxAdmin.Focus(); return(false); } return(true); }
private void ButtonLogin_Click(object sender, EventArgs e) { ButtonLogin.Enabled = false; labelWrongPW.Text = string.Empty; if (SessionVerwaltung.ADAuthentication("vrg-ol.de", TextBoxUsername.Text, TextBoxPassword.Text)) { form1.username = TextBoxUsername.Text; form1.passwort = TextBoxPassword.Text; this.Close(); } else { MessageBox.Show("Authentifizierung fehlgeschlagen", "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning); labelWrongPW.Text = " Falsches PW"; TextBoxPassword.Text = string.Empty; TextBoxPassword.Focus(); } ButtonLogin.Enabled = true; }
private void ButtonLogin_Click(object sender, EventArgs e) { if (!Regex.IsMatch(TextBoxAccount.Text, @"1\d{5}")) { MessageBox.Show("用户名不合法!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBoxAccount.Clear(); TextBoxAccount.Focus(); } else if (TextBoxPassword.Text == String.Empty) { MessageBox.Show("密码不合法!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBoxPassword.Clear(); TextBoxPassword.Focus(); } else { try { GlobalClass.Connection.Open(); SqlCommand LoginCmd = new SqlCommand("UserLogin", GlobalClass.Connection); LoginCmd.CommandType = CommandType.StoredProcedure; LoginCmd.Parameters.Add("@No", SqlDbType.NChar, 6); LoginCmd.Parameters.Add("@Password", SqlDbType.NChar, 32); LoginCmd.Parameters.Add("@ReturnValue", SqlDbType.Int, 6); LoginCmd.Parameters[0].Value = TextBoxAccount.Text; LoginCmd.Parameters[1].Value = GlobalClass.MD5(TextBoxPassword.Text); LoginCmd.Parameters[2].Direction = ParameterDirection.ReturnValue; LoginCmd.ExecuteNonQuery(); int ReturnValue = (int)LoginCmd.Parameters[2].Value; GlobalClass.Connection.Close(); if (ReturnValue == 0) { GlobalClass.UserName = TextBoxAccount.Text; GlobalClass.EmployeeNo = TextBoxAccount.Text; GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Administrator; this.TimerProgressBar.Start(); } else if (ReturnValue == 1) { GlobalClass.UserName = TextBoxAccount.Text; GlobalClass.EmployeeNo = TextBoxAccount.Text; GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Director; this.TimerProgressBar.Start(); } else if (ReturnValue == 2) { GlobalClass.UserName = TextBoxAccount.Text; GlobalClass.EmployeeNo = TextBoxAccount.Text; GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Manager; this.TimerProgressBar.Start(); } else if (ReturnValue == 3) { GlobalClass.UserName = TextBoxAccount.Text; GlobalClass.EmployeeNo = TextBoxAccount.Text; GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Reception; this.TimerProgressBar.Start(); } else if (ReturnValue == 4) { GlobalClass.UserName = TextBoxAccount.Text; GlobalClass.EmployeeNo = TextBoxAccount.Text; GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Logistics; this.TimerProgressBar.Start(); } else if (ReturnValue == 5) { MessageBox.Show("权限不足!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBoxAccount.Clear(); TextBoxPassword.Clear(); TextBoxAccount.Focus(); } else if (ReturnValue == 6) { MessageBox.Show("密码错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBoxPassword.Clear(); TextBoxPassword.Focus(); } else if (ReturnValue == 7) { MessageBox.Show("用户名错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBoxAccount.Clear(); TextBoxAccount.Focus(); } else { MessageBox.Show("未知错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); GlobalClass.Connection.Close(); } } }
protected void ButtonLogon_Click(object sender, EventArgs e) { objMedicationLogin = new Streamline.UserBusinessServices.MedicationLogin(); //Optimization Added by Sony DataSet ds = null; DataSet userAuthenticationType = null; string authType = string.Empty; string enableADAuthentication = string.Empty; bool isValidUser = false; try { if (TextBoxUsername.Text.Trim() == string.Empty || TextBoxPassword.Text.Trim() == string.Empty) { this.LabelError.Text = "Please enter Username/Password"; return; } try { userAuthenticationType = objMedicationLogin.GetUserAuthenticationType(TextBoxUsername.Text.Trim()); if (userAuthenticationType.Tables["Authentication"].Rows.Count > 0) { authType = userAuthenticationType.Tables["Authentication"].Rows[0]["AuthenticationType"].ToString(); } if (userAuthenticationType.Tables["EnableActiveDirectory"] != null) { enableADAuthentication = userAuthenticationType.Tables["EnableActiveDirectory"].Rows[0]["EnableADAuthentication"].ToString(); } if (enableADAuthentication.ToUpperInvariant().Equals("Y") && authType.ToUpperInvariant().Equals("A")) { isValidUser = objMedicationLogin.ADAuthenticateUser(TextBoxUsername.Text.Trim(), TextBoxPassword.Text.Trim(), userAuthenticationType.Tables["Authentication"].Rows[0]["Domain"].ToString() ); if (isValidUser) { var secureADPassword = new SecureString(); ds = objMedicationLogin.GetAuthenticatedStaffInfo(Convert.ToInt32(userAuthenticationType.Tables["Authentication"].Rows[0]["StaffId"]), TextBoxUsername.Text.Trim()); TextBoxPassword.Text.ToCharArray().ToList().ForEach(secureADPassword.AppendChar); Session["ADPassword"] = secureADPassword; } } else { ds = objMedicationLogin.chkServerLogin(TextBoxUsername.Text.Trim(), TextBoxPassword.Text.Trim()); } if (HiddenFieldUseName.Value.Trim().ToLower() != TextBoxUsername.Text.Trim().ToLower()) { HiddenFieldLoginCount.Value = "0"; HiddenFieldUseName.Value = TextBoxUsername.Text; } HiddenFieldLoginCount.Value = Convert.ToString(Convert.ToInt32(HiddenFieldLoginCount.Value) + 1); hiddenOldPassword.Value = TextBoxPassword.Text.Trim(); } catch (Exception ex) { this.LabelError.Text = "Invalid Username/Password"; TextBoxPassword.Text = ""; throw ex; } //Added in ref to Task#2595 if (Convert.ToInt32(HiddenFieldLoginCount.Value) > 5) { objMedicationLogin.chkCountLogin(TextBoxUsername.Text.Trim()); this.LabelError.Text = "Your account is disabled.Please contact system administrator."; TextBoxPassword.Focus(); HiddenFieldLoginCount.Value = ""; return; } if (ds.Tables[0].Rows.Count <= 0) { this.LabelError.Text = "Invalid Username/Password"; TextBoxPassword.Text = ""; return; } //if (ds.Tables[0].Rows.Count > 0) // { // Response.Redirect("ValidatePage.aspx?ClientId=0&StaffId=" + ds.Tables[0].Rows[0]["StaffID"].ToString()); // } else { //Added by Loveena in ref to Task#3269-2.6 User Management: When Staff Created or Updated Set AccessSmartCare flag. if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0][0].ToString() == "Not an authorized user") { this.LabelError.Text = "Not an authorized user"; } else { int _logStatus = Convert.ToInt32((ds.Tables[0].Rows[0][5]).ToString()); // Password Expire Functionality if (_logStatus == 1 || _logStatus == 2) { ScriptManager.RegisterStartupScript(LabelError, LabelError.GetType(), "key", "javascript:OpenChangePassword('" + TextBoxPassword.Text + "','" + TextBoxUsername.Text + "');", true); if (hiddenCancelled.Value == "0") { ScriptManager.RegisterClientScriptBlock(LabelError, LabelError.GetType(), "key", "javascript:alert('Password changed successfully')", true); TextBoxPassword.Text = hiddenOldPassword.Value; } if (hiddenCancelled.Value == "1") { ScriptManager.RegisterClientScriptBlock(LabelError, LabelError.GetType(), "key", "alert('Password changed failed')", true); return; } } else { //Added in ref to Task#2595 //Comented by Pradeep for testing needs to be uncoment later //if (ds.Tables[0].Rows[0]["QuestionsAnswered"] != System.DBNull.Value) // { // this.LabelError.Text = ds.Tables[0].Rows[0]["QuestionsAnswered"].ToString(); // TextBoxPassword.Focus(); // } //else // { //Commented in ref to Task#2700 Response.Redirect("ValidatePage.aspx?ClientId=0&StaffId=" + ds.Tables[0].Rows[0]["StaffID"].ToString(), false); //} //Added in ref to Task#2595 //if (ds.Tables[0].Rows[0]["QuestionsAnswered"] != System.DBNull.Value) //{ // //Modified by Loveena in ref to Task#2700 // //this.LabelError.Text = ds.Tables[0].Rows[0]["QuestionsAnswered"].ToString(); // //TextBoxPassword.Focus(); // Response.Redirect("ValidatePage.aspx?ClientId=0&StaffId=" + ds.Tables[0].Rows[0]["StaffID"].ToString() + "&QuestionsAnswered=" + ds.Tables[0].Rows[0]["QuestionsAnswered"].ToString()); //} //else //{ // Response.Redirect("ValidatePage.aspx?ClientId=0&StaffId=" + ds.Tables[0].Rows[0]["StaffID"].ToString() + "&QuestionsAnswered="); //} } } } } } catch (Exception ex) { if (ex.Data["CustomExceptionInformation"] == null) { ex.Data["CustomExceptionInformation"] = "###Source Function Name - MedicationLogin--Page_Load(), ParameterCount -0 ###"; } else { ex.Data["CustomExceptionInformation"] = ""; } if (ex.Data["DatasetInfo"] == null) { ex.Data["DatasetInfo"] = null; } Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this); } }
/// <summary> /// Logins the user. /// </summary> /// <param name="sender">Source of this event.</param> /// <param name="e">Arguments of this event.</param> private void ButtonLogin_Click(object sender, RoutedEventArgs e) { UserInfo userInfo; WindowsImpersonationContext impersonationContext = null; ISecurityProvider securityProvider; try { // Determine whether we need to try impersonating the user userInfo = new UserInfo(TextBoxUserName.Text); // If the application is unable to access the domain, possibly because the local user // running the application does not have access to domain objects, it's possible that // the user logging in does have access to the domain. So we attempt to impersonate the // user logging in to allow authentication to proceed if (!userInfo.DomainRespondsForUser && TryImpersonate(userInfo.LoginID, TextBoxPassword.Password, out impersonationContext)) { try { // Working around a known issue - DirectorySearcher will often throw // an exception the first time it is used after impersonating another // user so we get that out of the way here userInfo.Initialize(); } catch (InitializationException) { // Exception is expected so we ignore it } } // Initialize the security provider securityProvider = SecurityProviderCache.CreateProvider(TextBoxUserName.Text); securityProvider.SecurePassword = TextBoxPassword.SecurePassword; // Attempt to authenticate user if (securityProvider.Authenticate()) { // Setup security principal for subsequent uses SecurityIdentity securityIdentity = new SecurityIdentity(securityProvider); SecurityPrincipal = new SecurityPrincipal(securityIdentity); ClearErrorMessage(); ExitSuccess = true; } else { // Verify their password hasn't expired if (securityProvider.UserData.IsDefined && securityProvider.UserData.PasswordChangeDateTime <= DateTime.UtcNow) { // Display password expired message DisplayErrorMessage(string.Format("Your password has expired. {0} You must change your password to continue.", securityProvider.AuthenticationFailureReason)); m_displayType = DisplayType.ChangePassword; ManageScreenVisualization(); TextBoxPassword.Password = ""; } else { // Display login failure message DisplayErrorMessage("The username or password is invalid. " + securityProvider.AuthenticationFailureReason); if (string.IsNullOrWhiteSpace(TextBoxUserName.Text)) { TextBoxUserName.Focus(); } else { TextBoxPassword.Focus(); } } } } catch (Exception ex) { DisplayErrorMessage("Login failed: " + ex.Message); if (string.IsNullOrWhiteSpace(TextBoxUserName.Text)) { TextBoxUserName.Focus(); } else { TextBoxPassword.Focus(); } } finally { if ((object)impersonationContext != null) { impersonationContext.Undo(); impersonationContext.Dispose(); } } }
public FormIngreso() { InitializeComponent(); TextBoxPassword.Focus(); }
private void TextBox_GotFocus(object sender, RoutedEventArgs e) { //с помощью TextBlock на поле с паролем есть соответсвующая надпись TextBoxKostil.Visibility = Visibility.Collapsed; TextBoxPassword.Focus(); }
private void buttonAuthorize_Click(object sender, EventArgs e) { try { Exception delegateException = null; log.Debug("Testing logging in with the new credentials"); DelegatedAsyncAction loginAction = new DelegatedAsyncAction(connection, Messages.AUTHORIZING_USER, Messages.CREDENTIALS_CHECKING, Messages.CREDENTIALS_CHECK_COMPLETE, delegate { try { elevatedSession = connection.ElevatedSession(TextBoxUsername.Text.Trim(), TextBoxPassword.Text); } catch (Exception ex) { delegateException = ex; } }); using (var dlg = new ActionProgressDialog(loginAction, ProgressBarStyle.Marquee, false)) dlg.ShowDialog(this); // The exception would have been handled by the action progress dialog, just return the user to the sudo dialog if (loginAction.Exception != null) { return; } if (HandledAnyDelegateException(delegateException)) { return; } if (elevatedSession.IsLocalSuperuser || SessionAuthorized(elevatedSession)) { elevatedUsername = TextBoxUsername.Text.Trim(); elevatedPassword = TextBoxPassword.Text; DialogResult = DialogResult.OK; Close(); return; } ShowNotAuthorisedDialog(); } catch (Exception ex) { log.DebugFormat("Exception when attempting to sudo action: {0} ", ex); using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, String.Format(Messages.USER_AUTHORIZATION_FAILED, TextBoxUsername.Text), Messages.XENCENTER))) { dlg.ShowDialog(Parent); } TextBoxPassword.Focus(); TextBoxPassword.SelectAll(); } finally { // Check whether we have a successful elevated session and whether we have been asked to log it out // If non successful (most likely the new subject is not authorized) then log it out anyway. if (elevatedSession != null && DialogResult != DialogResult.OK) { elevatedSession.Connection.Logout(elevatedSession); elevatedSession = null; } } }
public PopupPassword() { InitializeComponent(); TextBoxPassword.Focus(); }