private void LoginUser(string username, string password, bool rememberLogin, string preferredLocale, string theme) { // status int loginStatus = PortalUtils.AuthenticateUser(username, password, ipAddress, rememberLogin, preferredLocale, theme); if (loginStatus < 0) { ShowWarningMessage("WrongLogin"); return; } // Access IP Settings SCP.SystemSettings settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.ACCESS_IP_SETTINGS); String AccessIps = String.Empty; String[] arAccessIps = null; if (settings != null) { AccessIps = settings.GetValueOrDefault(SCP.SystemSettings.ACCESS_IPs, string.Empty); arAccessIps = AccessIps.Split(','); } if (!String.IsNullOrEmpty(AccessIps)) { String RequestIP = Request.ServerVariables["REMOTE_ADDR"]; // String l_stSubnet = Knom.Helpers.Net.SubnetMask.ReturnSubnetmask(AccessIps); Boolean l_Mach = false; try { foreach (String l_AccessIP in arAccessIps) { l_Mach = Knom.Helpers.Net.SubnetMask.IsInRange(RequestIP, l_AccessIP.Trim()); if (l_Mach) { break; // Once it passed then don't need to check for other access; } } } catch (Exception) { } if (!l_Mach) { PortalUtils.UserSignOutOnly(); // messageBox.RenderMessage(MessageBoxType.Warning, "Unauthorized IP", "Unauthorized IP", null); ShowWarningMessage("IPAccessProhibited"); return; } } if (loginStatus == BusinessSuccessCodes.SUCCESS_USER_ONETIMEPASSWORD) { // One time password should be changed after login Response.Redirect("Default.aspx?mid=1&ctl=change_onetimepassword&onetimepassword=true&UserID=" + PanelSecurity.LoggedUserId.ToString()); } else { //Make Theme Cookies DataSet UserThemeSettingsData = ES.Services.Users.GetUserThemeSettings(PanelSecurity.LoggedUserId); if (UserThemeSettingsData.Tables.Count > 0) { foreach (DataRow row in UserThemeSettingsData.Tables[0].Rows) { string RowPropertyName = row.Field <String>("PropertyName"); string RowPropertyValue = row.Field <String>("PropertyValue"); if (RowPropertyName == "Style") { string UserThemeStyle = RowPropertyValue; HttpCookie UserThemeStyleCrumb = new HttpCookie("UserThemeStyle", UserThemeStyle); UserThemeStyleCrumb.Expires = DateTime.Now.AddMonths(2); HttpContext.Current.Response.Cookies.Add(UserThemeStyleCrumb); } if (RowPropertyName == "colorHeader") { string UserThemecolorHeader = RowPropertyValue; HttpCookie UserThemecolorHeaderCrumb = new HttpCookie("UserThemecolorHeader", UserThemecolorHeader); UserThemecolorHeaderCrumb.Expires = DateTime.Now.AddMonths(2); HttpContext.Current.Response.Cookies.Add(UserThemecolorHeaderCrumb); } if (RowPropertyName == "colorSidebar") { string UserThemecolorSidebar = RowPropertyValue; HttpCookie UserThemecolorSidebarCrumb = new HttpCookie("UserThemecolorSidebar", UserThemecolorSidebar); UserThemecolorSidebarCrumb.Expires = DateTime.Now.AddMonths(2); HttpContext.Current.Response.Cookies.Add(UserThemecolorSidebarCrumb); } } } // redirect by shortcut ShortcutRedirect(); // standard redirect Response.Redirect(RedirectUrl, true); } }
private void LoginUser(string username, string password, bool rememberLogin, string preferredLocale, string theme) { // status int loginStatus = PortalUtils.AuthenticateUser(username, password, ipAddress, rememberLogin, preferredLocale, theme); if (loginStatus < 0) { ShowWarningMessage("WrongLogin"); return; } // Access IP Settings SCP.SystemSettings settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.ACCESS_IP_SETTINGS); String AccessIps = String.Empty; String[] arAccessIps = null; if (settings != null) { AccessIps = settings.GetValueOrDefault(SCP.SystemSettings.ACCESS_IPs, string.Empty); arAccessIps = AccessIps.Split(','); } if (!String.IsNullOrEmpty(AccessIps)) { String RequestIP = Request.ServerVariables["REMOTE_ADDR"]; // String l_stSubnet = Knom.Helpers.Net.SubnetMask.ReturnSubnetmask(AccessIps); Boolean l_Mach = false; try { foreach (String l_AccessIP in arAccessIps) { l_Mach = Knom.Helpers.Net.SubnetMask.IsInRange(RequestIP, l_AccessIP.Trim()); if (l_Mach) { break; // Once it passed then don't need to check for other access; } } } catch (Exception) { } if (!l_Mach) { PortalUtils.UserSignOutOnly(); // messageBox.RenderMessage(MessageBoxType.Warning, "Unauthorized IP", "Unauthorized IP", null); ShowWarningMessage("IPAccessProhibited"); return; } } if (loginStatus == BusinessSuccessCodes.SUCCESS_USER_ONETIMEPASSWORD) { // One time password should be changed after login Response.Redirect("Default.aspx?mid=1&ctl=change_onetimepassword&onetimepassword=true&UserID=" + PanelSecurity.LoggedUserId.ToString()); } else { // redirect by shortcut ShortcutRedirect(); // standard redirect Response.Redirect(RedirectUrl, true); } }