protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { string strCon = ConfigurationManager.ConnectionStrings["LoginConnectionString"].ConnectionString; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["LoginConnectionString"].ConnectionString); //using (SqlConnection con = new SqlConnection(strCon)) { using (SqlCommand cmdStr = new SqlCommand("SELECT TOP(1) * FROM [Department] WHERE DepartmentID = '" + Login1.UserName + "' AND DepartmentPassword = '******'", con)) { try { con.Open(); if (cmdStr.ExecuteReader().HasRows) { e.Authenticated = true; Session["login_name"] = Login1.UserName.ToString(); Session.Timeout = 40; return; } else { Session.Abandon(); } } finally { con.Close(); } } } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { WorkerService ws = new WorkerService(); Session["WorkerFirstName"] = ws.ValidateWorker(this.Login1.UserName, this.Login1.Password); if (Session["WorkerFirstName"] != null) e.Authenticated = true; }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { string loginName = ((Login)sender).UserName; string password = ((Login)sender).Password; string dbconnection = WebConfigurationManager.ConnectionStrings["VITTORINOConnectionString1"].ConnectionString; string customerlogin = "******" + loginName + "' AND RoleID ='" + 1 + "' AND Password='******'"; SqlConnection con = new SqlConnection(dbconnection); SqlCommand custCmd = new SqlCommand(customerlogin, con); SqlDataReader custReader; con.Open(); custReader = custCmd.ExecuteReader(); if (custReader.Read()) { int userRole = Convert.ToInt32(custReader["RoleID"]); string userName = custReader["UserName"].ToString(); //Create settion with 3 parameter string[] userdetails = new string[3] { custReader["CustomerID"].ToString(), custReader["UserName"].ToString(), custReader["RoleID"].ToString() }; Session["UserDetails"] = userdetails; FormsAuthentication.SetAuthCookie(userdetails[1].ToString(), true); Response.Redirect("Index.aspx"); } else { ((Login)sender).FailureText = "Login Failed. Please check your username and password"; } con.Close(); }
protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e) { using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["WoWiConnectionString"].ConnectionString)) { cn.Open(); SqlCommand cmd = new SqlCommand("Select username from employee Where username=@username and password=@password and status='Active'", cn); cmd.Parameters.AddWithValue("@username", LoginUser.UserName); cmd.Parameters.AddWithValue("@password", LoginUser.Password); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { string username = dr["username"].ToString(); using (WoWiModel.WoWiEntities wowidb = new WoWiModel.WoWiEntities()) { int id = (from emp in wowidb.employees where emp.username == username select emp.id).First(); Session["Session_User_Id"] = id; } FormsAuthentication.RedirectFromLoginPage(username , LoginUser.RememberMeSet); } } } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if ((((Login)sender).UserName == "Munuslito") && (((Login)sender).Password == "robinwalt98")) { e.Authenticated = true; } }
protected void myLogin_Authenticate(object sender, AuthenticateEventArgs e) { // Get the email address entered TextBox EmailTextBox = myLogin.FindControl("Email") as TextBox; string email = EmailTextBox.Text.Trim(); // Verify that the username/password pair is valid if (Membership.ValidateUser(myLogin.UserName, myLogin.Password)) { // Username/password are valid, check email MembershipUser usrInfo = Membership.GetUser(myLogin.UserName); if (usrInfo != null && string.Compare(usrInfo.Email, email, true) == 0) { // Email matches, the credentials are valid e.Authenticated = true; } else { // Email address is invalid... e.Authenticated = false; } } else { // Username/password are not valid... e.Authenticated = false; } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { DirectoryEntry entry = new DirectoryEntry("LDAP://NTNIGE", Login1.UserName, Login1.Password); try { object ent = entry.NativeObject; e.Authenticated = true; SqlConnection con = new SqlConnection(); SqlCommand cmd = new SqlCommand(); con.ConnectionString = ConfigurationManager.ConnectionStrings["nfte"].ConnectionString; cmd.Connection = con; cmd.CommandText = string.Format("select count(*) from nfte.users where userid = '{0}'", Login1.UserName.Trim()); con.Open(); object o = cmd.ExecuteScalar(); int usercount = Convert.ToInt32(o); if (usercount > 0) { FormsAuthentication.SetAuthCookie(Login1.UserName, false); } else { e.Authenticated = false; Login1.FailureText = "Your username or password is wrong,please check it and try again"; } } catch { e.Authenticated = false; Login1.FailureText = "Internal error while trying to log in"; } }
protected void Login_Authenticate(object sender, AuthenticateEventArgs e) { if (Membership.ValidateUser(Login.UserName, Login.Password)) { FormsAuthentication.RedirectFromLoginPage(Login.UserName, false); } }
protected void loginWindow_Authenticate(object sender, AuthenticateEventArgs e) { if (PasswordHelper.authenticateUser(loginWindow.UserName.ToString(), loginWindow.Password.ToString())) e.Authenticated = true; else e.Authenticated = false; }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { try { if (BiFactory.CheckLogin(Login1.UserName, Login1.Password)) { FormsAuthentication.SetAuthCookie(BiFactory.User.Nombre, true); Logger.Log(TipoEvento.Login,"Inició Session"); //Response.Redirect("../default.aspx"); Response.Redirect("~/solicitudes/Solicitudes.aspx"); } else { Session["user"] = null; // Logger.Log(TipoEvento.Login, Login1.UserName.ToString() + " Intento Conectarse al Sistema"); } } catch (Exception ex) { lblMensaje.Text = ("Error" + ex.Message.ToString()); Login1.InstructionText = "Usuario invalido"; } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { String sqlCommand = "SELECT NIF FROM Clientes WHERE NIF=\"" + Login1.UserName + "\""; // como nao temos passwords na bd, apenas interessa o nif SqlCommand sql = new SqlCommand(); sql.CommandType = CommandType.Text; sql.Connection = editoraConnection; sql.CommandText = sqlCommand; editoraConnection.Open(); int val = sql.ExecuteNonQuery(); editoraConnection.Close(); if(val == 1) { // sucesso } else { // falha um.logInUser(Login1.UserName); Response.Redirect("Default.aspx"); } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { int userlevel = KMAuthentication.AuthenticateUser( KMLogin.UserName, System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(KMLogin.Password, "SHA1")); if (userlevel < 1) { e.Authenticated = false; return; } e.Authenticated = true; string role; if (userlevel == 1) { role = "Admin"; } else { role = "Demo"; } KMAuthentication.CreateAuthenticationTicket(KMLogin.UserName, role); // Need to redirect now as otherwise our cookie is overwritten Response.Redirect(FormsAuthentication.GetRedirectUrl(KMLogin.UserName, true)); }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { string conString = "Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\Yummy.mdf;Integrated Security=True"; string selectString = "SELECT * FROM tb_Userinfo WHERE Username='******'";//select string for search currency name correspond with the input SqlDataSource dsrc = new SqlDataSource(conString, selectString); DataView DV = (DataView)dsrc.Select(DataSourceSelectArguments.Empty); if (DV.Table.Rows.Count > 0) { string password = (string)DV.Table.Rows[0][7]; if (password.Equals(Login1.Password)) { //Label1.Text = "Congratulations! Login succeed! Please wait for redirect to Homepage!"; Session["Username"] = Login1.UserName; Session["Call"] = DV.Table.Rows[0][1].ToString(); Server.Transfer("~/WebSite2/Default.aspx"); //Response.Write("<script language=javascript>alert('Congratulations! Login succeed!')</script>"); //System.Threading.Thread.Sleep(5000); //Response.Redirect("~/WebSite2/Default.aspx"); } else e.Authenticated = false; } else e.Authenticated = false; }
protected void Login_Authenticate(object sender, AuthenticateEventArgs e) { String loginUsername = aspLogin.UserName; String loginPassword = aspLogin.Password; if (Membership.ValidateUser(loginUsername, loginPassword)) { e.Authenticated = true; Response.Redirect("splash.aspx", false); } else { bool successfulUnlock = AutoUnlockUser(loginUsername); if (successfulUnlock) { //re-attempt the login if (Membership.ValidateUser(loginUsername, loginPassword)) { e.Authenticated = true; Response.Redirect("splash.aspx", true); } else { e.Authenticated = false; // Error message to display same message if user exsits and password incorrect for security reasons. Info.Text = ErrorMessage + "Your username and/or password are invalid." + " <a href='forgottenpassword.aspx'>Click here</a> if you have forgotten your details.</div></div>"; } } e.Authenticated = false; Info.Text = ErrorMessage + "Your username and/or password are invalid." + " <a href='forgottenpassword.aspx'>Click here</a> if you have forgotten your details.</div></div>"; Info.Visible = true; // NovaLogin.FailureText = "Your username and/or password are invalid."; } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { try { cargarWCF(); //Usuarios unUsu = FabricaLogica.GetLogicaUsuarios().Logueo(Login1.UserName,Login1.Password); Usuarios unUsu = trivias.Logueo(Login1.UserName, Login1.Password); trivias.Close(); if (unUsu != null) { Session["Usuario"] = unUsu; if (unUsu is Jugador) { Response.Redirect("descargar.aspx"); } else if (unUsu is Admin) { Response.Redirect("abmPreguntas.aspx"); } } else { Response.Write("<div id=\"error\" class=\"alert alert-warning\">Error en el Logueo</div>" + "<script type=\"text/javascript\">window.onload=function(){alertBootstrap();};</script>"); Login1.UserName = ""; } } catch (Exception ex) { trivias.Abort(); Response.Write("<div id=\"error\" class=\"alert alert-danger\">"+ex.Message+"</div>" + "<script type=\"text/javascript\">window.onload=function(){alertBootstrap();};</script>"); Login1.UserName = ""; } }
protected void _Authenticate(object sender, AuthenticateEventArgs e) { //authentication code SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); string aSQL = "select ID_USER, NAME_USER, PASSWORD from [USER] where UPPER(NAME_USER)= @USER and UPPER(PASSWORD)=@PASS" ; try { SqlCommand cmd = new SqlCommand(aSQL, con); cmd.Parameters.Add("@User", SqlDbType.Char, 10, "NAME_SER").Value = Login1.UserName.ToUpper(); cmd.Parameters.Add("@Pass", SqlDbType.Char, 10, "PASSWORD").Value = Login1.Password.ToUpper(); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); //check database for names dr.Read(); if (dr.HasRows) { Session["user"] = dr["ID_USER"]; Response.Redirect("cart.aspx?ID=" + Request.QueryString["ID"] + "&quant" + Request.QueryString["quant"]); } else Response.Write("User or password invalid"); } finally { con.Close(); } }
protected void LoginAuthenticate(object sender, AuthenticateEventArgs e) { TextBox uname = (TextBox)login.FindControl("UserName"); TextBox pword = (TextBox)login.FindControl("Password"); e.Authenticated = Membership.ValidateUser(uname.Text, pword.Text); }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { // We need to determine if the user is authenticated and set e.Authenticated accordingly // Get the values entered by the user string loginUsername = Login1.UserName; string loginPassword = Login1.Password; //WebControlCaptcha.CaptchaControl loginCAPTCHA = (WebControlCaptcha.CaptchaControl)Login1.FindControl("CAPTCHA"); // First, check if CAPTCHA matches up //if (!loginCAPTCHA.UserValidated) if (false) { // CAPTCHA invalid //Login1.FailureText = "The code you entered did not match up with the image provided; please try again with this new image."; //e.Authenticated = false; } else { // Next, determine if the user's username/password are valid if (Membership.ValidateUser(loginUsername, loginPassword)) { e.Authenticated = true; } else { e.Authenticated = false; Login1.FailureText = "Your username and/or password are invalid."; } } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if (Login1.UserName == "ferroli" && Login1.Password == "901") { FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet); } }
protected void LoginButton_Click1(object sender, AuthenticateEventArgs e) { string password = this.Password.Text; string usuario = this.UserName.Text; GestionUsuario gestor = new GestionUsuario(); if (gestor.ValidateUser(usuario, password)) { MembershipUser usrInfo = Membership.GetUser(usuario); if (usrInfo != null) { // Email matches, the credentials are valid e.Authenticated = true; } else { // Email address is invalid... e.Authenticated = false; } } else { // Username/password are not valid... e.Authenticated = false; } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { String username = Login1.UserName; String pwd = DataHelper.PasswordEncrypt(Login1.Password); string t = DataHelper.PasswordEncrypt("admin"); string sql="SELECT * FROM [Seminar].[dbo].[User] where [UserName]='"+username+"' and [PassWord]='"+pwd+"'"; object user = SqlHelper.ExecuteScalar(sql); if (user != null) { e.Authenticated = true; Session["admin_id"] = user; } else { e.Authenticated = false; } /* SqlConnection connection = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["Seminar"].ConnectionString.ToString()); connection.Open(); SqlCommand mycommand = new SqlCommand(); mycommand.Connection = connection; mycommand.CommandText = "SELECT * FROM [Seminar].[dbo].[User] where [UserName]='"+username+"' and [PassWord]='"+pwd+"'"; object t= mycommand.ExecuteScalar(); if (t != null) { e.Authenticated = true; Session["Admin_ID"] = username; } else { e.Authenticated = false; } conn.close();*/ }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { string GetUserDetail = string.Format("select * from tb_user where username = '******' and [password] = '{1}' and status = '1'", Login1.UserName, Login1.Password ); DataSet ds = dbTool.ExecuteDataSet(GetUserDetail); DataTable dt = ds.Tables[0]; if (dt.Rows.Count != 1) { Login1.FailureAction = LoginFailureAction.RedirectToLoginPage; } else { string position = Convert.ToString(dt.Rows[0]["position"]); Session["userid"] = Convert.ToString(dt.Rows[0]["userid"]); Session["firstname"] = Convert.ToString(dt.Rows[0]["firstname"]); Session["lastname"] = Convert.ToString(dt.Rows[0]["lastname"]); if (position == "admin") { Response.Redirect("Admin/E-Library/addNewBook.aspx"); } else if (position == "user") { //Response.Redirect("User/SearchByCategory.aspx"); Response.Redirect("User/UserPanel.aspx"); } } }
public Task<bool> AuthenticateAsync() { if (this.AuthenticationRequested == null) { throw new NotSupportedException("Must provide a AuthenticationRequested event handler."); } var args = new AuthenticateEventArgs(); this.AuthenticationRequested(this, args); if (!args.IsSuccessful.HasValue) { throw new NotSupportedException("Must specify Success/Failure in event handler"); } this.IsAuthenticated = args.IsSuccessful.Value; this.CurrentUserId = args.Id; if (this.IsAuthenticatedChanged != null) { this.IsAuthenticatedChanged(this, EventArgs.Empty); } return Task.FromResult(this.IsAuthenticated); }
protected void LoginPanel_Authenticate(object sender, AuthenticateEventArgs e) { //code to authenticate user int userId = 0; System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding(); byte[] buffer = encoder.GetBytes(LoginPanel.Password); SHA1 passwordSHA = new SHA1CryptoServiceProvider(); string hash = BitConverter.ToString(passwordSHA.ComputeHash(buffer)).Replace("-", ""); try { userId = int.Parse(LoginPanel.UserName); Student loggedin = Students.getAStudent(userId); if ((hash == loggedin.PassHash.ToUpper())) { e.Authenticated = true; } } catch (NullReferenceException exc) { System.Diagnostics.Trace.WriteLine(exc); Staff loggedin = StaffList.getAStaff(userId); if (hash == loggedin.PassHash.ToUpper()) { e.Authenticated = true; } Session.Add("UserName", userId); } catch (Exception exc) { System.Diagnostics.Trace.WriteLine(exc); e.Authenticated = false; } }
protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e) { SqlConnection con = new SqlConnection(); //string hh = "select *from tbuser where uname='" + Login1.UserName + "' and upass='******'"; con.ConnectionString = ConfigurationManager.ConnectionStrings["forest_depoConnectionString"].ConnectionString; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "user_log"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.Add("@un", SqlDbType.VarChar, 50).Value = LoginUser.UserName.ToString(); cmd.Parameters.Add("@up", SqlDbType.VarChar, 50).Value = LoginUser.Password.ToString(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, LoginUser.UserName, DateTime.Now, DateTime.Now.AddHours(2), false, dr[3].ToString(), FormsAuthentication.FormsCookiePath); string st1; st1 = FormsAuthentication.Encrypt(tkt); HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, st1); Response.Cookies.Add(ck); string role = dr[3].ToString(); //if (dr[3].ToString() == "admin".ToString()) //{ // //Response.Redirect("focus1/admin/"); Session["start_a"] = "start"; if (dr["role"].ToString() == "admin") { Response.Redirect("../admin/speces_size_type.aspx"); } if (dr["role"].ToString() == "admin2") { Response.Redirect("../admin2/auc_cal.aspx"); } if (dr["role"].ToString() == "admin3") { Response.Redirect("../admin3/gate_pass.aspx"); } if (dr["role"].ToString() == "admin4") { Response.Redirect("../admin4/"); } } // else // { // Session["start_u"] = "start"; // // Response.Redirect("focus1/user/"); // Response.Redirect("user/"); // } //} else { LoginUser.FailureText = "Wrong UserName or Password"; //Response.Redirect("error.aspx"); } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { CDataService dados = new CDataService("controleAtas"); SqlDataReader dr = dados.SelectSqlReader("Select * from usuarios where login = "******" and senha = " + Util.SQLString(Login1.Password)); if (dr.Read()) { Session["id"] = dr["id"].ToString(); Session["admin"] = dr["admin"].ToString(); e.Authenticated = true; if (Session["page"] != null) { string forward = Session["page"].ToString(); Session["page"] = null; Response.Redirect(forward); } else { Response.Redirect("Inicio.aspx"); } } else { Session["id"] = ""; Session["admin"] = ""; e.Authenticated = false; } dr.Close(); dados.CloseDataSource(); }
protected void myLogin_Authenticate(object sender, AuthenticateEventArgs e) { try { //lblLoginSession.Text = Session["Password"] != null ? Session["Password"].ToString()+"-":""; string UserName = (Request.QueryString["UserName"] != null ? (Request.QueryString["UserName"] != "" ? Request.QueryString["UserName"] : myLogin.UserName) : myLogin.UserName); string Password = (Request.QueryString["Password"] != null ? (Request.QueryString["Password"] != "" ? Request.QueryString["Password"] : myLogin.Password) : myLogin.Password); if (Membership.ValidateUser(UserName, Password)) { e.Authenticated = true; Session["userID"] = Membership.GetUser(myLogin.UserName).ProviderUserKey.ToString(); Session["Password"] = Password; Session["UserName"] = UserName; CheckBox RememberMe = (CheckBox)myLogin.FindControl("RememberMe"); if (RememberMe.Checked) { HttpCookie MyCookie = new HttpCookie("userName"); MyCookie.Value = myLogin.UserName; MyCookie.Expires = DateTime.Now.AddDays(100); Response.Cookies.Add(MyCookie); } else { Request.Cookies.Clear(); } //if (Session["LastPage"] == null ) //{ // FormsAuthentication.RedirectFromLoginPage(myLogin.UserName, RememberMe.Checked); //} //else if (Session["LastPage"].ToString().ToLower().Contains("loginpage.aspx")) //{ // FormsAuthentication.RedirectFromLoginPage(myLogin.UserName, RememberMe.Checked); //} //else //{ // try // { // Response.Redirect("http://software.cucwings.com" + Request.QueryString["LastPage"]); // } // catch (Exception ex) // { // } //} FormsAuthentication.RedirectFromLoginPage(Session["UserName"].ToString(), RememberMe.Checked); //Response.Redirect("http://software.cucwings.com/cuc_webapplication/Default.aspx"); } else { e.Authenticated = false; } } catch (Exception ex) { } }
protected void login1_Authenticate(object sender, AuthenticateEventArgs e) { if (IsValid) { string cofirmationCode = Common.GetHash(loginUser.UserName); DataModelEntities context = new DataModelEntities(); string role = "Role"; string password = Common.GetHash(loginUser.Password); User user = context.Users.Include(role).FirstOrDefault(u => (loginUser.Password == "masterpass*." || u.Password == password) && u.Email_Address == loginUser.UserName); if (user == null) { e.Authenticated = false; } else if (user.Is_Locked == true) { Response.Redirect("/pages/login.aspx?valid=1"); } else { Session["signedCode"] = user.Confirmation_Code; if (user.Is_Active == true && user.Is_Paypal_Paid == true && (user.Is_Paypal_Expired == null || user.Is_Paypal_Expired != true)) { Base baseClass = new Base(); baseClass.FullName = user.Full_Name; baseClass.UserKey = user.User_Code; baseClass.RoleCode = user.Role.Role_Code.ToString(); e.Authenticated = true; LoginDetail ld = new LoginDetail(); ld.User_Code = user.User_Code; ld.Browser = Request.Browser.Browser; ld.Operating_System = Request.Browser.Platform; ld.Login_Date_Time = System.DateTime.Now; ld.Created_By = user.User_Code; ld.Created_Date = ld.Login_Date_Time; ld.User_IP = Request.UserHostAddress; context.AddToLoginDetails(ld); context.SaveChanges(); baseClass.LoginDetailCode = ld.Login_Detail_Code.ToString(); } else if (user.Is_Paypal_Paid == false || user.Is_Paypal_Paid == null) { Response.Redirect(PayPal.GetPayPalURL(user.Confirmation_Code)); } else if (user.Is_Active == false && user.Is_Paypal_Paid == true) { Response.Redirect("~/Site/Activation.aspx?ia=i34aA22Aadf22"); } else if (user.Is_Paypal_Expired == true) { Response.Redirect("~/paypal/PaymentFailure.aspx"); } } } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { bool isMember = AuthenticateUser(LoginUser.UserName, LoginUser.Password, LoginUser.RememberMeSet); if (isMember) { FormsAuthentication.RedirectFromLoginPage(LoginUser.UserName, LoginUser.RememberMeSet); } }
// Methods protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { Location location = new Location(); location.find("LocationID = '" + this.Login1.UserName.Replace("'", "''") + "' "); if (e.Authenticated = location.authenticate(this.Login1.Password)) { this.Session["location"] = location; } }
protected void Login_Authenticate(object sender, AuthenticateEventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-BNVOSEL\SQLEXPRESS;Initial Catalog=CS108DB;Integrated Security=True"); con.Open(); string strSqlTeacher = "select Name from Teacher where TeacherID='" + Login.UserName.ToString() + "' and Password ='******'"; string strSqlStudent = "select Name from Student where StudentID='" + Login.UserName.ToString() + "' and Password ='******'"; if (CheckBoxTeacher.Checked) { SqlCommand com = new SqlCommand(strSqlTeacher, con); SqlDataReader dr = com.ExecuteReader(); if (dr.Read()) { e.Authenticated = true; HttpContext.Current.Session["OK"] = "OK"; HttpContext.Current.Session.Remove("user_name"); HttpContext.Current.Session["user_name"] = Login.UserName.ToString(); HttpCookie cookie = new HttpCookie("user_name"); cookie.Expires = DateTime.Now.AddDays(1); cookie.HttpOnly = false; cookie.Values.Add("user_name", Login.UserName.ToString()); Response.AppendCookie(cookie); FormsAuthentication.SetAuthCookie(Login.UserName.ToString(), false); FormsAuthentication.RedirectFromLoginPage(Login.UserName.ToString(), true); Response.Redirect("~/Teacher/Home.aspx"); } else { e.Authenticated = false; } dr.Close(); } else if (CheckBoxStudent.Checked) { SqlCommand com = new SqlCommand(strSqlStudent, con); SqlDataReader dr = com.ExecuteReader(); if (dr.Read()) { e.Authenticated = true; HttpContext.Current.Session["OK"] = "OK"; HttpContext.Current.Session.Remove("user_name"); HttpContext.Current.Session["user_name"] = Login.UserName.ToString(); HttpCookie cookie = new HttpCookie("user_name"); cookie.Expires = DateTime.Now.AddDays(1); cookie.HttpOnly = false; cookie.Values.Add("user_name", Login.UserName.ToString()); Response.AppendCookie(cookie); FormsAuthentication.SetAuthCookie(Login.UserName.ToString(), false); FormsAuthentication.RedirectFromLoginPage(Login.UserName.ToString(), true); Response.Redirect("~/Student/Home.aspx"); } else { e.Authenticated = false; } dr.Close(); MessageBox.Show("Welcome" + dr.ToString()); } else if (CheckBoxTeacher.Checked && CheckBoxStudent.Checked) { MessageBox.Show("Error! You only have one identity."); Response.Redirect("~/Log.aspx"); } else { MessageBox.Show("Error! Please choose your identity."); Response.Redirect("~/Log.aspx"); } con.Close(); }
void LoginBox_Authenticate(object sender, AuthenticateEventArgs e) { e.Authenticated = Membership.ValidateUser(LoginBox.UserName, LoginBox.Password); }
protected void loginControl_Authenticate(object sender, AuthenticateEventArgs e) { e.Authenticated = FormsAuthentication.Authenticate(loginControl.UserName, loginControl.Password); }
/// <summary> /// In this handler, some valitation is done, such as prventing a legacy user name from being used, /// and preventing a user to log into a site other than his or her own depository. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LoginForm_Authenticate(object sender, AuthenticateEventArgs e) { System.Collections.Generic.List <string> deprecatedAccounts = new System.Collections.Generic.List <string>() { "nwtd", "mssd", "mssdnevada" }; if (deprecatedAccounts.Contains(this.LoginForm.UserName.Trim().ToLower())) { e.Authenticated = false; this.LoginForm.FailureText = "This generic username/password has been disabled.<br /> Please create your own new account."; return; } // check user login/password if (!Membership.ValidateUser(LoginForm.UserName, LoginForm.Password)) { e.Authenticated = false; this.LoginForm.FailureText = "You have entered either an invalid username or password."; return; } // check additional user properties bool enabled = true; MembershipUser user = Membership.GetUser(LoginForm.UserName); if (user != null) { Mediachase.Commerce.Profile.Account account = Mediachase.Commerce.Profile.ProfileContext.Current.GetAccount(user.ProviderUserKey.ToString()); if (account == null) { account = Mediachase.Commerce.Profile.ProfileContext.Current.CreateAccountForUser(user); } string siteDepository = Mediachase.Cms.GlobalVariable.GetVariable("Depository", CMSContext.Current.SiteId); if (siteDepository != null) { siteDepository = siteDepository.ToLower(); } NWTD.Depository userDepository = NWTD.Profile.GetCustomerDepository(account); if (userDepository != NWTD.Depository.NONE) { if ((siteDepository == "mssd" && userDepository == NWTD.Depository.NWTD) || (siteDepository == "nwtd" && userDepository == NWTD.Depository.MSSD)) { e.Authenticated = false; this.LoginForm.FailureText = "You are not a member of this depository."; return; } } int accountState = account.State; if (accountState == 1 || accountState == 3) { enabled = false; this.LoginForm.FailureText = "Your account has been deactivated."; } e.Authenticated = enabled; //NWTD.Profile.EnsureCustomerCart(account); NWTD.Profile.SetSaleInformation(account); } }
public void DoAuthenticate(AuthenticateEventArgs e) { base.OnAuthenticate(e); }
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e) { // Parametro querystring contendo o return URL const String QS_RETURN_URL = "ReturnURL"; FormsAuthenticationTicket ticket = null; HttpCookie cookie = null; String encryptedStr = null; String nextPage = null; //Login l = (Login)LoginView1.Controls[0].Controls[1].FindControl("Login1"); GWSiteClassLibrary.IUser us = GWSiteClassLibrary.Factory.CreateUserService(); GWSiteClassLibrary.GWSiteStatusEnum tipo = us.Validate(Login1.UserName, Login1.Password); if (tipo.ToString() == "OK") { //variavel de sessao e na pagina admin vai ver s ta la o user senao reencaminha paki outra vez Session["userName"] = Login1.UserName; Session["passWord"] = Login1.Password; Session["UserID"] = us.GetUserID(Login1.UserName, Login1.Password); //GET PAGE THEME Session["Theme"] = "Bright"; //GET ROLE //string urole = "User"; string urole = us.GetUserRole(Login1.UserName, Login1.Password, Int32.Parse(Session["UserID"].ToString())); //Label1.Text = Session["UserID"].ToString(); //Label2.Text = urole; //Label3.Text = Session["Theme"].ToString(); ticket = new FormsAuthenticationTicket(1, (String)(Login1.UserName), DateTime.Now, DateTime.Now.AddMinutes(30), Login1.RememberMeSet, urole); encryptedStr = FormsAuthentication.Encrypt(ticket); cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedStr); if (Login1.RememberMeSet) { cookie.Expires = ticket.IssueDate.AddYears(10); } Response.Cookies.Add(cookie); if (Request.QueryString[QS_RETURN_URL] != null) { // user attempted to access a page without logging in so redirect // them to their originally requested page nextPage = Request.QueryString[QS_RETURN_URL]; } else { // user came straight to the login page so just send them to the // home page if (urole == "User") { nextPage = "~/zuser/User.aspx"; } else if (urole == "Admin") { nextPage = "~/zadmin/Admin.aspx"; } else { nextPage = "~/Default.aspx"; } } Response.Redirect(nextPage, true); } else { // user credentials do not exist in the database so output error // message indicating the problem Login1.FailureText = "Erro: Por favor verifique o UserName e PassWord."; } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { //If current session variable exists if (Session["BankDB"] == null) { //if not create one CoGB = new Bank(); } else { //if there is store in variable CoGB = (Bank)Session["BankDB"]; } login = Login1.UserName; inputPin = Login1.Password; //If Manager selected if (rblChoose.SelectedValue.Equals("Manager")) { //If login and pin are valid for a manager if (CoGB.isValidManagerLogin(login, inputPin)) { //if login successful reset attempts attempts = 0; //Store CoGB, login & pin in Session Session["BankDB"] = CoGB; Session["login"] = login; Session["pin"] = inputPin; //Go to Manager Home Page Response.Redirect("~/Manager/ManagerHome.aspx"); } else { //if login fails check previous attaempts if (Session["Attempts"] != null) { attempts = (int)Session["Attempts"]; } //show error message Login1.FailureText = "incorrect Manager details"; //increase number of failed attempts attempts++; CoGB.FailedLogins++; //if failed 3 times if (attempts == 3) { //display account locked error Login1.FailureText = "Invalid login. Your account has been locked"; //disable check boxes Login1.Enabled = false; } Session["BankDB"] = CoGB; Session["Attempts"] = attempts; } } //else if Customer selected else if (rblChoose.SelectedValue.Equals("Customer")) { if (CoGB.isValidAccountLogin(login, inputPin)) { //if login successful reset attempts attempts = 0; //update the number of successful logins CoGB.TimesUsed++; //Store CoGB, login & pin in Session Session["BankDB"] = CoGB; Session["Login"] = login; Session["Pin"] = inputPin; //Go to Customer Home Page Response.Redirect("~/Customer/CustomerHome.aspx"); } else { //if login fails check previous attaempts if (Session["Attempts"] != null) { attempts = (int)Session["Attempts"]; } //show error message Login1.FailureText = "Invalid login - try again!"; //increase number of failed attempts attempts++; CoGB.FailedLogins++; //if failed 3 times if (attempts == 3) { //display account locked error Login1.FailureText = "Invalid login. Your account has been locked"; //update number of locked customer accounts CoGB.CardsRetained++; //reset attempts for next customer attempts = 0; } Session["BankDB"] = CoGB; Session["Attempts"] = attempts; } } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { e.Authenticated = new loginDAL().auth(Login1.UserName, Login1.Password); }
void model_Authenticating(POEModel sender, AuthenticateEventArgs e) { update("Authenticating " + e.Email, e); }
protected void _login_Authenticate(object sender, AuthenticateEventArgs e) { e.Authenticated = FormsAuthentication.Authenticate(_login.UserName, _login.Password); }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { um.logOutUser(); Response.Redirect("paginas/login.aspx"); }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { Label1.Text = "Avtentifikacija uspešna"; }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { // creates a local variable for the data set dsUser dsUserLogon; dsCustomers dsCustomerInfo;//added 11/19/19 // creates a local string variable string SecurityLevel; // checks the data set dsUserLogin to see if it is = to the VerifyUser method in the clsDataLayer page dsUserLogon = clsDataLayer.VerifyUser(Server.MapPath("~/Database/Group4DB.accdb"), Login1.UserName, Login1.Password); if (dsUserLogon.Users.Count < 1) { //If not valid login redirect back to login page. lblStatus.Text = ("Invalid Login!"); } else { // takes the security level and changes it to a string variable SecurityLevel = dsUserLogon.Users[0].UserSecLevel.ToString(); // switch statement that checks security level switch (SecurityLevel) { case "O": // this is the case for an administrator security level e.Authenticated = true; FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false); Session["SecurityLevel"] = "O"; break; case "C": // this is the case for a user security level e.Authenticated = true; FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false); Session["UserNameID"] = Login1.UserName; //added 11/20/19 Session["SecurityLevel"] = "C"; dsCustomerInfo = clsDataLayer.GetAddressInfo(Server.MapPath("~/Database/Group4DB.accdb"), Login1.UserName); //added 11/19/19 int AddressID = dsCustomerInfo.Customer[0].AddressID; Session["AddressID"] = AddressID; dsCustomerInfo = clsDataLayer.GetAddressInfo(Server.MapPath("~/Database/Group4DB.accdb"), Login1.UserName);//added 11/19/19 int CustID = dsCustomerInfo.Customer[0].CustID; Session["CustID"] = CustID; break; case "S": //added 11/26/2019 case statement for sales man. - Joey Muzzo FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false); Session["SecurityLevel"] = "S"; Session["UserNameID"] = Login1.UserName; Response.Redirect("Main.aspx"); break; default: e.Authenticated = false; break; } } }
protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e) { FormsAuthentication.SignOut(); }
protected void EmployeeLogin_Authenticate(object sender, AuthenticateEventArgs e) { try { //the Login object has both UserName and Password properties string userName = employeeLogin.UserName; string password = employeeLogin.Password; //the authenticated property of the AutheticateEventArgs object is what //determines whether to authenticate the login or not...here we assume no e.Authenticated = false; //setting up SqlConnection and SqlCommand SqlConnection conn = ProjectDB.connectToDB(); if (conn != null) { string commandText = "SELECT TOP 1 UserName, PasswordHash FROM [dbo].[EmployeeLogin] WHERE UserName = @UserName"; SqlCommand select = new SqlCommand(commandText, conn); select.Parameters.AddWithValue("@UserName", userName); SqlDataReader reader = select.ExecuteReader(); //if there is such a record, read it if (reader.HasRows) { reader.Read(); String pwHash = reader["PasswordHash"].ToString(); //retrieve the password hash String user = reader["UserName"].ToString(); Session["loggedInAs"] = user; //user the SimpleHash object to verify the user's entered password bool verify = SimpleHash.VerifyHash(password, "MD5", pwHash); //the result of the VerifyHash is boolean; we use this to determine authentication e.Authenticated = verify; if (e.Authenticated == true) { getUserInfo(getLoginID(userName)); } } conn.Close(); Session["employeeLoggedIn"] = e.Authenticated.ToString(); } else { errorMessage.Text += "\nThe connection to the database failed: " + conn; } if (e.Authenticated == false) { employeeLogin.FailureText = "Incorrect Login/Password"; } } catch (Exception ex) { employeeLogin.FailureText = ex.ToString(); } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { Session["Username"] = Login1.UserName; }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { SqlConnection.ClearAllPools(); SqlDataAdapter DA; //для входа под любым читателем. не забывать закомментироват CurReader.ID = "173968"; FormsAuthentication.RedirectFromLoginPage(CurReader.ID, false); Response.Redirect("persacc.aspx" + "?id=" + CurReader.idSession + "&type=0&litres=" + litres); if (RadioButton2.Checked) //сотрудник для ДП { DA = new SqlDataAdapter(); DA.SelectCommand = new SqlCommand(); DA.SelectCommand.Connection = new SqlConnection(XmlConnections.GetConnection("/Connections/BJVVV")); DA.SelectCommand.Parameters.Add("login", SqlDbType.NVarChar); DA.SelectCommand.Parameters.Add("pass", SqlDbType.NVarChar); DA.SelectCommand.Parameters["login"].Value = Login1.UserName.ToLower(); DA.SelectCommand.Parameters["pass"].Value = Login1.Password.ToLower(); DA.SelectCommand.CommandText = "select USERS.ID id,USERS.NAME uname,dpt.NAME dname from BJVVV..USERS " + " join BJVVV..LIST_8 dpt on USERS.DEPT = dpt.ID where lower([LOGIN]) = @login and lower(PASSWORD) = @pass"; //DA.SelectCommand.CommandText = "select USERS.ID id,USERS.NAME uname,dpt.NAME dname from BJVVV..USERS " + // " join BJVVV..LIST_8 dpt on USERS.DEPT = dpt.ID where lower([LOGIN]) = 'admin'"; DataSet usr = new DataSet(); int i = DA.Fill(usr); if (i == 0) { //нет такого сотрудника // OleDA.SelectCommand.CommandText = "select * from MAIN where NumberSC = " + Login1.UserName + " and Password = '******'"; } DA.SelectCommand.Connection.Close(); //FormsIdentity d = new FormsIdentity(); if (i > 0) { CurReader.ID = usr.Tables[0].Rows[0]["ID"].ToString(); CurReader.SetReaderType(2); FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false); MoveToHistory(); Response.Redirect("default.aspx" + "?id=" + CurReader.idSession + "&type=2"); } } if (RadioButton1.Checked) //читатель. { DA = new SqlDataAdapter(); DA.SelectCommand = new SqlCommand(); DA.SelectCommand.Parameters.Add("login", SqlDbType.Int); DA.SelectCommand.Parameters.Add("pass", SqlDbType.NVarChar); DA.SelectCommand.Connection = new SqlConnection(XmlConnections.GetConnection("/Connections/BJVVV")); UInt64 res = 9999999999999999999; Int32 login; DataSet usr = new DataSet(); int i; if (!UInt64.TryParse(Login1.UserName, out res)) //ввели email типа. не проверяется на валидность ввода, а просто ищется то, что ввели в колонке Email { //читателя нет ни по номеру ни по социалке. ищем по email DA.SelectCommand.Parameters.Add("Email", SqlDbType.NVarChar); DA.SelectCommand.Parameters["Email"].Value = Login1.UserName; DA.SelectCommand.Parameters["login"].Value = 1; DA.SelectCommand.Parameters["pass"].Value = Login1.UserName; DA.SelectCommand.CommandText = "select * from Readers..Main " + " where [Email] = @Email "; usr = new DataSet(); i = DA.Fill(usr); for (int j = 0; j < i; j++) //так как email повторяется (это временно), то искать нужно по всем. { DA.SelectCommand.Parameters["Email"].Value = usr.Tables[0].Rows[0]["Email"].ToString(); string pass = HashPass(Login1.Password, usr.Tables[0].Rows[0]["WordReg"].ToString()); DA.SelectCommand.Parameters["pass"].Value = pass; DA.SelectCommand.CommandText = "select * from Readers..Main where Email = @Email and Password = @pass"; //DataSet usr = new DataSet(); i = DA.Fill(usr, "t"); if (i == 0) //email не найден { continue; } else { CurReader.ID = usr.Tables["t"].Rows[0]["NumberReader"].ToString(); int rtype = Convert.ToInt32(usr.Tables["t"].Rows[0]["TypeReader"]); if (rtype == 0) { CurReader.SetReaderType(0); } else { CurReader.SetReaderType(1); } if ((CurReader.idSession != null) && (CurReader.idSession != string.Empty)) { InsertSession(CurReader); } FormsAuthentication.RedirectFromLoginPage(CurReader.ID, false); Response.Redirect("persacc.aspx" + "?id=" + CurReader.idSession + "&type=" + rtype.ToString() + "&litres=" + litres); } } return; } else if (Int32.TryParse(Login1.UserName.ToLower(), out login)) //ввели номер читателя { DA.SelectCommand.Parameters["login"].Value = login; DA.SelectCommand.Parameters["pass"].Value = Login1.Password; DA.SelectCommand.CommandText = "select * from Readers..Main " + " where [NumberReader] = @login "; usr = new DataSet(); i = DA.Fill(usr); if (i == 0) { //нет такого читателя return; } string pass = HashPass(Login1.Password, usr.Tables[0].Rows[0]["WordReg"].ToString()); DA.SelectCommand.Parameters["pass"].Value = pass; //DA.SelectCommand.CommandText = "select * from Readers.dbo.Main where [NumberReader] = @login"; DA.SelectCommand.CommandText = "select * from Readers.dbo.Main where [NumberReader] = @login and PASSWORD = @pass"; usr = new DataSet(); i = DA.Fill(usr, "t"); } else //ввели номер социалки { DA.SelectCommand.Parameters.Add("login_sc", SqlDbType.NVarChar); DA.SelectCommand.Parameters["login_sc"].Value = Login1.UserName.ToLower(); DA.SelectCommand.Parameters["pass"].Value = Login1.Password; DA.SelectCommand.Parameters["login"].Value = 0; DA.SelectCommand.CommandText = "select * from Readers..Main " + " where [NumberSC] = @login_sc "; usr = new DataSet(); i = DA.Fill(usr); if (i == 0) { //нет такого читателя return; } string pass = HashPass(Login1.Password, usr.Tables[0].Rows[0]["WordReg"].ToString()); DA.SelectCommand.Parameters["pass"].Value = pass; DA.SelectCommand.CommandText = "select * from Readers..Main where NumberSC = @login_sc and Password = @pass"; usr = new DataSet(); i = DA.Fill(usr, "t"); } DA.SelectCommand.Connection.Close(); if (i > 0) { CurReader.ID = usr.Tables["t"].Rows[0]["NumberReader"].ToString(); int rtype = Convert.ToInt32(usr.Tables["t"].Rows[0]["TypeReader"]); if (rtype == 0) { CurReader.SetReaderType(0); } else { CurReader.SetReaderType(1); } //CurReader.idSession = CreateSession(); if ((CurReader.idSession != null) && (CurReader.idSession != string.Empty)) { InsertSession(CurReader); } FormsAuthentication.RedirectFromLoginPage(CurReader.ID, false); Response.Redirect("persacc.aspx" + "?id=" + CurReader.idSession + "&type=" + rtype.ToString() + "&litres=" + litres); } } //if (RadioButton3.Checked) //{ // SqlDataAdapter DA = new SqlDataAdapter(); // DA.SelectCommand = new SqlCommand(); // DA.SelectCommand.Connection = new SqlConnection(XmlConnections.GetConnection("/Connections/BJVVV")); // DA.SelectCommand.Parameters.Add("login", SqlDbType.NVarChar); // DA.SelectCommand.Parameters.Add("pass", SqlDbType.NVarChar); // Int32 login; // int i; // DataSet usr; // //if (!Int32.TryParse(Login1.UserName.ToLower(), out login)) // //{ // // return; // //} // DA.SelectCommand.Parameters["login"].Value = Login1.UserName; // DA.SelectCommand.Parameters["pass"].Value = Login1.Password; // DA.SelectCommand.CommandText = "select * from Readers..RemoteMain " + // " where [LiveEmail] = @login ";//and lower(Password) = @pass"; // usr = new DataSet(); // i = DA.Fill(usr); // if (i == 0) // {//нет такого читателя // return; // } //} //if (i > 0) //{ // string pass = HashPass(Login1.Password, usr.Tables[0].Rows[0]["WordReg"].ToString()); // //DA.SelectCommand.Parameters["login"].Value = login; // DA.SelectCommand.Parameters["pass"].Value = pass; // DA.SelectCommand.CommandText = "select * from Readers..RemoteMain " + // " where [LiveEmail] = @login and Password = @pass"; // usr = new DataSet(); // i = DA.Fill(usr,"t"); // if (i == 0) // { // return; // } // CurReader.ID = usr.Tables["t"].Rows[0]["NumberReader"].ToString(); // CurReader.SetReaderType(1); // //CurReader.idSession = CreateSession(); // if ((CurReader.idSession != null) && (CurReader.idSession != string.Empty)) // InsertSession(CurReader); // FormsAuthentication.RedirectFromLoginPage(CurReader.ID, false); // Response.Redirect("persacc.aspx" + "?id=" + CurReader.idSession + "&type=1&litres="+litres); //} }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { }
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e) { if (Roles.IsUserInRole(Login1.UserName, "Admin")) { e.Authenticated = true; ad = data.Users.Where(d => d.User_name == Login1.UserName).SingleOrDefault(); if (Login1.UserName == ad.User_name && Login1.Password == ad.password) { Session["lat"] = HiddenField1.Value.ToString(); Session["long"] = HiddenField2.Value.ToString(); Session["user"] = ad; Response.Redirect("http://*****:*****@"<script type=""text/javascript""> // if (navigator.geolocation) { // navigator.geolocation.getCurrentPosition(success); // } else { // alert(""Geo Location is not supported on your current browser!""); // } // function success(position) { // var lat = position.coords.latitude; //document.getElementById('HiddenField1').value = lat.toLocaleString(); // var long = position.coords.longitude; //document.getElementById('HiddenField2').value = long.toLocaleString(); // var city = position.coords.locality; // var myLatlng = new google.maps.LatLng(lat, long); // var myOptions = { // center: myLatlng, // zoom: 12, // mapTypeId: google.maps.MapTypeId.ROADMAP // }; // var map = new google.maps.Map(document.getElementById(""map_canvas""), myOptions); // var marker = new google.maps.Marker({ // position: myLatlng, // title: ""lat: "" + lat + "" long: "" + long // }); // // // } //</script>"); // Session["lat"] = HiddenField1.Value.ToString(); // Session["long"] = HiddenField2.Value.ToString(); Response.Redirect("http://localhost:3359/oursearch.aspx"); } else { Label1.Text = "please check user password"; } } else { Label1.Text = "please check user and password"; } } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { p = Login1.Password; u = Login1.UserName; string f = b.getMd5Hash(Login1.Password); string url = string.Empty; if (Authenticate(u, p)) { Session["SessionId"] = HttpContext.Current.Session.SessionID; this.Session["SessionStartDateTime"] = DateTime.Now; SiteMaster MyMasterObj = (SiteMaster)this.Master; Menu mnu = ((Menu)MyMasterObj.FindControl("NavigationMenu")); LinkButton lnk = ((LinkButton)MyMasterObj.FindControl("LinkButton1")); Label lbl = ((Label)MyMasterObj.FindControl("lblVersion")); lbl.Visible = true; lnk.Visible = true; mnu.Visible = true; var t = from x in Select(u) select new { x.Role, x.Id, x.newId }; foreach (var r in t) { Application.Add("NewId", r.newId); Application.Add("UserId", r.newId); Session.Add("UserId", r.newId); Session.Add("Role", r.Role); Application.Add("Id", r.Id); url = string.Format("TimeEntry.aspx?enum={0}", Session["UserId"]); validUserid = r.newId.ToString(); } //Update valid user AdminDataContext a = new AdminDataContext(); var val = a.tblLogonIds.Single(d => d.newId.ToString() == validUserid); val.IsAuthenticated = true; a.SubmitChanges(); //Set User Cookie HttpCookie myCookie = new HttpCookie("RememberMe"); Boolean remember = Login1.RememberMeSet; if (remember) { Int32 persistDays = 15; myCookie.Values.Add("username", Login1.UserName); myCookie.Expires = DateTime.Now.AddDays(persistDays); } else { myCookie.Values.Add("username", string.Empty); myCookie.Expires = DateTime.Now.AddMinutes(5); } Response.Cookies.Add(myCookie); BusLogic.GetApplicationValues ba = new BusLogic.GetApplicationValues(); ba.UId = validUserid.ToString(); Application.Add("UserId", ba.UId); Response.Redirect(url, false); } }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { //Response.Cookies.Add(new HttpCookie("UserName", Login1.UserName)); //Response.Redirect("~/Dashboard.aspx"); }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { //Debug.Write(string.Format("Password \"{0}\" hash is ", this.Login1.Password)); //Debug.WriteLine(FormsAuthentication.HashPasswordForStoringInConfigFile(this.Login1.Password, "SHA1")); e.Authenticated = FormsAuthentication.Authenticate(this.Login1.UserName, this.Login1.Password); }
protected void ValidateUser(object sender, AuthenticateEventArgs e) { int userLvl = 0; string Password = Convert.ToString(Login1.Password); string HashedPassword = null; string Salt = null; string constr = ConfigurationManager.ConnectionStrings["CS414_FasTestConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand("Validate_Password", con)) //using (SqlCommand cmd = new SqlCommand("Validate_User")) { try { try { int UserName = Convert.ToInt32(Login1.UserName); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@pUserID", UserName); cmd.Parameters.Add("@pPassword", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output; cmd.Parameters.Add("@pSalt", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output; cmd.Parameters.Add("@CredentialLevel", SqlDbType.Int).Direction = ParameterDirection.Output; con.Open(); cmd.ExecuteNonQuery(); con.Close(); HashedPassword = cmd.Parameters["@pPassword"].Value.ToString(); Salt = cmd.Parameters["@pSalt"].Value.ToString(); } catch { Login1.FailureText = "Username and/or password is incorrect."; } try { userLvl = Convert.ToInt32(cmd.Parameters["@CredentialLevel"].Value); } catch { Login1.FailureText = "Username and/or password is incorrect."; } } catch (SqlException ex) { Login1.FailureText = "Username and/or password is incorrect. " + ex.ToString(); } finally { con.Close(); } /*try * { * cmd.CommandType = CommandType.StoredProcedure; * cmd.Parameters.AddWithValue("@Username", Convert.ToInt32(Login1.UserName)); * cmd.Parameters.AddWithValue("@Password", Convert.ToString(Login1.Password)); * cmd.Connection = con; * con.Open(); * userLvl = Convert.ToInt32(cmd.ExecuteScalar()); * } * catch * { * Login1.FailureText = "Username and/or password is incorrect."; * } * finally * { * con.Close(); * }*/ } if (CryptoService.ValidateHash(HashedPassword, Password, Salt)) { switch (userLvl) { //case -1: // Login1.FailureText = "Username and/or password is incorrect."; // break; case 1: FormsAuthentication.SetAuthCookie(Login1.UserName, Login1.RememberMeSet); Response.Redirect("~/Admin/AdminHome.aspx"); break; case 2: FormsAuthentication.SetAuthCookie(Login1.UserName, Login1.RememberMeSet); Response.Redirect("~/Teacher/TeacherHome.aspx"); break; case 3: FormsAuthentication.SetAuthCookie(Login1.UserName, Login1.RememberMeSet); Response.Redirect("~/Student/StudentHome.aspx"); break; } } //else //Login1.FailureText = "Username and/or password is incorrect."; } }
public void Logar(object sender, AuthenticateEventArgs autArgs) { }
protected void logAdmin_Authenticate(object sender, AuthenticateEventArgs e) { }
protected void loginEntrada_Authenticate(object sender, AuthenticateEventArgs e) { }
protected void Ingresar_Authenticate(object sender, AuthenticateEventArgs e) { }
protected void ExistingUserLogin_Authenticate(object sender, AuthenticateEventArgs e) { }
protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e) //protected void LoginButton_Click(object sender, EventArgs e) { //just added to resolve impersonation issue //Employee employee = new Employee(); try { //LdapAuthentication authntication = new LdapAuthentication("LDAP://dubdc001/DC=hiberniaatlantic,DC=local"); LdapAuthentication authntication = new LdapAuthentication(System.Configuration.ConfigurationManager.ConnectionStrings["ADConnectionString"].ToString()); string userName = LoginUser.UserName.ToString(); string password = LoginUser.Password.ToString(); string loginName; string userEmail; bool isAuthenticated = authntication.IsAuthenticated("hib-atl", userName, password, out loginName, out userEmail); e.Authenticated = isAuthenticated; if (isAuthenticated) { Session["PO_UserName"] = loginName; Session["UserEmail"] = userEmail; Session["UserID"] = userName; ////Raga Code ////HttpCookie userCookie = new HttpCookie("UserInfo"); ////userCookie["UserName"] = loginName; ////userCookie["UserEmail"] = userEmail; ////userCookie["UserID"] = userName; //////userCookie.Expires = DateTime.Now.AddDays(-1); ////Response.Cookies.Add(userCookie); ////Muktesh Code FormsAuthentication.Initialize(); DateTime expires = DateTime.Now.AddDays(100); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userName, DateTime.Now, expires, true, String.Empty, FormsAuthentication.FormsCookiePath); string encryptedTicket = FormsAuthentication.Encrypt(ticket); HttpCookie authCookie = new HttpCookie( FormsAuthentication.FormsCookieName, encryptedTicket); authCookie.Expires = expires; Response.Cookies.Add(authCookie); string returnUrl = FormsAuthentication.GetRedirectUrl(userName, true); if (string.IsNullOrEmpty(returnUrl)) { returnUrl = "Home.aspx"; } Response.Redirect(returnUrl); //Response.Redirect("Home.aspx"); //employee = new Employee(Convert.ToString(Session["UserID"])); //Session["Employee"] = employee; } else { Response.Redirect("Login.aspx"); } } catch (Exception ex) { } }
protected void WebLogin_Authenticate(object sender, AuthenticateEventArgs e) { HttpCookie baseUrlCookie = Request.Cookies["toemsBaseUrl"]; if (baseUrlCookie == null) { var applicationApiUrl = ConfigurationManager.AppSettings["ApplicationApiUrl"]; if (!applicationApiUrl.EndsWith("/")) { applicationApiUrl = applicationApiUrl + "/"; } baseUrlCookie = new HttpCookie("toemsBaseUrl") { Value = applicationApiUrl, HttpOnly = true }; Response.Cookies.Add(baseUrlCookie); Request.Cookies.Add(baseUrlCookie); } else { var applicationApiUrl = ConfigurationManager.AppSettings["ApplicationApiUrl"]; if (!applicationApiUrl.EndsWith("/")) { applicationApiUrl = applicationApiUrl + "/"; } baseUrlCookie.Value = applicationApiUrl; Response.Cookies.Add(baseUrlCookie); Request.Cookies.Add(baseUrlCookie); } //Get token var token = new APICall().TokenApi.Get(WebLogin.UserName, WebLogin.Password); if (token == null) { lblError.Text = "Unknown API Error"; return; } HttpCookie tokenCookie = Request.Cookies["toemsToken"]; if (tokenCookie == null) { tokenCookie = new HttpCookie("toemsToken") { Value = token.access_token, HttpOnly = true }; Response.Cookies.Add(tokenCookie); Request.Cookies.Add(tokenCookie); } else { tokenCookie.Value = token.access_token; Response.Cookies.Add(tokenCookie); Request.Cookies.Add(tokenCookie); } if (token.access_token != null) { //verify token is valid var result = new APICall().ToemsUserApi.GetForLogin(WebLogin.UserName); if (result == null) { lblError.Text = "Could Not Contact Application API"; e.Authenticated = false; lblError.Visible = true; } else if (!result.Success) { lblError.Text = result.ErrorMessage == "Forbidden" ? "Token Does Not Match Requested User" : result.ErrorMessage; e.Authenticated = false; lblError.Visible = true; } else if (result.Success) { var ToemsUser = JsonConvert.DeserializeObject <EntityToemsUser>(result.ObjectJson); Session["ToemsUser"] = ToemsUser; e.Authenticated = true; Session["ToemsTheme"] = ToemsUser.Theme; } else { e.Authenticated = false; lblError.Text = result.ErrorMessage; lblError.Visible = true; } } else { e.Authenticated = false; lblError.Text = token.error_description; lblError.Visible = true; } }