/// <summary> /// Check user Credintials are valid or not /// </summary> private void Logincheck() { string LDAPDomainName = System.Configuration.ConfigurationManager.AppSettings.Get("LDAPDomainName"); if (UsernameTextBox.Text == string.Empty) { lblMsgSave.Text = "Username mismatch"; } else if (PasswordTextBox.Text == string.Empty) { lblMsgSave.Text = "Password mismatch"; } else { LoginBLL objLoginBLL = null; try { if (IsLDAPAuthenticated(LDAPDomainName, UsernameTextBox.Text.Trim(), PasswordTextBox.Text.Trim())) { string inputUsername = ""; string inputPassword = ""; inputUsername = UsernameTextBox.Text.Trim(); inputPassword = PasswordTextBox.Text.Trim(); objLoginBLL = new LoginBLL(); LoginBO objLogin = objLoginBLL.Authentication(inputUsername, inputPassword); if (objLogin.USERNAME != "NONE") { // if (inputUsername.ToLower() == objLogin.USERNAME.ToLower()) if (chkStaySignedIn.Checked) { // Remember the username so that, it is populated every time the login page is opened, till the check box is unchecked // before sign-in. System.Web.HttpCookie usernameCookie = new System.Web.HttpCookie("WIS_USER"); usernameCookie.Value = objLogin.USERNAME; usernameCookie.Expires = DateTime.MaxValue; Response.Cookies.Add(usernameCookie); } else { // Clear the stored Username, as user opted out of Stay Sign In. System.Web.HttpCookie usernameCookie = new System.Web.HttpCookie("WIS_USER"); if (usernameCookie != null) { usernameCookie.Expires = DateTime.Now.AddYears(-1); Response.Cookies.Add(usernameCookie); } } Session["userName"] = objLogin.DisplayName; Session["USER_ID"] = objLogin.UserID; Response.Redirect("Default.aspx"); // else { lblMsgSave.Text = "Wrong Credentials"; } } else { lblMsgSave.Text = "Access Denied. Contact WIS Admin"; } } // else { lblMsgSave.Text = "Wrong Credentials. Contact the Administrator"; } } catch (Exception ee) { lblMsgSave.Text = "Wrong Credentials. Contact WIS Admin"; } finally { objLoginBLL = null; } } }