private void BindTabs() { List <Tab> tabsList = new List <Tab>(); tabsList.Add(CreateTab("enterprisestorage_folder_settings", "Tab.GeneralSettings")); tabsList.Add(CreateTab("enterprisestorage_folder_settings_folder_permissions", "Tab.FolderPermissions")); SCP.SystemSettings settings = ES.Services.System.GetSystemSettings(SCP.SystemSettings.WEBDAV_PORTAL_SETTINGS); bool isOwaEnabled = false; if (settings != null) { isOwaEnabled = Utils.ParseBool(settings[SCP.SystemSettings.WEBDAV_OWA_ENABLED_KEY], false); } if (isOwaEnabled) { tabsList.Add(CreateTab("enterprisestorage_folder_settings_owa_editing", "Tab.OwaEditPermissions")); } int idx = 0; foreach (Tab tab in tabsList) { if (String.Compare(tab.Id, SelectedTab, true) == 0) { break; } idx++; } esTabs.SelectedIndex = idx; esTabs.DataSource = tabsList; esTabs.DataBind(); }
private void SaveRDS() { try { SCP.SystemSettings settings = new SCP.SystemSettings(); // RDS Server settings = new SCP.SystemSettings(); settings[RDS_MAIN_CONTROLLER] = ddlRdsController.SelectedValue; int result = ES.Services.System.SetSystemSettings(SCP.SystemSettings.RDS_SETTINGS, settings); } catch (Exception ex) { ShowErrorMessage("SYSTEM_SETTINGS_SAVE", ex); return; } ShowSuccessMessage("SYSTEM_SETTINGS_SAVE"); }
private void SaveWPI() { try { SCP.SystemSettings settings = new SCP.SystemSettings(); // WPI /* * settings[FEED_ENABLE_MICROSOFT] = wpiMicrosoftFeed.Checked.ToString(); * settings[FEED_ENABLE_HELICON] = wpiHeliconTechFeed.Checked.ToString(); */ settings[SCP.SystemSettings.FEED_ULS_KEY] = wpiEditFeedsList.Value; string mainFeedUrl = txtMainFeedUrl.Text; if (string.IsNullOrEmpty(mainFeedUrl)) { mainFeedUrl = WebPlatformInstaller.MAIN_FEED_URL; } settings[SCP.SystemSettings.WPI_MAIN_FEED_KEY] = mainFeedUrl; int result = ES.Services.System.SetSystemSettings(SCP.SystemSettings.WPI_SETTINGS, settings); if (result < 0) { ShowResultMessage(result); return; } } catch (Exception ex) { ShowErrorMessage("SYSTEM_SETTINGS_SAVE", ex); return; } ShowSuccessMessage("SYSTEM_SETTINGS_SAVE"); }
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 { //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); } }
public static int SendMessage(string from, string to, string bcc, string subject, string body, MailPriority priority, bool isHtml, Attachment[] attachments) { // Command line argument must the the SMTP host. SmtpClient client = new SmtpClient(); // load SMTP client settings SystemSettings settings = SystemController.GetSystemSettingsInternal( SystemSettings.SMTP_SETTINGS, true ); client.Host = settings["SmtpServer"]; client.Port = settings.GetInt("SmtpPort"); if (!String.IsNullOrEmpty(settings["SmtpUsername"])) { client.Credentials = new NetworkCredential( settings["SmtpUsername"], settings["SmtpPassword"] ); } if (!String.IsNullOrEmpty(settings["SmtpEnableSsl"])) { client.EnableSsl = Utils.ParseBool(settings["SmtpEnableSsl"], false); } // create message MailMessage message = new MailMessage(from, to); message.Body = body; message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = isHtml; message.Subject = subject; message.SubjectEncoding = System.Text.Encoding.UTF8; if (!String.IsNullOrEmpty(bcc)) { message.Bcc.Add(bcc); } message.Priority = priority; if (attachments != null) { foreach (Attachment current in attachments) { message.Attachments.Add(current); } } // send message try { client.Send(message); return(0); } catch (SmtpException ex) { switch (ex.StatusCode) { case SmtpStatusCode.BadCommandSequence: return(BusinessErrorCodes.SMTP_BAD_COMMAND_SEQUENCE); case SmtpStatusCode.CannotVerifyUserWillAttemptDelivery: return(BusinessErrorCodes.SMTP_CANNOT_VERIFY_USER_WILL_ATTEMPT_DELIVERY); case SmtpStatusCode.ClientNotPermitted: return(BusinessErrorCodes.SMTP_CLIENT_NOT_PERMITTED); case SmtpStatusCode.CommandNotImplemented: return(BusinessErrorCodes.SMTP_COMMAND_NOT_IMPLEMENTED); case SmtpStatusCode.CommandParameterNotImplemented: return(BusinessErrorCodes.SMTP_COMMAND_PARAMETER_NOT_IMPLEMENTED); case SmtpStatusCode.CommandUnrecognized: return(BusinessErrorCodes.SMTP_COMMAND_UNRECOGNIZED); case SmtpStatusCode.ExceededStorageAllocation: return(BusinessErrorCodes.SMTP_EXCEEDED_STORAGE_ALLOCATION); case SmtpStatusCode.GeneralFailure: return(BusinessErrorCodes.SMTP_GENERAL_FAILURE); case SmtpStatusCode.InsufficientStorage: return(BusinessErrorCodes.SMTP_INSUFFICIENT_STORAGE); case SmtpStatusCode.LocalErrorInProcessing: return(BusinessErrorCodes.SMTP_LOCAL_ERROR_IN_PROCESSING); case SmtpStatusCode.MailboxBusy: return(BusinessErrorCodes.SMTP_MAILBOX_BUSY); case SmtpStatusCode.MailboxNameNotAllowed: return(BusinessErrorCodes.SMTP_MAILBOX_NAME_NOTALLOWED); case SmtpStatusCode.MailboxUnavailable: return(BusinessErrorCodes.SMTP_MAILBOX_UNAVAILABLE); case SmtpStatusCode.MustIssueStartTlsFirst: return(BusinessErrorCodes.SMTP_MUST_ISSUE_START_TLS_FIRST); case SmtpStatusCode.ServiceClosingTransmissionChannel: return(BusinessErrorCodes.SMTP_SERVICE_CLOSING_TRANSMISSION_CHANNEL); case SmtpStatusCode.ServiceNotAvailable: return(BusinessErrorCodes.SMTP_SERVICE_NOT_AVAILABLE); case SmtpStatusCode.SyntaxError: return(BusinessErrorCodes.SMTP_SYNTAX_ERROR); case SmtpStatusCode.TransactionFailed: return(BusinessErrorCodes.SMTP_TRANSACTION_FAILED); case SmtpStatusCode.UserNotLocalTryAlternatePath: return(BusinessErrorCodes.SMTP_USER_NOT_LOCAL_TRY_ALTERNATE_PATH); case SmtpStatusCode.UserNotLocalWillForward: return(BusinessErrorCodes.SMTP_USER_NOT_LOCAL_WILL_FORWARD); default: return(BusinessErrorCodes.SMTP_UNKNOWN_ERROR); } } finally { // Clean up. message.Dispose(); } }
/// <remarks/> public void SetSystemSettingsAsync(string settingsName, SystemSettings settings) { this.SetSystemSettingsAsync(settingsName, settings, null); }
public override void DoWork() { BackgroundTask topTask = TaskManager.TopTask; // get input parameters string mailTo = (string)topTask.GetParamValue("MAIL_TO"); int auditLogSeverity = Utils.ParseInt((string)topTask.GetParamValue("AUDIT_LOG_SEVERITY"), -1); string auditLogSource = (string)topTask.GetParamValue("AUDIT_LOG_SOURCE"); string auditLogTask = (string)topTask.GetParamValue("AUDIT_LOG_TASK"); string auditLogDate = (string)topTask.GetParamValue("AUDIT_LOG_DATE"); int showExecutionLog = Utils.ParseInt((string)topTask.GetParamValue("SHOW_EXECUTION_LOG"), 0); // check input parameters if (String.IsNullOrEmpty(mailTo)) { TaskManager.WriteWarning("Specify 'Mail To' task parameter"); return; } string mailFrom = null; SystemSettings settings = SystemController.GetSystemSettingsInternal(SystemSettings.SMTP_SETTINGS, false); if (settings != null) { mailFrom = settings["SmtpUsername"]; } if (String.IsNullOrEmpty(mailFrom)) { TaskManager.WriteWarning("You need to configure SMTP settings first"); return; } DateTime logStart, logEnd; switch (auditLogDate) { case "today": logStart = DateTime.Now; logEnd = DateTime.Now; break; case "yesterday": logStart = DateTime.Now.AddDays(-1); logEnd = DateTime.Now.AddDays(-1); break; case "schedule": default: logEnd = DateTime.Now; ScheduleInfo schedule = SchedulerController.GetSchedule(topTask.ScheduleId); switch (schedule.ScheduleTypeId) { case "Daily": logStart = DateTime.Now.AddDays(-1); break; case "Weekly": logStart = DateTime.Now.AddDays(-7); break; case "Monthly": logStart = DateTime.Now.AddMonths(-1); break; case "Interval": logStart = DateTime.Now.AddSeconds(-schedule.Interval); break; case "OneTime": default: logStart = DateTime.Now; break; } break; } string mailSubject = "Audit Log Report (" + logStart.ToString("MMM dd, yyyy") + " - " + logEnd.ToString("MMM dd, yyyy") + ")"; StringBuilder sb = new StringBuilder(); sb.AppendLine("<html><head><style>"); sb.AppendLine("table, th, td { border: 1px solid black; border-collapse: collapse; }"); sb.AppendLine("th, td { padding: 5px; }"); sb.AppendLine("th { text-align: left; }"); sb.AppendLine("</style></head><body>"); sb.AppendLine("<h2>" + mailSubject + "</h2>"); sb.AppendFormat("<h3>Source: {0}, Task: {1}, Severity: {2}</h3>", String.IsNullOrEmpty(auditLogSource) ? "All" : auditLogSource, String.IsNullOrEmpty(auditLogTask) ? "All" : auditLogTask, GetAuditLogRecordSeverityName(auditLogSeverity)); DataTable logs = AuditLog.GetAuditLogRecordsPaged(topTask.EffectiveUserId, 0, 0, null, logStart, logEnd, auditLogSeverity, auditLogSource, auditLogTask, "", 0, Int32.MaxValue).Tables[1]; sb.AppendLine("<p>"); if (logs.Rows.Count == 0) { sb.AppendLine("Audit Log is empty."); } else { sb.AppendLine("<table>"); sb.Append("<tr><th>Started</th><th>Finished</th><th>Severity</th><th>Username</th><th>Source</th><th>Task</th><th>Item-Name</th>"); if (showExecutionLog == 1) { sb.AppendLine("<th>Execution-Log</th></tr>"); } else { sb.AppendLine("</tr>"); } foreach (DataRow log in logs.Rows) { sb.AppendLine("<tr>"); // Started sb.AppendFormat("<td>{0}</td>", log["StartDate"].ToString()); // Finished sb.AppendFormat("<td>{0}</td>", log["FinishDate"].ToString()); // Severity sb.AppendFormat("<td>{0}</td>", GetAuditLogRecordSeverityName((int)log["SeverityID"])); // Username sb.AppendFormat("<td>{0}</td>", log["Username"]); // Source sb.AppendFormat("<td>{0}</td>", log["SourceName"]); // Task sb.AppendFormat("<td>{0}</td>", log["TaskName"]); // Item-Name sb.AppendFormat("<td>{0}</td>", log["ItemName"]); // Execution-Log if (showExecutionLog == 1) { string executionLog = FormatPlainTextExecutionLog(log["ExecutionLog"].ToString()); sb.AppendFormat("<td>{0}</td>", executionLog); } sb.AppendLine("</tr>"); } sb.AppendLine("</table>"); } sb.AppendLine("</p></body></html>"); // send mail message int res = MailHelper.SendMessage(mailFrom, mailTo, mailSubject, sb.ToString(), true); if (res != 0) { TaskManager.WriteError("SMTP Error. Code: " + res.ToString()); } }
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); } }