protected void Page_Load(object sender, EventArgs e) { Control oControl; Page.Title = strTitle; if (Request.Cookies["profileid"] == null || Request.Cookies["profileid"].Value == "") { oControl = (Control)LoadControl("/controls/sys/sys_login.ascx"); PH3.Controls.Add(oControl); if (Request.QueryString["referrer"] != null) { string strReferrer = ""; foreach (string strName in Request.QueryString) { if (strName != "referrer") { strReferrer += "&" + strName + "=" + Request.QueryString[strName]; } } Response.Cookies["userloginreferrer"].Value = Request.QueryString["referrer"] + strReferrer; } } else { Users oUser = new Users(0, dsn); oUser.AddLogin(oUser.GetName(Int32.Parse(Request.Cookies["profileid"].Value))); if (Request.QueryString["referrer"] != null) { string strReferrer = ""; foreach (string strName in Request.QueryString) { if (strName != "referrer") { strReferrer += "&" + strName + "=" + Request.QueryString[strName]; } } Response.Redirect(Request.QueryString["referrer"] + strReferrer); } else { Response.Redirect("/index.aspx"); } } oControl = (Control)LoadControl("/controls/sys/sys_rotator_header.ascx"); PH4.Controls.Add(oControl); }
protected void Page_Load(object sender, EventArgs e) { lblInvalid.Visible = false; oUser = new Users(0, dsn); if (Request.Cookies["profileid"] != null && Request.Cookies["profileid"].Value != "") { oUser.AddLogin(oUser.GetName(Int32.Parse(Request.Cookies["profileid"].Value))); Redirect(); } else { if (Request.QueryString["logout"] != null) { lblLogout.Visible = true; } if (Request.QueryString["error"] != null) { lblInvalid.Visible = true; } txtUsername.Focus(); btnLogin.Attributes.Add("onclick", "return ValidateText('" + txtUsername.ClientID + "','Please enter a username') && ValidateText('" + txtPassword.ClientID + "','Please enter a password');"); } }
public int LoginUser(string _username, string _password, int _environment, bool _log, bool _admin) { Variables oNCB = new Variables(_environment); int _id = oUser.GetId(_username); if (_id != 0) { DirectoryEntry oEntry = new DirectoryEntry(oNCB.primaryDC(dsn), oNCB.Domain() + "\\" + _username, _password); DirectorySearcher oSearcher = new DirectorySearcher(oEntry); oSearcher.Filter = "(objectCategory=user)"; try { SearchResult oResult = oSearcher.FindOne(); oUser.AddLogin(_username); return(_id); } catch { // ADD PNC Authentication if (_environment == (int)CurrentEnvironment.CORPDMN) { Variables oPNC = new Variables((int)CurrentEnvironment.PNCNT_PROD); DirectoryEntry oPNCEntry = new DirectoryEntry(oPNC.primaryDC(dsn), oPNC.Domain() + "\\" + _username, _password); DirectorySearcher oPNCSearcher = new DirectorySearcher(oPNCEntry); oSearcher.Filter = "(objectCategory=user)"; try { SearchResult oPNCResult = oPNCSearcher.FindOne(); oUser.AddLogin(_username); return(_id); } catch { // ADD PNC Authentication return(-10); } } else if (_environment == (int)CurrentEnvironment.PNCNT_PROD) { oNCB = new Variables((int)CurrentEnvironment.CORPDMN); DirectoryEntry oNCBEntry = new DirectoryEntry(oNCB.primaryDC(dsn), oNCB.Domain() + "\\" + _username, _password); DirectorySearcher oNCBSearcher = new DirectorySearcher(oNCBEntry); oNCBSearcher.Filter = "(objectCategory=user)"; try { SearchResult oNCBResult = oNCBSearcher.FindOne(); oUser.AddLogin(_username); return(_id); } catch { // ADD PNC Authentication return(-10); } } else { return(-1); } } } else { return(0); } }