protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string _CurrUrl = HttpContext.Current.Request.Url.AbsoluteUri; Session["CURRURL"] = _CurrUrl; if (Session["UserLoginData"] == null) { Response.BufferOutput = true; Response.Redirect("~/SSO.aspx"); } else { hdfEmployeeID.Value = Request.QueryString["EmployeeID"]; Inf_UserLoginData userData = new Inf_UserLoginData(); userData = (Inf_UserLoginData)Session["UserLoginData"]; hdfUserLogin.Value = userData.DisplayName; InitialEmpDetail(); GetAppraisalHeader(); BindGridView(); CheckStateActionHistory(); DisableButton(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string _CurrUrl = HttpContext.Current.Request.Url.AbsoluteUri; Session["CURRURL"] = _CurrUrl; if (Session["UserLoginData"] == null) { Response.BufferOutput = true; Response.Redirect("~/SSO.aspx"); } else { Inf_UserLoginData userData = new Inf_UserLoginData(); userData = (Inf_UserLoginData)Session["UserLoginData"]; hdfUserLogin.Value = userData.DisplayName; hdfEmployeeID.Value = Request.QueryString["EmployeeID"]; InitialEmpDetail(); GetAppraisalHeader(); BindGridView1(); BindGridView2(); BindGVApprovalHist(); BindGVAppraisalHistory(); lblTotalPart1.Text = "50 คะแนน"; lblTotalPart2.Text = "50 คะแนน"; lblTotalPoint.Text = "100 คะแนน"; Session["tbAttachFile"] = null; InitialGVAttachFile(); #region #### For Pop Up Employee #### if (!string.IsNullOrEmpty(hdfEmployeeType.Value) && hdfEmployeeType.Value.Trim().Equals("2")) { InitialGVPopupEmployee(); lbtnPopupEmployee_ModalPopupExtender.Show(); } #endregion #### For Pop Up Employee #### } } }
public Inf_UserLoginData AuthenUserLogin(string username) { Inf_UserLoginData userData = new Inf_UserLoginData(); try { string adName = @"LDAP://gulf"; System.DirectoryServices.DirectoryEntry ldap = new System.DirectoryServices.DirectoryEntry(adName); DirectorySearcher searchUser = new DirectorySearcher(ldap); searchUser.Filter = "(&(objectClass=user)(SAMAccountName=" + username.Trim() + "))"; SearchResult result = searchUser.FindOne(); if (result != null) { DirectoryEntry drEntry = result.GetDirectoryEntry(); drEntry.AuthenticationType = AuthenticationTypes.Secure; userData.EmployeeID = drEntry.Properties["employeeID"].Value == null ? "" : drEntry.Properties["employeeID"].Value.ToString(); userData.DomainName = drEntry.Properties["SAMAccountName"].Value == null ? "" : drEntry.Properties["SAMAccountName"].Value.ToString(); userData.DisplayName = drEntry.Properties["displayName"].Value == null ? "" : drEntry.Properties["displayName"].Value.ToString(); userData.Email = drEntry.Properties["mail"].Value == null ? "" : drEntry.Properties["mail"].Value.ToString(); userData.Company = drEntry.Properties["company"].Value == null ? "" : drEntry.Properties["company"].Value.ToString(); userData.Department = drEntry.Properties["department"].Value == null ? "" : drEntry.Properties["department"].Value.ToString(); userData.Title = drEntry.Properties["title"].Value == null ? "" : drEntry.Properties["title"].Value.ToString(); if (drEntry.Properties["manager"].Value != null) { if (!string.IsNullOrEmpty(drEntry.Properties["manager"].Value.ToString())) { string mgr = ""; mgr = drEntry.Properties["manager"].Value.ToString().Remove(0, 3).Replace("\\", " "); int r = mgr.IndexOf(","); userData.Manager = mgr.Remove(r); } } drEntry.Dispose(); } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } return(userData); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string _CurrUrl = HttpContext.Current.Request.Url.AbsoluteUri; Session["CURRURL"] = _CurrUrl; if (Session["UserLoginData"] == null) { Response.BufferOutput = true; Response.Redirect("~/SSO.aspx"); } else { Inf_UserLoginData userData = new Inf_UserLoginData(); userData = (Inf_UserLoginData)Session["UserLoginData"]; hdfUserLogin.Value = userData.DisplayName; hdfEmployeeID.Value = Request.QueryString["EmployeeID"]; InitialEmpDetail(); GetAppraisalHeader(); BindGridViewEdit1(); BindGridViewEdit2(); BindGVApprovalHist(); BindGVAppraisalHistory(); lblTotalPart1.Text = "50 คะแนน"; lblTotalPart2.Text = "50 คะแนน"; lblTotalPoint.Text = "100 คะแนน"; if (!string.IsNullOrEmpty(lblActualPart1.Text) && !string.IsNullOrEmpty(lblActualPart2.Text)) { lblActualPoint.Text = (Convert.ToDecimal(lblActualPart1.Text.Trim()) + Convert.ToDecimal(lblActualPart2.Text.Trim())).ToString(); } Session["tbAttachFile"] = null; InitialGVAttachFile(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Inf_UserLoginData userData = new Inf_UserLoginData(); if (Session["UserLoginData"] == null) { Response.BufferOutput = true; Response.Redirect("~/SSO.aspx"); } else { userData = (Inf_UserLoginData)Session["UserLoginData"]; if (userData != null) { string _EmployeeID = userData.EmployeeID.Trim(); string _displayName = userData.DisplayName; lblLoginName.Text = _displayName; HREmployee_Manage manage = new HREmployee_Manage(); HREmployee hrData = new HREmployee(); hrData = manage.GetHREmployeeData(_EmployeeID); if (hrData == null || string.IsNullOrEmpty(hrData.EmployeeID)) { MenuItem parent2 = NavigationMenu.FindItem("2"); NavigationMenu.Items.Remove(parent2); MenuItem parent3 = NavigationMenu.FindItem("3"); NavigationMenu.Items.Remove(parent3); MenuItem parent5 = NavigationMenu.FindItem("5"); NavigationMenu.Items.Remove(parent5); } } else { Response.BufferOutput = true; Response.Redirect("~/Unauthorized.aspx"); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserLoginData"] == null) { Response.BufferOutput = true; Response.Redirect("~/SSO.aspx"); } else { Inf_UserLoginData userData = new Inf_UserLoginData(); userData = (Inf_UserLoginData)Session["UserLoginData"]; hdfUserLogin.Value = userData.DisplayName; InitialDDlCompay(); InitialDDlDepartment(); BindingGrid(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string _CurrUrl = HttpContext.Current.Request.Url.AbsoluteUri; Session["CURRURL"] = _CurrUrl; if (Session["UserLoginData"] == null) { Response.BufferOutput = true; Response.Redirect("~/SSO.aspx"); } else { Inf_UserLoginData userData = new Inf_UserLoginData(); userData = (Inf_UserLoginData)Session["UserLoginData"]; hdfUserLogin.Value = userData.DisplayName; InitialGridviewSUser(); pnSearchResult.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserLoginData"] == null) { Response.BufferOutput = true; Response.Redirect("~/SSO.aspx"); } else { Inf_UserLoginData userData = new Inf_UserLoginData(); userData = (Inf_UserLoginData)Session["UserLoginData"]; userData = (Inf_UserLoginData)Session["UserLoginData"]; if (userData != null) { string _EmployeeID = userData.EmployeeID.Trim(); HREmployee_Manage manage = new HREmployee_Manage(); HREmployee hrData = new HREmployee(); hrData = manage.GetHREmployeeData(_EmployeeID); if (hrData == null || string.IsNullOrEmpty(hrData.EmployeeID)) { lbtnSelEmployee.Visible = false; lbtnPrintForm.Visible = false; lbtnReportSummary.Visible = false; } } else { Response.BufferOutput = true; Response.Redirect("~/Unauthorized.aspx"); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string _CurrUrl = HttpContext.Current.Request.Url.AbsoluteUri; Session["CURRURL"] = _CurrUrl; if (Session["UserLoginData"] == null) { Response.BufferOutput = true; Response.Redirect("~/SSO.aspx"); } else { Inf_UserLoginData userData = new Inf_UserLoginData(); userData = (Inf_UserLoginData)Session["UserLoginData"]; hdfUserLogin.Value = userData.DisplayName; InitialDDlCompay(); InitialDDlDepartment(); BindingGrid(); } } }
protected void Page_Load(object sender, EventArgs e) { #region #### Old Version #### //string username = Thread.CurrentPrincipal.Identity.Name.Split('\\')[1]; //string adName = @"LDAP://gulf"; //System.DirectoryServices.DirectoryEntry ldap = new System.DirectoryServices.DirectoryEntry(adName); //DirectorySearcher searchUser = new DirectorySearcher(ldap); //searchUser.Filter = "(&(objectClass=user)(SAMAccountName=" + username.Trim() + "))"; //SearchResult result = searchUser.FindOne(); //if (result != null) //{ // DirectoryEntry drEntry = result.GetDirectoryEntry(); // drEntry.AuthenticationType = AuthenticationTypes.Secure; // //HttpCookie _ASPXEMPID = new HttpCookie("ASPXEMPID"); // //HttpCookie _ASPXAUTH = new HttpCookie("ASPXAUTH"); // //HttpCookie _ASPXDISPNAME = new HttpCookie("ASPXDISPNAME"); // //HttpCookie _ASPXEMPMAIL = new HttpCookie("ASPXEMPMAIL"); // //HttpCookie _ASPXCOMPANY = new HttpCookie("ASPXCOMPANY"); // //HttpCookie _ASPXDEPT = new HttpCookie("ASPXDEPT"); // //HttpCookie _ASPXTITLE = new HttpCookie("ASPXTITLE"); // //HttpCookie _ASPXADMGRNAME = new HttpCookie("ASPXMGRNAME"); // Inf_UserLoginData userData = new Inf_UserLoginData(); // userData.EmployeeID = drEntry.Properties["employeeID"].Value.ToString(); // userData.DomainName = drEntry.Properties["SAMAccountName"].Value.ToString(); // userData.DisplayName = drEntry.Properties["displayName"].Value.ToString(); // userData.Email = drEntry.Properties["mail"].Value.ToString(); // userData.Company = drEntry.Properties["company"].Value.ToString(); // userData.Department = drEntry.Properties["department"].Value.ToString(); // userData.Title = drEntry.Properties["title"].Value.ToString(); // if (drEntry.Properties["manager"].Value != null) // { // if (!string.IsNullOrEmpty(drEntry.Properties["manager"].Value.ToString())) // { // string mgr = ""; // mgr = drEntry.Properties["manager"].Value.ToString().Remove(0, 3).Replace("\\", " "); // int r = mgr.IndexOf(","); // userData.Manager = mgr.Remove(r); // } // } // Session["UserLoginData"] = userData; // //Response.Cookies.Add(_ASPXEMPID); // //Response.Cookies.Add(_ASPXAUTH); // //Response.Cookies.Add(_ASPXDISPNAME); // //Response.Cookies.Add(_ASPXEMPMAIL); // //Response.Cookies.Add(_ASPXDEPT); // //Response.Cookies.Add(_ASPXTITLE); // //Response.Cookies.Add(_ASPXCOMPANY); // //ViewState["AUTH"] = _ASPXAUTH.Value; // //ViewState["ADMGRNAME"] = _ASPXADMGRNAME.Value; // //ViewState["ADMGRNAMETRIM"] = mgr.Remove(r).Replace(" ", ""); // Response.Redirect("~/Default.aspx"); // drEntry.Dispose(); //} //else //{ // Response.BufferOutput = true; // Response.Redirect("~/UnAuthorize.aspx"); //} #endregion string sCurrURL = (string)Session["CURRURL"]; string url = string.Empty; if (string.IsNullOrEmpty(sCurrURL)) { url = "~/Default.aspx"; } else { url = sCurrURL; } Session["CURRURL"] = null; string username = string.Empty; /********** Local Version ******************/ //username = Thread.CurrentPrincipal.Identity.Name.Split('\\')[1]; //username = "******"; /******************************************/ /********** Production version ***********/ string _username = HttpContext.Current.User.Identity.Name; username = GetUserLogin(_username); /******************************************/ Inf_UserLoginData userData = new Inf_UserLoginData(); AuthenticateUser autUser = new AuthenticateUser(); userData = autUser.AuthenUserLogin(username); if (userData == null || string.IsNullOrEmpty(userData.DomainName)) { Response.BufferOutput = true; Response.Redirect("~/Unauthorized.aspx"); } else { Session["UserLoginData"] = userData; //Response.Redirect("~/Default.aspx"); Response.Redirect(url); } }