protected void btn_login_Click(object sender, EventArgs e) { /*1 - Grabbing the user's login info*/ String Username = txb_TUID.Text; String Password = txb_Password.Text; /*2 - Resetting controls to default values*/ lbl_Error.Text = ""; /*3 - Basic validation*/ if (Username.Equals("")) { lbl_Error.Text = "ERROR: The username field is empty."; lbl_Error.ForeColor = Color.Red; } else if (Password.Equals("")) { lbl_Error.Text = "ERROR: The password field is empty."; lbl_Error.ForeColor = Color.Red; } else if (valid.validateLogin(Username) || valid.validateLogin(Password)) { lbl_Error.Text = "ERROR: Illegal input character was used."; lbl_Error.ForeColor = Color.Red; } else { /*3 - Checking that the Username and Password are both correct*/ bool Correct_Login_Information = AuthenticateUser(Username, Password); if (!Correct_Login_Information) { lbl_Error.Text = "ERROR: Your username or password is incorrect."; lbl_Error.ForeColor = Color.Red; } else { /*4 - Requesting Web Service information*/ TempleUser.LDAPuser Temple_Information = TempleUser.WebService.getLDAPEntryByAccessnet(Username); TempleUser.StudentObj Student_Information = TempleUser.WebService.getStudentInfo(Temple_Information.templeEduID); /*5 - Checking we received something from Web Services*/ if (Temple_Information == null) { lbl_Error.Text = "ERROR: Web Services did not return anything."; } else if (Temple_Information != null) { /*Populating the Session Object with the user's information*/ Session["TU_ID"] = Temple_Information.templeEduID;//TUID Session["First_Name"] = Temple_Information.givenName; Session["Last_Name"] = Temple_Information.sn; Session["Email"] = Temple_Information.mail; Session["Title"] = Temple_Information.title; Session["Affiliation_Primary"] = Temple_Information.eduPersonPrimaryAffiliation; Session["Affiliation_Secondary"] = Temple_Information.eduPersonAffiliation; /*Security Session Variable*/ Session["Authenticated"] = true; /*If the user is also a student, we can also retreive their information and add them to the Session Object*/ if (Student_Information != null) { Session["School"] = Student_Information.school; Session["Major_1"] = Student_Information.major1; Session["Major_2"] = Student_Information.major2; } /*Successful Login - Allowed to be redirected to Home.aspx*/ DbMethods DbMethodsObj = new DbMethods(); bool test = DbMethodsObj.CheckIfAdminExists(Student_Information.tuid); //check if user is an Admin if (test == true) { //Security Session Variable for Admin Session["AdminToken"] = true; Response.Redirect("Admin.aspx"); } else { //check if expert exists in system int count = Convert.ToInt32(DbMethodsObj.CheckIfExpertExists(Student_Information.tuid)); if (count == 0) { Response.Redirect("CreateProfile.aspx"); } else { SessionMethods sessionMethodsObj = new SessionMethods(); sessionMethodsObj.storeExpertDataInSession(); //change isActive to true DbMethodsObj.SetExpertIsActiveTrue(); Expert expertProfileObj = (CapstoneBlackstone.Expert)Session["expertProfileObj"]; string user_name = expertProfileObj.username; var x = Session["Authenticated"]; //redirect to expert page Response.Redirect("ExpertPage.aspx?username=" + user_name);// conserve the session token at login } } } } } }//end logIn button clickEvent