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 LoadSettings() { // SMTP SCP.SystemSettings settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.SMTP_SETTINGS); if (settings != null) { txtSmtpServer.Text = settings[SMTP_SERVER]; txtSmtpPort.Text = settings[SMTP_PORT]; txtSmtpUser.Text = settings[SMTP_USERNAME]; txtSmtpPassword.Text = settings[SMTP_PASSWORD]; chkEnableSsl.Checked = Utils.ParseBool(settings[SMTP_ENABLE_SSL], false); } // BACKUP settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.BACKUP_SETTINGS); if (settings != null) { txtBackupsPath.Text = settings["BackupsPath"]; } // WPI settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.WPI_SETTINGS); /* * if (settings != null) * { * wpiMicrosoftFeed.Checked = Utils.ParseBool(settings[FEED_ENABLE_MICROSOFT],true); * wpiHeliconTechFeed.Checked = Utils.ParseBool(settings[FEED_ENABLE_HELICON],true); * } * else * { * wpiMicrosoftFeed.Checked = true; * wpiHeliconTechFeed.Checked = true; * } */ if (null != settings) { wpiEditFeedsList.Value = settings[SCP.SystemSettings.FEED_ULS_KEY]; string mainFeedUrl = settings[SCP.SystemSettings.WPI_MAIN_FEED_KEY]; if (string.IsNullOrEmpty(mainFeedUrl)) { mainFeedUrl = WebPlatformInstaller.MAIN_FEED_URL; } txtMainFeedUrl.Text = mainFeedUrl; } // FILE MANAGER settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.FILEMANAGER_SETTINGS); if (settings != null && !String.IsNullOrEmpty(settings[FILE_MANAGER_EDITABLE_EXTENSIONS])) { txtFileManagerEditableExtensions.Text = settings[FILE_MANAGER_EDITABLE_EXTENSIONS].Replace(",", System.Environment.NewLine); } else { // Original SolidCP Extensions txtFileManagerEditableExtensions.Text = FileManager.ALLOWED_EDIT_EXTENSIONS.Replace(",", System.Environment.NewLine); } // RDS var services = ES.Services.RDS.GetRdsServices(); foreach (var service in services) { ddlRdsController.Items.Add(new ListItem(service.ServiceName, service.ServiceId.ToString())); } settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.RDS_SETTINGS); if (settings != null && !string.IsNullOrEmpty(settings[RDS_MAIN_CONTROLLER])) { ddlRdsController.SelectedValue = settings[RDS_MAIN_CONTROLLER]; } else if (ddlRdsController.Items.Count > 0) { ddlRdsController.SelectedValue = ddlRdsController.Items[0].Value; } // Webdav portal settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.WEBDAV_PORTAL_SETTINGS); if (settings != null) { chkEnablePasswordReset.Checked = Utils.ParseBool(settings[SCP.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY], false); txtWebdavPortalUrl.Text = settings[WEBDAV_PORTAL_URL]; txtPasswordResetLinkLifeSpan.Text = settings[SCP.SystemSettings.WEBDAV_PASSWORD_RESET_LINK_LIFE_SPAN]; chkEnableOwa.Checked = Utils.ParseBool(settings[SCP.SystemSettings.WEBDAV_OWA_ENABLED_KEY], false); txtOwaUrl.Text = settings[SCP.SystemSettings.WEBDAV_OWA_URL]; } // Twilio portal settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.TWILIO_SETTINGS); if (settings != null) { txtAccountSid.Text = settings.GetValueOrDefault(SCP.SystemSettings.TWILIO_ACCOUNTSID_KEY, string.Empty); txtAuthToken.Text = settings.GetValueOrDefault(SCP.SystemSettings.TWILIO_AUTHTOKEN_KEY, string.Empty); txtPhoneFrom.Text = settings.GetValueOrDefault(SCP.SystemSettings.TWILIO_PHONEFROM_KEY, string.Empty); } // Access IP Settings settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.ACCESS_IP_SETTINGS); if (settings != null) { txtIPAddress.Text = settings.GetValueOrDefault(SCP.SystemSettings.ACCESS_IPs, string.Empty); } }
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); } }