public bool AuthenticateUser(string domain, string username, string password, string LdapPath, out string Errmsg) { log.Debug(" inside AuthenticateUser : "******""; string domainAndUsername = username; User u = new User(); Login_DataObject obj1 = new Login_DataObject(); DirectoryEntry entry = new DirectoryEntry(LdapPath, domainAndUsername, password); try { string SUserName = domainAndUsername; string SPassword = password; SPassword = SPassword.Replace("/", "").Replace(",", "").Replace("-", ""); u = obj1.CheckUserNamePassword(SUserName); string studenttablepassword = u.StudentDOB.ToShortDateString();; studenttablepassword = studenttablepassword.Replace("/", "").Replace(",", "").Replace("-", ""); //DirectorySearcher search = new DirectorySearcher(entry); //search.Filter = "(SAMAccountName=" + username + ")"; //search.PropertiesToLoad.Add("cn"); //SearchResult result = search.FindOne(); if (SPassword != studenttablepassword) { LblError.Visible = true; LblError.Text = "Invalid RollNumber or Password!"; return(false); } else { return(true); } //LdapPath = result.Path; //string _filterAttribute = (String)result.Properties["cn"][0]; ////Object obj = entry.NativeObject; //DirectorySearcher search = new DirectorySearcher(entry); //search.Filter = "(SAMAccountName=" + username + ")"; //search.PropertiesToLoad.Add("cn"); //SearchResult result = search.FindOne(); //if (null == result) //{ // return false; //} //// Update the new path to the user in the directory //LdapPath = result.Path; //string _filterAttribute = (String)result.Properties["cn"][0]; } catch (Exception ex) { Errmsg = ex.Message; return(false); throw new Exception("Error authenticating user." + ex.Message); } }
private int selectRoleStudent(object sender, ImageClickEventArgs e) { User u = new User(); Login_DataObject obj1 = new Login_DataObject(); string RollNumber = TextBoxURollNO.Text.Trim(); u = obj1.fnLoginLanOnStudent(RollNumber); //if (u.StudentName != "") //{ //} int a = u.Role; if (a == 0) { return(0); } return(1); }
protected int selectRole(object sender, EventArgs e) { User u = new User(); Login_DataObject obj1 = new Login_DataObject(); string mailid = TextBoxUid.Text.Trim(); string dir_domain = ConfigurationManager.AppSettings["DirectoryDomain"].ToString(); u = obj1.fnLoginLanOn(mailid + dir_domain); int a = u.Role; if (a == 0) { return(0); } return(1); }
public void Login_Click() { try { User u = new User(); Login_DataObject obj1 = new Login_DataObject(); string StudentRollNO = TextBoxURollNO.Text.Trim(); string dir_domain = ConfigurationManager.AppSettings["DirectoryDomain"].ToString(); u = obj1.fnLoginLanOnStudent(StudentRollNO); if (u.StudentName != null) { int a = u.Role; Session["UserName"] = u.StudentName; Session["Role"] = u.Role; Session["User"] = TextBoxURollNO.Text; Session["Department"] = u.StudentClassName; Session["DepartmentId"] = u.StudentClassCode; Session["InstituteId"] = u.StudentInstCode; Session["InstituteName"] = u.StudentInstName; Session["StudentDOB"] = u.StudentDOB; Session["emailId"] = u.EmailId1; Session["UserId"] = TextBoxURollNO.Text; LblError.Visible = false; LblError.Text = ""; if (u.Role != null) { if (a == 21) //redirecting based on conditions { Response.Redirect("~/GrantEntry/SeedMoneyforStudent.aspx", false); } else //displaying error message in case of invalid credentials { string unacces = "Invalid Credentials Entered........Please Contact Admin"; Response.Redirect("~/Loginstudent.aspx?val=" + unacces); } } } else { //Response.Redirect("~/Login.aspx", false); // ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Invalid User...');window.location='" + Request.ApplicationPath + "~/Login.aspx';</script>"); LblError1.Visible = true; LblError1.Text = "Invalid User..."; } } catch (Exception ex) { log.Error(ex.StackTrace); log.Error(ex.Message); log.Error("Login Failed...For MailId : " + TextBoxURollNO.Text); ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Login Failed for the user......Please Contact Admin')</script>"); } }
public void LoginLanOff_Click() { try { User u = new User(); string dir_domain = ConfigurationManager.AppSettings["DirectoryDomain"].ToString(); Login_DataObject obj1 = new Login_DataObject(); string mailid = TextBoxURollNO.Text.Trim(); string userid = TextBoxPassword.Text.Trim(); u = obj1.fnLoginLanOff(mailid + dir_domain, userid);// calling login function if (u.Role != null) { int a = u.Role; Session["User"] = TextBoxURollNO.Text.Trim(); Session["Role"] = a; Session["UserId"] = u.UserId; Session["UserName"] = u.UserNamePrefix + " " + u.UserFirstName + " " + u.UserMiddleName + " " + u.UserLastName; Session["InstituteId"] = u.InstituteId; Session["Department"] = u.Department; Session["emailId"] = mailid + dir_domain; Session["SupervisorId"] = u.SupervisorId; // Session["AutoApproval"] = u.AutoApproved; Session["ActiveUser"] = u.Active; Session["ProjectUnit"] = u.UnitId; Session["RoleName"] = u.Role_Name; LblError.Visible = false; LblError.Text = ""; LblError1.Visible = false; LblError1.Text = ""; if (u.Active == "Y") { if (a == 1) //redirecting based on conditions { Response.Redirect("~/PublicationEntry/PublicationView.aspx", false); } else if (a == 2) { Response.Redirect("~/ManageJournal/ManageJournal.aspx", false); } else if (a == 3) { Response.Redirect("~/PublicationEntry/PublicationView.aspx", false); } else if (a == 5) { Response.Redirect("~/PublicationEntry/PublicationLibraryUpdate.aspx", false); } else if (a == 6) { //Response.Redirect("~/PublicationEntry.aspx", false); Response.Redirect("~/GrantEntry/GrantEntry.aspx", false); } else if (a == 11) { //Response.Redirect("~/PublicationEntry.aspx", false); Response.Redirect("~/PublicationEntry/PublicationEntry.aspx", false); } else if (a == 8) { Response.Redirect("~/ManageJournal/ManageJournal.aspx", false); } else if (a == 13) { Response.Redirect("~/ManageJournal/ManageJournal.aspx", false); } else if (a == 14) { Response.Redirect("~/PublicationEntry/Reports/PublicationReport.aspx", false); } else if (a == 15) { Response.Redirect("~/PublicationEntry/Reports/PublicationReport.aspx", false); } else if (a == 16) { //Response.Redirect("~/PublicationEntry.aspx", false); Response.Redirect("~/GrantEntry/GrantEntry.aspx", false); } else { Response.Redirect("~/PublicationEntry/Reports/PublicationReport.aspx", false); } } else //displaying error message in case of invalid credentials { // Response.Redirect("~/Login.aspx",false); // LblError.Visible = true; // LblError.Text = "Invalid Credentials Entered...Try again..."; string unacces = "Invalid Credentials Entered........Please Contact Admin"; Response.Redirect("~/Login.aspx?val=" + unacces); } } else { LblError1.Visible = true; LblError1.Text = "Invalid User..."; } } catch (Exception ex) { log.Error(ex.StackTrace); log.Error(ex.Message); log.Error("Login Failed...For MailId : " + TextBoxURollNO.Text); ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Login Failed for the user......Please Contact Admin')</script>"); } }
public void getMenu() { Login_DataObject obj = new Login_DataObject(); int role = (int)Session["Role"]; string userid = Session["UserId"].ToString(); string InstituteId = Session["InstituteId"].ToString(); string Department = Session["Department"].ToString(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(); if (role == 21) { da = obj.DynamicMenuStudent(role); } else { da = obj.DynamicMenu(userid); } da.Fill(ds); dt = ds.Tables[0]; // DataRow[] drowpar = dt.Select("RoleID=" + role); foreach (DataRow dr in dt.Rows) { if (dr["LinkLevel"].Equals("M1")) { menuBar.Items.Add(new MenuItem(dr["LinkName"].ToString(), dr["Id"].ToString(), "", dr["URL"].ToString())); } else { } if (dr["Id"] != null) { DataSet ds1 = new DataSet(); DataTable dt1 = new DataTable(); SqlDataAdapter da1 = new SqlDataAdapter(); string role1 = Convert.ToString(role); if (role1 == "21") { da1 = obj.DynamicMenuStudent1(role1, dr["Id"].ToString()); } else { da1 = obj.DynamicMenu1(userid, dr["Id"].ToString()); } da1.Fill(ds1); dt1 = ds1.Tables[0]; // DataRow[] drowpar1 = dt1.Select("ParentID =" + dr["Id"].ToString()); //DataRow[] drowpar1 = dt1.Select("RoleID=" + role); foreach (DataRow dr1 in dt1.Rows) { MenuItem mnu = new MenuItem(dr1["LinkName"].ToString(), dr1["Id"].ToString(), "", dr1["URL"].ToString()); menuBar.FindItem(dr1["ParentID"].ToString()).ChildItems.Add(mnu); Session["authPage"] = Session["authPage"].ToString() + dr1["id"].ToString() + authSpace; } } } }
public void LoginLanOff_Click() { try { User u = new User(); string dir_domain = ConfigurationManager.AppSettings["DirectoryDomain"].ToString(); Login_DataObject obj1 = new Login_DataObject(); string mailid = TextBoxUid.Text.Trim(); string userid = TextBoxPassword.Text.Trim(); u = obj1.fnLoginLanOff(mailid + dir_domain, userid);// calling login function if (u.Role != null) { int a = u.Role; Session["User"] = TextBoxUid.Text; Session["Role"] = a; Session["UserId"] = u.UserId; Session["UserName"] = u.UserNamePrefix + " " + u.UserFirstName + " " + u.UserMiddleName + " " + u.UserLastName; Session["InstituteId"] = u.InstituteId; Session["Department"] = u.Department; Session["emailId"] = mailid + dir_domain; Session["SupervisorId"] = u.SupervisorId; // Session["AutoApproval"] = u.AutoApproved; Session["ActiveUser"] = u.Active; Session["ProjectUnit"] = u.UnitId; Session["RoleName"] = u.Role_Name; LblError.Visible = false; LblError.Text = ""; LblError1.Visible = false; LblError1.Text = ""; if (u.Active == "Y") { string Module = Request.QueryString["Module"]; if (Module != "" && Module != null) { if (Module == "JA") { Response.Redirect("~/PublicationEntry/PublicationEntry.aspx?Module=" + Module + "", false); } else if (Module == "BK") { Response.Redirect("~/PublicationEntry/PublicationEntry.aspx?Module=" + Module + "", false); } else if (Module == "CP") { Response.Redirect("~/PublicationEntry/PublicationEntry.aspx?Module=" + Module + "", false); } else if (Module == "NM") { Response.Redirect("~/PublicationEntry/PublicationEntry.aspx?Module=" + Module + "", false); } else if (Module == "TS") { Response.Redirect("~/PublicationEntry/PublicationEntry.aspx?Module=" + Module + "", false); } else if (Module == "Patent") { Response.Redirect("~/Patent/Patent.aspx", false); } else if (Module == "Grant") { Response.Redirect("~/GrantEntry/GrantEntry.aspx", false); } //else if (Module == "Conference") //{ // Login_DataObject obj = new Login_DataObject(); // string Enable = obj.GetConferenceMenuForLoginUser(Session["InstituteId"].ToString(), Session["Department"].ToString(), Session["UserId"].ToString()); // if (Enable == "Y") // { // Response.Redirect("~/Conference/ConferencePrePresentationEntry.aspx", false); // } // else // { // ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Currently Conference Entry has been disabled. please contact Directorate of Research ([email protected])')</script>"); // return; // } //} else if (Module == "Report") { Response.Redirect("~/PublicationEntry/Reports/PublicationReport.aspx", false); } } else { if (a == 1) //redirecting based on conditions { Response.Redirect("~/PublicationEntry/PublicationView.aspx", false); } else if (a == 2) { Response.Redirect("~/ManageJournal/ManageJournal.aspx", false); } else if (a == 3) { Response.Redirect("~/PublicationEntry/PublicationView.aspx", false); } else if (a == 5) { Response.Redirect("~/PublicationEntry/PublicationLibraryUpdate.aspx", false); } else if (a == 6) { //Response.Redirect("~/PublicationEntry.aspx", false); Response.Redirect("~/GrantEntry/GrantEntry.aspx", false); } else if (a == 11) { //Response.Redirect("~/PublicationEntry.aspx", false); Response.Redirect("~/PublicationEntry/PublicationEntry.aspx", false); } else if (a == 8) { Response.Redirect("~/ManageJournal/ManageJournal.aspx", false); } else if (a == 13) { Response.Redirect("~/ManageJournal/ManageJournal.aspx", false); } else if (a == 14) { Response.Redirect("~/PublicationEntry/Reports/PublicationReport.aspx", false); } else if (a == 15) { Response.Redirect("~/PublicationEntry/Reports/PublicationReport.aspx", false); } else if (a == 16) { //Response.Redirect("~/PublicationEntry.aspx", false); Response.Redirect("~/GrantEntry/GrantEntry.aspx", false); } else if (a == 20) { Response.Redirect("~/GrantEntry/GrantFileUpload.aspx", false); } else if (a == 22) { Response.Redirect("~/PublicationEntry/Reports/PublicationReport.aspx", false); } else { Response.Redirect("~/PublicationEntry/Reports/PublicationReport.aspx", false); } } } else //displaying error message in case of invalid credentials { // Response.Redirect("~/Login.aspx",false); // LblError.Visible = true; // LblError.Text = "Invalid Credentials Entered...Try again..."; string unacces = "Invalid Credentials Entered........Please Contact Admin"; Response.Redirect("~/Login.aspx?val=" + unacces); } } else { LblError1.Visible = true; LblError1.Text = "Invalid User..."; } } catch (Exception ex) { log.Error(ex.StackTrace); log.Error(ex.Message); log.Error("Login Failed...For MailId : " + TextBoxUid.Text); ClientScript.RegisterStartupScript(Page.GetType(), "validation1", "<script language='javascript'>alert('Login Failed for the user......Please Contact Admin')</script>"); } }