diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs index 82eef886..6d4f921b 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs @@ -331,11 +331,14 @@ 1 1 - &ServerFeature=3 - &EnterpriseServerFeature=3 - &PortalFeature=3 - &SchedulerServiceFeature=3 - &WDPortalFeature=3 + + + + + + + + 1 1 @@ -357,7 +360,10 @@ ""]]> "" AND DSOP_UPN = ""]]> - 1 + + 1 + + &EnterpriseServerFeature=3 AND VALIDATE_OK = "1" &PortalFeature=3 AND VALIDATE_OK = "1" &SchedulerServiceFeature=3 AND VALIDATE_OK = "1" @@ -389,7 +395,11 @@ ""]]> "" AND DSOP_UPN = ""]]> - 1 + + + 1 + + VALIDATE_OK="0" 1 @@ -437,21 +447,28 @@ ""]]> "" AND DSOP_UPN = ""]]> - 1 + + + + 1 1 1 - - - - 3]]> - 3 AND &PortalFeature<>3]]> + + + + + + + 3 AND COMPFOUND_ESERVER=0]]> + 3 AND &PortalFeature<>3 AND COMPFOUND_SERVER=0]]> 1 1 1 + Please wait while [ProductName] Installer configures IIS & ASP.NET, this may take a few minutes. Thanks! @@ -476,7 +493,7 @@ - + @@ -503,7 +520,7 @@ - + @@ -512,7 +529,7 @@ - + @@ -522,7 +539,7 @@ - + @@ -539,9 +556,15 @@ - - + + + + + + + + @@ -576,7 +599,7 @@ - + @@ -584,15 +607,23 @@ - + + + + + + + + - WSP_ROOT + WSP_BASE + - + @@ -609,9 +640,19 @@ - + + + + + + + + + + + @@ -630,7 +671,7 @@ - (NOT Installed OR NOT WIX_UPGRADE_DETECTED) AND NOT(DB_AUTH = "Windows Authentication") + (NOT Installed AND NOT WIX_UPGRADE_DETECTED) AND NOT(DB_AUTH = "Windows Authentication") - (NOT Installed OR NOT WIX_UPGRADE_DETECTED) AND (DB_AUTH = "Windows Authentication") + (NOT Installed AND NOT WIX_UPGRADE_DETECTED) AND (DB_AUTH = "Windows Authentication") - - + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/StandaloneServerActionManager.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/StandaloneServerActionManager.cs index 60b02246..b1cdb349 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/StandaloneServerActionManager.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/StandaloneServerActionManager.cs @@ -651,12 +651,11 @@ namespace WebsitePanel.Setup.Actions user.IsPeer = false; user.HtmlMail = true; user.Username = loginName; - user.Password = password; user.FirstName = firstName; user.LastName = lastName; user.Email = email; - int userId = ES.Services.Users.AddUser(user, false); + int userId = ES.Services.Users.AddUser(user, false, password); if (userId > 0) { Log.WriteEnd("Added user account"); diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Global.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Global.cs index 6bf1759f..e0215046 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Global.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Global.cs @@ -39,6 +39,7 @@ namespace WebsitePanel.Setup public const string DefaultInstallPathRoot = @"C:\WebsitePanel"; public const string LoopbackIPv4 = "127.0.0.1"; public const string InstallerProductCode = "cfg core"; + public const string DefaultProductName = "WebsitePanel"; public abstract class Parameters { diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/InstallAction.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/InstallAction.cs index 80d2f019..6cfa5953 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/InstallAction.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/InstallAction.cs @@ -88,7 +88,8 @@ namespace WebsitePanel.Setup SwitchServer2AspNet40, SwitchEntServer2AspNet40, SwitchWebPortal2AspNet40, - ConfigureSecureSessionModuleInWebConfig + ConfigureSecureSessionModuleInWebConfig, + RestoreConfig } public class InstallAction diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs index c41de825..2a0292d2 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs @@ -322,12 +322,30 @@ namespace WebsitePanel.Setup case WindowsVersion.WindowsServer2008: ret = "Windows Server 2008"; break; + case WindowsVersion.WindowsServer2008R2: + ret = "Windows Server 2008 R2"; + break; + case WindowsVersion.WindowsServer2012: + ret = "Windows Server 2012"; + break; + case WindowsVersion.WindowsServer2012R2: + ret = "Windows Server 2012 R2"; + break; case WindowsVersion.WindowsVista: ret = "Windows Vista"; break; case WindowsVersion.WindowsXP: ret = "Windows XP"; break; + case WindowsVersion.Windows7: + ret = "Windows 7"; + break; + case WindowsVersion.Windows8: + ret = "Windows 8"; + break; + default: + ret = "Windows"; + break; } return ret; } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs index 60ab6e24..ea1913ec 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs @@ -94,6 +94,9 @@ namespace WebsitePanel.Setup.Internal case SetupActions.Uninstall: Uninstall(); break; + case SetupActions.Setup: + Maintenance(); + break; default: throw new NotImplementedException(); } @@ -101,6 +104,7 @@ namespace WebsitePanel.Setup.Internal protected abstract void Install(); protected abstract void Uninstall(); + protected abstract void Maintenance(); /// /// LoadSetupVariablesFromParameters. @@ -166,9 +170,13 @@ namespace WebsitePanel.Setup.Internal } public static string GetComponentID(SetupVariables Ctx) { - var XmlPath = string.Format("//component[.//add/@key='ComponentCode' and .//add/@value='{0}']", Ctx.ComponentCode); + return GetComponentID(GetFullConfigPath(Ctx), Ctx.ComponentCode); + } + public static string GetComponentID(string Cfg, string ComponentCode) + { + var XmlPath = string.Format("//component[.//add/@key='ComponentCode' and .//add/@value='{0}']", ComponentCode); var Xml = new XmlDocument(); - Xml.Load(GetFullConfigPath(Ctx)); + Xml.Load(Cfg); var Node = Xml.SelectSingleNode(XmlPath) as XmlElement; return Node == null ? null : Node.GetAttribute("id"); } @@ -393,6 +401,9 @@ namespace WebsitePanel.Setup.Internal case ActionTypes.ConfigureSecureSessionModuleInWebConfig: ConfigureSecureSessionModuleInWebConfig(); break; + case ActionTypes.RestoreConfig: + RestoreXmlConfigs(Execute.SetupVariables); + break; } } catch (Exception ex) @@ -402,7 +413,6 @@ namespace WebsitePanel.Setup.Internal } } } - protected virtual List GetActions(string ComponentID) { return new List(); @@ -843,7 +853,7 @@ namespace WebsitePanel.Setup.Internal return; } // Load web.config - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(webConfigPath); // add node: @@ -993,7 +1003,7 @@ namespace WebsitePanel.Setup.Internal return; } // Load web.config - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(webConfigPath); // do Windows 2008 platform-specific changes bool iis7 = (Context.IISVersion.Major >= 7); @@ -1229,7 +1239,7 @@ namespace WebsitePanel.Setup.Internal private string GetConnectionString(string webConfigPath) { string ret = null; - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(webConfigPath); //connection string string xPath = "configuration/connectionStrings/add[@name=\"EnterpriseServer\"]"; @@ -1244,7 +1254,7 @@ namespace WebsitePanel.Setup.Internal private string GetCryptoKey(string webConfigPath) { string ret = null; - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(webConfigPath); //crypto key string xPath = "configuration/appSettings/add[@key=\"WebsitePanel.CryptoKey\"]"; @@ -1258,7 +1268,7 @@ namespace WebsitePanel.Setup.Internal private bool IsEncryptionEnabled(string webConfigPath) { - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(webConfigPath); //encryption enabled string xPath = "configuration/appSettings/add[@key=\"WebsitePanel.EncryptionEnabled\"]"; @@ -1710,12 +1720,11 @@ namespace WebsitePanel.Setup.Internal user.IsPeer = false; user.HtmlMail = true; user.Username = loginName; - user.Password = password; user.FirstName = firstName; user.LastName = lastName; user.Email = email; - int userId = ES.Services.Users.AddUser(user, false); + int userId = ES.Services.Users.AddUser(user, false, password); if (userId > 0) { Log.WriteEnd("Added user account"); @@ -2316,7 +2325,7 @@ namespace WebsitePanel.Setup.Internal } Log.WriteStart("Updating config.xml file"); - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(path); XmlNode serversNode = doc.SelectSingleNode("//myLittleAdmin/sqlservers"); @@ -2429,7 +2438,7 @@ namespace WebsitePanel.Setup.Internal return; } // Load web.config - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(webConfigPath); // Tighten WSE security on local machine @@ -2513,7 +2522,7 @@ namespace WebsitePanel.Setup.Internal } Log.WriteStart("Loading portal settings"); - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(path); string xPath = "configuration/connectionStrings/add[@name=\"SiteSqlServer\"]"; @@ -2605,7 +2614,7 @@ namespace WebsitePanel.Setup.Internal } Log.WriteStart("Updating site settings"); - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(path); XmlElement urlNode = doc.SelectSingleNode("SiteSettings/EnterpriseServer") as XmlElement; @@ -3178,7 +3187,7 @@ namespace WebsitePanel.Setup.Internal } Log.WriteStart("Updating configuration file (server password)"); - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(path); XmlElement passwordNode = doc.SelectSingleNode("//websitepanel.server/security/password") as XmlElement; @@ -3221,7 +3230,7 @@ namespace WebsitePanel.Setup.Internal } Log.WriteStart("Updating configuration file (service settings)"); - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(path); XmlElement ipNode = doc.SelectSingleNode("//configuration/appSettings/add[@key='WebsitePanel.HostIP']") as XmlElement; @@ -3881,7 +3890,7 @@ namespace WebsitePanel.Setup.Internal return; } // Load web.config - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(webConfigPath); // replace existing node: @@ -3915,8 +3924,61 @@ namespace WebsitePanel.Setup.Internal } #endregion #endregion + private void RestoreXmlConfigs(SetupVariables Ctx) + { + try + { + Log.WriteStart("RestoreXmlConfigs"); + var Backup = BackupRestore.Find(Ctx.InstallerFolder, Global.DefaultProductName, Ctx.ComponentName); + switch(Ctx.ComponentCode) + { + case Global.Server.ComponentCode: + { + Backup.XmlFiles.Add("Web.config"); + } + break; + case Global.EntServer.ComponentCode: + { + Backup.XmlFiles.Add("Web.config"); + } + break; + case Global.WebPortal.ComponentCode: + { + Backup.XmlFiles.Add("Web.config"); + Backup.XmlFiles.Add(@"App_Data\Countries.config"); + Backup.XmlFiles.Add(@"App_Data\CountryStates.config"); + Backup.XmlFiles.Add(@"App_Data\Ecommerce_Modules.config"); + Backup.XmlFiles.Add(@"App_Data\Ecommerce_Pages.config"); + Backup.XmlFiles.Add(@"App_Data\ESModule_ControlsHierarchy.config"); + Backup.XmlFiles.Add(@"App_Data\ModulesData.config"); + Backup.XmlFiles.Add(@"App_Data\SiteSettings.config"); + Backup.XmlFiles.Add(@"App_Data\SupportedLocales.config"); + Backup.XmlFiles.Add(@"App_Data\SupportedThemes.config"); + Backup.XmlFiles.Add(@"App_Data\WebsitePanel_Modules.config"); + Backup.XmlFiles.Add(@"App_Data\WebsitePanel_Pages.config"); + } + break; + } + var MainCfg = Path.Combine(Ctx.InstallerFolder, BackupRestore.MainConfig); + if (!BackupRestore.HaveChild(MainCfg, "//components")) + { + Log.WriteInfo("Restoring main config..."); + XmlDocumentMerge.Process(Backup.BackupMainConfigFile, MainCfg); + Context.ComponentId = WiXSetup.GetComponentID(Ctx); + AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = MainCfg }); + AppConfig.LoadComponentSettings(Ctx); + } + Log.WriteInfo(string.Format("Restoring xml config for component - {0}.", Ctx.ComponentFullName)); + Backup.Restore(); + Log.WriteEnd("RestoreXmlConfigs"); + } + catch (Exception ex) + { + Log.WriteError("RestoreXmlConfigs", ex); + throw; + } + } } - public class UninstallScript : SetupScript // UninstallPage { public UninstallScript(SetupVariables SessionVariables):base(SessionVariables) @@ -4117,12 +4179,22 @@ namespace WebsitePanel.Setup.Internal protected override List GetActions(string ComponentID) { var Scenario = base.GetActions(ComponentID); - var Act = new InstallAction(ActionTypes.UpdateConfig); - Act.Description = "Updating system configuration..."; - Scenario.Add(Act); - Act = new InstallAction(ActionTypes.StartApplicationPool); - Act.Description = "Starting IIS Application Pool..."; - Scenario.Add(Act); + Scenario.Add(new InstallAction(ActionTypes.RestoreConfig) { SetupVariables = Context, Description = "Restoring xml configuration files..." }); + Scenario.Add(new InstallAction(ActionTypes.UpdateConfig) { Description = "Updating system configuration..." }); + Scenario.Add(new InstallAction(ActionTypes.StartApplicationPool) { Description = "Starting IIS Application Pool..." }); + return Scenario; + } + } + public class MaintenanceScript: ExpressScript + { + public MaintenanceScript(SetupVariables SessionVariables):base(SessionVariables) + { + Context.SetupAction = SetupActions.Setup; + } + protected override List GetActions(string ComponentID) + { + var Scenario = base.GetActions(ComponentID); + Scenario.Add(new InstallAction(ActionTypes.UpdateConfig) { Description = "Updating system configuration..." }); return Scenario; } } @@ -4170,6 +4242,7 @@ namespace WebsitePanel.Setup.Internal else if (ModeExtension == ModeExtension.Restore) { Context.ComponentId = GetComponentID(Context); + Context.UpdateVersion = Context.Release; AppConfig.LoadComponentSettings(Context); new RestoreScript(Context).Run(); } @@ -4194,12 +4267,19 @@ namespace WebsitePanel.Setup.Internal } Script.Run(); } + protected override void Maintenance() + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + SetupScript Script = new MaintenanceScript(Context); + Script.Actions.Add(new InstallAction(ActionTypes.UpdateServerPassword) { Description = "Updating server password..." }); + Script.Run(); + } } - public class EServerSetup : WiXSetup { - public EServerSetup(SetupVariables Ctx) - : base(Ctx) + public EServerSetup(SetupVariables Ctx, ModeExtension Ext) + : base(Ctx, Ext) { } @@ -4210,7 +4290,7 @@ namespace WebsitePanel.Setup.Internal SetupVars.SetupAction = Action; SetupVars.IISVersion = Global.IISVersion; AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = GetFullConfigPath(SetupVars) }); - return new EServerSetup(SetupVars); + return new EServerSetup(SetupVars, GetModeExtension(Ctx)); } protected override void Install() { @@ -4240,6 +4320,7 @@ namespace WebsitePanel.Setup.Internal else if (ModeExtension == ModeExtension.Restore) { Context.ComponentId = GetComponentID(Context); + Context.UpdateVersion = Context.Release; AppConfig.LoadComponentSettings(Context); new RestoreScript(Context).Run(); } @@ -4264,12 +4345,19 @@ namespace WebsitePanel.Setup.Internal } Script.Run(); } + protected override void Maintenance() + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + SetupScript Script = new MaintenanceScript(Context); + Script.Actions.Add(new InstallAction(ActionTypes.UpdateServerAdminPassword) { Description = "Updating serveradmin password..." }); + Script.Run(); + } } - public class PortalSetup : WiXSetup { - public PortalSetup(SetupVariables Ctx) - : base(Ctx) + public PortalSetup(SetupVariables Ctx, ModeExtension Ext) + : base(Ctx, Ext) { } @@ -4280,7 +4368,7 @@ namespace WebsitePanel.Setup.Internal SetupVars.SetupAction = Action; SetupVars.IISVersion = Global.IISVersion; AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = GetFullConfigPath(SetupVars) }); - return new PortalSetup(SetupVars); + return new PortalSetup(SetupVars, GetModeExtension(Ctx)); } protected override void Install() { @@ -4306,17 +4394,11 @@ namespace WebsitePanel.Setup.Internal } if (WiXThrow) InstallFailed(); - - else if (ModeExtension == ModeExtension.Restore) - { - Context.ComponentId = GetComponentID(Context); - AppConfig.LoadComponentSettings(Context); - new RestoreScript(Context).Run(); - } } else if (ModeExtension == ModeExtension.Restore) { Context.ComponentId = GetComponentID(Context); + Context.UpdateVersion = Context.Release; AppConfig.LoadComponentSettings(Context); new RestoreScript(Context).Run(); } @@ -4348,8 +4430,15 @@ namespace WebsitePanel.Setup.Internal } Script.Run(); } + protected override void Maintenance() + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + SetupScript Script = new MaintenanceScript(Context); + Script.Actions.Add(new InstallAction(ActionTypes.UpdateEnterpriseServerUrl) { Description = "Updating site settings..." }); + Script.Run(); + } } - #region WiXActionManagers public class WiXServerActionManager : BaseActionManager { diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/BackupRestore.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/BackupRestore.cs new file mode 100644 index 00000000..91890d6e --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/BackupRestore.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Xml; +using Ionic.Zip; + +namespace WebsitePanel.Setup.Internal +{ + public class BackupRestore + { + struct DirectoryTag + { + public string Name; + public DateTime Date; + public Version Version; + } + public const string MainConfig = "WebsitePanel.config"; + const string BackupDirectory = "Backup"; + const string ConfigDirectory = "Config"; + const string AppZip = @"App\app.zip"; + const string DateFormat = "yyyy-MM-dd"; + public BackupRestore() + { + XmlFiles = new List(); + } + public static BackupRestore Find(string Root, string Product, string Id) + { + var Result = default(BackupRestore); + var Dir = Path.Combine(Root, BackupDirectory); + var FullId = GetFullId(Product, Id); + if (Directory.Exists(Dir)) + { + var DirList = new List(); + foreach (var DateItem in Directory.GetDirectories(Dir)) + { + DateTime date; + var DateName = new DirectoryInfo(DateItem).Name; + if (DateTime.TryParseExact(DateName, DateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out date)) + { + foreach (var VersionItem in Directory.GetDirectories(DateItem)) + { + var VersionName = new DirectoryInfo(VersionItem).Name; + if (VersionName.StartsWith(FullId, StringComparison.InvariantCultureIgnoreCase)) + { + Version BckpVersion; + var StrVersion = VersionName.Substring(FullId.Length); + if (Version.TryParse(StrVersion, out BckpVersion)) + DirList.Add(new DirectoryTag { Name = VersionItem, Date = date, Version = BckpVersion }); + } + } + } + } + var ByVersion = from i in DirList where i.Version == (from v in DirList select v.Version).Max() select i; + var ByDate = from i in ByVersion where i.Date == (from v in ByVersion select v.Date).Max() select i; + var SrcTag = ByDate.First(); + Result = new BackupRestore { Id = Id, Root = GetComponentRoot(SrcTag, Id), BackupFile = Path.Combine(SrcTag.Name, AppZip), BackupMainConfigFile = GetMainConfig(SrcTag) }; + } + return Result; + } + public static bool HaveChild(string XmlDocPath, string XmlPath) + { + var Result = false; + var XCfg = new XmlDocument(); + XCfg.Load(XmlDocPath); + var Node = XCfg.SelectSingleNode(XmlPath); + if (Node != null) + Result = Node.ChildNodes.Count > 0; + return Result; + } + private static string GetComponentRoot(DirectoryTag DirTag, string Id) + { + var Cfg = GetMainConfig(DirTag); + if (string.IsNullOrWhiteSpace(Cfg)) + throw new Exception("Broken backup. Main config file not found."); + var XCfg = new XmlDocument(); + XCfg.Load(Cfg); + var Component = XCfg.SelectSingleNode(string.Format("//component[.//add/@key='ComponentName' and .//add/@value='{0}']", Id)); + var InstallFolder = Component.SelectSingleNode(".//add[@key='InstallFolder']"); + return InstallFolder.Attributes["value"].Value; + } + private static string GetMainConfig(DirectoryTag DirTag) + { + return Path.Combine(DirTag.Name, ConfigDirectory, MainConfig); + } + private static string GetFullId(string Product, string Id) + { + return string.Format("{0} {1}", Product, Id); + } + public virtual void Restore() + { + using (var Bckp = new ZipFile(BackupFile)) + { + foreach (var Xml in XmlFiles) + { + var SrcEntry = from Entry in Bckp.Entries where NormalizePath(Entry.FileName.ToLowerInvariant(), "/") == Xml.ToLowerInvariant() select Entry; + if (SrcEntry != null) + { + if (SrcEntry.LongCount() > 1) + throw new Exception(string.Format("Too many backup entries - {0}.", Xml)); + var FileEntry = SrcEntry.FirstOrDefault(); + if (FileEntry != null) + { + using (var InMem = new MemoryStream()) + { + FileEntry.Extract(InMem); + InMem.Seek(0, SeekOrigin.Begin); + using (var OutFile = new FileStream(Path.Combine(Root, Xml), FileMode.Open, FileAccess.ReadWrite)) + { + XmlDocumentMerge.Process(InMem, OutFile); + } + } + } + } + } + } + } + private string NormalizePath(string FilePath, string In) + { + return Path.Combine(FilePath.Split(new string[] { In }, StringSplitOptions.RemoveEmptyEntries)); + } + public string Id { get; set; } // Component full name. + public string Comment { get; set; } + public string BackupFile { get; set; } // Should be zip archive. + public string BackupMainConfigFile { get; set; } + public IList XmlFiles { get; set; } // Xml files (configs) to merge and update. + public string Root { get; set; } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/XmlDocumentMerge.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/XmlDocumentMerge.cs new file mode 100644 index 00000000..4c4511c4 --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/XmlDocumentMerge.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; +using System.Xml.XPath; + +namespace WebsitePanel.Setup.Internal +{ + public static class XmlDocumentMerge + { + const string SuccessFormat = "Success: {0}."; + const string ErrorFormat = "Error: {0}."; + const string MergeCompleted = "XmlDocumentMerge completed"; + static XmlDocumentMerge() + { + KeyAttributes = new List { "name", "id", "key" }; + } + public static List KeyAttributes { get; set; } + public static string Process(string Src, string Dst, string SaveTo = "") + { + var Result = string.Empty; + if (!File.Exists(Src)) + Result = string.Format(ErrorFormat, string.Format("source document [{0}] does not exists", Src)); + else if (!File.Exists(Dst)) + Result = string.Format(ErrorFormat, string.Format("destination document [{0}] does not exists", Dst)); + else + { + try + { + var InStream = new FileStream(Src, FileMode.Open, FileAccess.Read); + var OutStream = new FileStream(Dst, FileMode.Open, FileAccess.ReadWrite); + Result = Process(InStream, + OutStream, + SaveTo); + InStream.Close(); + OutStream.Flush(); + OutStream.Close(); + } + catch (Exception ex) + { + Result = string.Format(ErrorFormat, ex.ToString()); + } + } + return Result; + } + public static string Process(Stream InSrc, Stream OutDst, string SaveTo = "") + { + var Result = string.Format(SuccessFormat, MergeCompleted); + try + { + var SrcDoc = new XmlDocument(); + SrcDoc.Load(InSrc); + var DstDoc = new XmlDocument(); + DstDoc.Load(OutDst); + var DstNavi = DstDoc.CreateNavigator(); + var DstIterator = DstNavi.SelectChildren(XPathNodeType.All); + while (DstIterator.MoveNext()) + Merge(DstIterator.Current.Clone(), SrcDoc, string.Empty); + if (string.IsNullOrWhiteSpace(SaveTo)) + { + OutDst.SetLength(0); + DstDoc.Save(OutDst); + } + else + DstDoc.Save(SaveTo); + } + catch (Exception ex) + { + Result = string.Format(ErrorFormat, ex.ToString()); + } + return Result; + } + private static string NodePath(string Parent, string Current) + { + var Result = string.Empty; + if (!string.IsNullOrWhiteSpace(Parent) && !string.IsNullOrWhiteSpace(Current)) + Result = string.Format("{0}/{1}", Parent, Current); + else if (!string.IsNullOrWhiteSpace(Parent)) + Result = Parent; + else if (!string.IsNullOrWhiteSpace(Current)) + Result = Current; + return Result; + } + private static string NodeView(XPathNavigator Navi) + { + foreach (var Attr in KeyAttributes) + { + var Value = Navi.GetAttribute(Attr, string.Empty); + if (!string.IsNullOrWhiteSpace(Value)) + return string.Format("{0}[@{1}='{2}']", Navi.Name, Attr, Value); + } + return Navi.Name; + } + private static void Merge(XPathNavigator DstNavi, XmlDocument SrcDoc, string Parent) + { + if (DstNavi.NodeType == XPathNodeType.Element) + { + var SrcElem = SrcDoc.SelectSingleNode(NodePath(Parent, NodeView(DstNavi))); + if (SrcElem != null) + { + if (DstNavi.MoveToFirstAttribute()) + { + do + { + var SrcElemAttr = SrcElem.Attributes[DstNavi.LocalName]; + if (SrcElemAttr != null) + DstNavi.SetValue(SrcElemAttr.Value); + } + while (DstNavi.MoveToNextAttribute()); + DstNavi.MoveToParent(); + } + } + } + else if (DstNavi.NodeType == XPathNodeType.Text) + { + var SrcElem = SrcDoc.SelectSingleNode(NodePath(Parent, NodeView(DstNavi))); + if (SrcElem != null) + DstNavi.SetValue(SrcElem.InnerText); + } + var Here = NodeView(DstNavi); + if (DstNavi.MoveToFirstChild()) + { + do + { + Merge(DstNavi, SrcDoc, NodePath(Parent, Here)); + } + while (DstNavi.MoveToNext()); + DstNavi.MoveToParent(); + } + else if (DstNavi.NodeType == XPathNodeType.Element) + { + var SrcElem = SrcDoc.SelectSingleNode(NodePath(Parent, Here)); + if (SrcElem != null && !string.IsNullOrWhiteSpace(SrcElem.InnerXml)) + foreach (XmlNode Child in SrcElem.ChildNodes) + DstNavi.AppendChild(Child.CloneNode(true).CreateNavigator()); + } + } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj index 246d4850..864c3e5d 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj @@ -144,6 +144,8 @@ + + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ExpressInstallPage.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ExpressInstallPage.cs index 82062a32..29056db1 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ExpressInstallPage.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ExpressInstallPage.cs @@ -1153,12 +1153,11 @@ namespace WebsitePanel.Setup user.IsPeer = false; user.HtmlMail = true; user.Username = loginName; - user.Password = password; user.FirstName = firstName; user.LastName = lastName; user.Email = email; - int userId = ES.Services.Users.AddUser(user, false); + int userId = ES.Services.Users.AddUser(user, false, password); if (userId > 0) { Log.WriteEnd("Added user account"); diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogFileListener.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogFileListener.cs new file mode 100644 index 00000000..623505fa --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogFileListener.cs @@ -0,0 +1,55 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using Microsoft.Deployment.WindowsInstaller; + +namespace WebsitePanel.WIXInstaller.Common +{ + public class WiXLogFileListener : TraceListener + { + public const uint FileFlushSize = 4096; + public const string DefaultLogFile = "WSPInstallation.log.txt"; + public static string LogFile { get; private set; } + private StringBuilder m_Ctx; + static WiXLogFileListener() + { + LogFile = Path.Combine(Path.GetTempPath() + DefaultLogFile); + } + public WiXLogFileListener(string LogFileName = DefaultLogFile) + : base("WiXLogFileListener") + { + m_Ctx = new StringBuilder(); + } + ~WiXLogFileListener() + { + Dispose(false); + } + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + Flush(true); + } + public override void Write(string Value) + { + m_Ctx.Append(Value); + Flush(); + } + public override void WriteLine(string Value) + { + m_Ctx.AppendLine(Value); + Flush(); + } + private void Flush(bool Force = false) + { + if(m_Ctx.Length >= FileFlushSize || Force) + { + using (var FileCtx = new StreamWriter(LogFile, true)) + { + FileCtx.Write(m_Ctx.ToString()); + } + m_Ctx.Clear(); + } + } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs index 2f652068..0ff7782e 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs @@ -27,6 +27,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; using System.Collections.Generic; +using System.Configuration; using System.Configuration.Install; using System.Data; using System.Data.Sql; @@ -54,6 +55,144 @@ namespace WebsitePanel.WIXInstaller #region CustomActions [CustomAction] + public static ActionResult MaintenanceServer(Session session) + { + var Result = ActionResult.Success; + Log.WriteStart("MaintenanceServer"); + Result = ProcessInstall(session, WiXInstallType.MaintenanceServer); + Log.WriteEnd("MaintenanceServer"); + return Result; + } + [CustomAction] + public static ActionResult MaintenanceEServer(Session session) + { + var Result = ActionResult.Success; + Log.WriteStart("MaintenanceEServer"); + Result = ProcessInstall(session, WiXInstallType.MaintenanceEnterpriseServer); + Log.WriteEnd("MaintenanceEServer"); + return Result; + } + [CustomAction] + public static ActionResult MaintenancePortal(Session session) + { + var Result = ActionResult.Success; + Log.WriteStart("MaintenancePortal"); + Result = ProcessInstall(session, WiXInstallType.MaintenancePortal); + Log.WriteEnd("MaintenancePortal"); + return Result; + } + [CustomAction] + public static ActionResult PreFillSettings(Session session) + { + PopUpDebugger(); + var Ctx = session; + Ctx.AttachToSetupLog(); + Log.WriteStart("PreFillSettings"); + var WSP = Ctx["WEBSITEPANELDIR"]; + var CfgStr = string.Empty; + Func GetCfg = (string CfgDir) => + { + if (Directory.Exists(CfgDir)) + { + var CfgFile = Path.Combine(CfgDir, BackupRestore.MainConfig); + if (File.Exists(CfgFile) && BackupRestore.HaveChild(CfgFile, "//components")) + return CfgFile; + else + { + var Names = new string[] { Global.Server.ComponentName, Global.EntServer.ComponentName, Global.WebPortal.ComponentName }; + foreach (var Name in Names) + { + var Backup = BackupRestore.Find(CfgDir, Global.DefaultProductName, Name); + if (Backup != null && BackupRestore.HaveChild(Backup.BackupMainConfigFile, "//components")) + return CfgStr = Backup.BackupMainConfigFile; + } + } + } + return string.Empty; + }; + Func SetProperty = (Session CtxSession, string Prop, string Value) => + { + if(!string.IsNullOrWhiteSpace(Value)) + { + CtxSession[Prop] = Value; + return true; + } + return false; + }; + CfgStr = GetCfg(WSP); + if(string.IsNullOrWhiteSpace(CfgStr)) + { + var Drives = from Drive in DriveInfo.GetDrives() where Drive.DriveType == DriveType.Fixed select Drive; + foreach(var Drive in Drives) + { + var Dir = Path.Combine(Drive.RootDirectory.FullName, Global.DefaultProductName); + CfgStr = GetCfg(Dir); + if (!string.IsNullOrWhiteSpace(CfgStr)) + break; + } + } + if (!string.IsNullOrWhiteSpace(CfgStr)) + { + var EServerUrl = string.Empty; + AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = CfgStr }); + var CtxVars = new SetupVariables(); + CtxVars.ComponentId = WiXSetup.GetComponentID(CfgStr, Global.Server.ComponentCode); + if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) + { + AppConfig.LoadComponentSettings(CtxVars); + Ctx["COMPFOUND_SERVER"] = "1"; + SetProperty(Ctx, "PI_SERVER_IP", CtxVars.WebSiteIP); + SetProperty(Ctx, "PI_SERVER_PORT", CtxVars.WebSitePort); + SetProperty(Ctx, "PI_SERVER_HOST", CtxVars.WebSiteDomain); + SetProperty(Ctx, "PI_SERVER_LOGIN", CtxVars.UserAccount); + SetProperty(Ctx, "PI_SERVER_PASSWORD", CtxVars.UserPassword); + SetProperty(Ctx, "PI_SERVER_PASSWORD_CONFIRM",CtxVars.UserPassword); + SetProperty(Ctx, "PI_SERVER_DOMAIN", CtxVars.UserDomain); + SetProperty(Ctx, "SERVER_ACCESS_PASSWORD", CtxVars.ServerPassword); + SetProperty(Ctx, "SERVER_ACCESS_PASSWORD_CONFIRM", CtxVars.ServerPassword); + } + CtxVars.ComponentId = WiXSetup.GetComponentID(CfgStr, Global.EntServer.ComponentCode); + if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) + { + AppConfig.LoadComponentSettings(CtxVars); + Ctx["COMPFOUND_ESERVER"] = "1"; + SetProperty(Ctx, "PI_ESERVER_IP", CtxVars.WebSiteIP); + SetProperty(Ctx, "PI_ESERVER_PORT", CtxVars.WebSitePort); + SetProperty(Ctx, "PI_ESERVER_HOST", CtxVars.WebSiteDomain); + SetProperty(Ctx, "PI_ESERVER_LOGIN", CtxVars.UserAccount); + SetProperty(Ctx, "PI_ESERVER_PASSWORD", CtxVars.UserPassword); + SetProperty(Ctx, "PI_ESERVER_PASSWORD_CONFIRM", CtxVars.UserPassword); + SetProperty(Ctx, "PI_ESERVER_DOMAIN", CtxVars.UserDomain); + SetProperty(Ctx, "SERVERADMIN_PASSWORD", CtxVars.ServerAdminPassword); + SetProperty(Ctx, "SERVERADMIN_PASSWORD_CONFIRM", CtxVars.ServerAdminPassword); + EServerUrl = string.Format("http://{0}:{1}", CtxVars.WebSiteIP, CtxVars.WebSitePort); + } + CtxVars.ComponentId = WiXSetup.GetComponentID(CfgStr, Global.WebPortal.ComponentCode); + if (!string.IsNullOrWhiteSpace(CtxVars.ComponentId)) + { + AppConfig.LoadComponentSettings(CtxVars); + Ctx["COMPFOUND_PORTAL"] = "1"; + SetProperty(Ctx, "PI_PORTAL_IP", CtxVars.WebSiteIP); + SetProperty(Ctx, "PI_PORTAL_PORT", CtxVars.WebSitePort); + SetProperty(Ctx, "PI_PORTAL_HOST", CtxVars.WebSiteDomain); + SetProperty(Ctx, "PI_PORTAL_LOGIN", CtxVars.UserAccount); + SetProperty(Ctx, "PI_PORTAL_PASSWORD", CtxVars.UserPassword); + SetProperty(Ctx, "PI_PORTAL_PASSWORD_CONFIRM", CtxVars.UserPassword); + SetProperty(Ctx, "PI_PORTAL_DOMAIN", CtxVars.UserDomain); + if (!SetProperty(Ctx, "PI_ESERVER_URL", CtxVars.EnterpriseServerURL)) + if (!SetProperty(Ctx, "PI_ESERVER_URL", EServerUrl)) + SetProperty(Ctx, "PI_ESERVER_URL", Global.WebPortal.DefaultEntServURL); + } + } + TryApllyNewPassword(Ctx, "PI_SERVER_PASSWORD"); + TryApllyNewPassword(Ctx, "PI_ESERVER_PASSWORD"); + TryApllyNewPassword(Ctx, "PI_PORTAL_PASSWORD"); + TryApllyNewPassword(Ctx, "SERVER_ACCESS_PASSWORD"); + TryApllyNewPassword(Ctx, "SERVERADMIN_PASSWORD"); + Log.WriteEnd("PreFillSettings"); + return ActionResult.Success; + } + [CustomAction] public static ActionResult InstallWebFeatures(Session session) { var Msg = string.Empty; @@ -406,6 +545,7 @@ namespace WebsitePanel.WIXInstaller [CustomAction] public static ActionResult FillIpListUI(Session session) { + PopUpDebugger(); var Ctrls = new[]{ new ComboBoxCtrl(session, "PI_SERVER_IP"), new ComboBoxCtrl(session, "PI_ESERVER_IP"), new ComboBoxCtrl(session, "PI_PORTAL_IP") }; @@ -717,18 +857,27 @@ namespace WebsitePanel.WIXInstaller case WiXInstallType.RemoveServer: Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); break; + case WiXInstallType.MaintenanceServer: + Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Setup); + break; case WiXInstallType.InstallEnterpriseServer: Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Install); break; case WiXInstallType.RemoveEnterpriseServer: Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); break; + case WiXInstallType.MaintenanceEnterpriseServer: + Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Setup); + break; case WiXInstallType.InstallPortal: Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Install); break; case WiXInstallType.RemovePortal: Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); break; + case WiXInstallType.MaintenancePortal: + Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Setup); + break; default: throw new NotImplementedException(); } @@ -751,6 +900,17 @@ namespace WebsitePanel.WIXInstaller { Debugger.Launch(); } + private static void TryApllyNewPassword(Session Ctx, string Id) + { + var Pass = Ctx[Id]; + if (string.IsNullOrWhiteSpace(Pass)) + { + Pass = Guid.NewGuid().ToString(); + Ctx[Id] = Pass; + Ctx[Id + "_CONFIRM"] = Pass; + Log.WriteInfo("New password was applied to " + Id); + } + } } public static class SessionExtension { @@ -758,9 +918,9 @@ namespace WebsitePanel.WIXInstaller { WiXSetup.InstallLogListener(new WiXLogListener(Ctx)); WiXSetup.InstallLogListener(new InMemoryStringLogListener("WIX CA IN MEMORY")); + WiXSetup.InstallLogListener(new WiXLogFileListener()); } } - internal enum WiXInstallType: byte { InstallServer, @@ -769,7 +929,8 @@ namespace WebsitePanel.WIXInstaller RemoveServer, RemoveEnterpriseServer, RemovePortal, - RemoveUpdate, - RestoreUpdate + MaintenanceServer, + MaintenanceEnterpriseServer, + MaintenancePortal } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj index 59ae4596..0aee4f2c 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj @@ -47,6 +47,7 @@ ..\..\Lib\Microsoft.Web.Administration.dll + @@ -63,6 +64,7 @@ + diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 5126597e..b4cf06cb 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -8208,11 +8208,13 @@ AS INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) ELSE IF @QuotaID = 558 BEGIN -- RAM of VPS2012 - DECLARE @Result1 int = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + DECLARE @Result1 int + SET @Result1 = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) - DECLARE @Result2 int = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + DECLARE @Result2 int + SET @Result2 = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID INNER JOIN ServiceItemProperties AS SIP2 ON SIP2.ItemID = SI.ItemID AND SIP2.PropertyName = 'DynamicMemory.Enabled' AND SIP2.PropertyValue = 'True' @@ -9607,6 +9609,13 @@ IF EXISTS (SELECT * FROM ResourceGroups WHERE GroupName = 'SharePoint') BEGIN DECLARE @group_id INT SELECT @group_id = GroupId FROM ResourceGroups WHERE GroupName = 'SharePoint' + DELETE FROM PackageQuotas WHERE QuotaID IN (SELECT QuotaID FROM Quotas WHERE GroupID = @group_id) + DELETE FROM HostingPlanQuotas WHERE QuotaID IN (SELECT QuotaID FROM Quotas WHERE GroupID = @group_id) + DELETE FROM HostingPlanResources WHERE GroupId = @group_id + DELETE FROM PackagesBandwidth WHERE GroupId = @group_id + DELETE FROM PackagesDiskspace WHERE GroupId = @group_id + DELETE FROM PackageResources WHERE GroupId = @group_id + DELETE FROM ResourceGroupDnsRecords WHERE GroupId = @group_id DELETE FROM Providers WHERE GroupID = @group_id DELETE FROM Quotas WHERE GroupID = @group_id DELETE FROM VirtualGroups WHERE GroupID = @group_id diff --git a/WebsitePanel/Database/wix_update_db.sql b/WebsitePanel/Database/wix_update_db.sql index 4f342f1d..4131b41b 100644 --- a/WebsitePanel/Database/wix_update_db.sql +++ b/WebsitePanel/Database/wix_update_db.sql @@ -8197,11 +8197,13 @@ AS INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) ELSE IF @QuotaID = 558 BEGIN -- RAM of VPS2012 - DECLARE @Result1 int = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + DECLARE @Result1 int + SET @Result1 = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) - DECLARE @Result2 int = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + DECLARE @Result2 int + SET @Result2 = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID INNER JOIN ServiceItemProperties AS SIP2 ON SIP2.ItemID = SI.ItemID AND SIP2.PropertyName = 'DynamicMemory.Enabled' AND SIP2.PropertyValue = 'True' @@ -8910,6 +8912,12 @@ INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDe END GO +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaID] = '572') +BEGIN + INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (572, 33, 20, N'VPS2012.ReplicationEnabled', N'Allow user to Replication', 1, 0, NULL, NULL) +END +GO + IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [ProviderName] = 'HyperV2012R2') BEGIN INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (350, 33, N'HyperV2012R2', N'Microsoft Hyper-V 2012 R2', N'WebsitePanel.Providers.Virtualization.HyperV2012R2, WebsitePanel.Providers.Virtualization.HyperV2012R2', N'HyperV2012R2', 1) @@ -9590,6 +9598,13 @@ IF EXISTS (SELECT * FROM ResourceGroups WHERE GroupName = 'SharePoint') BEGIN DECLARE @group_id INT SELECT @group_id = GroupId FROM ResourceGroups WHERE GroupName = 'SharePoint' + DELETE FROM PackageQuotas WHERE QuotaID IN (SELECT QuotaID FROM Quotas WHERE GroupID = @group_id) + DELETE FROM HostingPlanQuotas WHERE QuotaID IN (SELECT QuotaID FROM Quotas WHERE GroupID = @group_id) + DELETE FROM HostingPlanResources WHERE GroupId = @group_id + DELETE FROM PackagesBandwidth WHERE GroupId = @group_id + DELETE FROM PackagesDiskspace WHERE GroupId = @group_id + DELETE FROM PackageResources WHERE GroupId = @group_id + DELETE FROM ResourceGroupDnsRecords WHERE GroupId = @group_id DELETE FROM Providers WHERE GroupID = @group_id DELETE FROM Quotas WHERE GroupID = @group_id DELETE FROM VirtualGroups WHERE GroupID = @group_id @@ -10020,6 +10035,145 @@ UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordResetLetterTextBo GO + + +DECLARE @UserPasswordResetSMSBody nvarchar(2500) + +Set @UserPasswordResetSMSBody = N'Password reset link: +#passwordResetLink# +' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'PasswordResetLinkSmsBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetLetter', N'PasswordResetLinkSmsBody', @UserPasswordResetSMSBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordResetSMSBody WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'PasswordResetLinkSmsBody' +GO + +-- USER PASSWORD RESET EMAIL PINCODE TEMPLATE + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'From' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetPincodeLetter', N'From', N'support@HostingCompany.com') +END +GO + +DECLARE @UserPasswordResetPincodeLetterHtmlBody nvarchar(2500) + +Set @UserPasswordResetPincodeLetterHtmlBody = N' + + Password reset notification + + + + + + + +Password reset notification + + + +Hello #user.FirstName#, + + + + +We received a request to reset the password for your account. Your password reset pincode: + + +#passwordResetPincode# + + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + + + +Best regards + + +'; + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'HtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetPincodeLetter', N'HtmlBody', @UserPasswordResetPincodeLetterHtmlBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordResetPincodeLetterHtmlBody WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'HtmlBody' +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'Priority' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetPincodeLetter', N'Priority', N'Normal') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'Subject' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetPincodeLetter', N'Subject', N'Password reset notification') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'LogoUrl' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetPincodeLetter', N'LogoUrl', N'https://controlpanel.virtuworks.net/App_Themes/Default/Images/logo.png') +END +GO + + +DECLARE @UserPasswordResetPincodeLetterTextBody nvarchar(2500) + +Set @UserPasswordResetPincodeLetterTextBody = N'========================================= + Password reset notification +========================================= + + +Hello #user.FirstName#, + + +We received a request to reset the password for your account. Your password reset pincode: + +#passwordResetPincode# + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'TextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetPincodeLetter', N'TextBody', @UserPasswordResetPincodeLetterTextBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordResetPincodeLetterTextBody WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'TextBody' +GO + +DECLARE @UserPasswordPincodeSMSBody nvarchar(2500) + +Set @UserPasswordPincodeSMSBody = N' +Your password reset pincode: +#passwordResetPincode#' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'PasswordResetPincodeSmsBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetPincodeLetter', N'PasswordResetPincodeSmsBody', @UserPasswordPincodeSMSBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordPincodeSMSBody WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetPincodeLetter' AND [PropertyName]= N'PasswordResetPincodeSmsBody' +GO + -- Exchange setup EMAIL TEMPLATE @@ -10289,79 +10443,79 @@ GO DECLARE @ExchangeMailboxSetupLetterTextBody nvarchar(2500) -Set @ExchangeMailboxSetupLetterTextBody = N' -Hello #Account.DisplayName#, - -Thanks for choosing VirtuWorks as your Exchange hosting provider. - - -User Accounts - -The following user accounts have been created for you. - -Username: #Account.UserPrincipalName# -E-mail: #Account.PrimaryEmailAddress# - -Password Reset Url: #PswResetUrl# - - - -================================= -DNS -================================= - -In order for us to accept mail for your domain, you will need to point your MX records to: - -#SmtpServer# - -================================= -Webmail (OWA, Outlook Web Access) -================================= - -https://mail.virtuworks.net/owa - -================================= -Outlook (Windows Clients) -================================= - -To configure Outlook 2010 to work with VirtuWorks servers, please reference: - -https://portal.virtuworks.net/whmcs/knowledgebase.php?action=displayarticle&id=2 - -If you need to download and install the Outlook 2010 client: - -Outlook 2010 Download URL: -32 Bit - http://www.virtuworks.net/downloads/Outlook2010-32bit.zip -64 Bit - http://www.virtuworks.net/downloads/Outlook2010-64bit.zip -KEY: HXGFV-DY3HM-4W2BQ-3R7KQ-K8P49 - -================================= -ActiveSync, iPhone, iPad -================================= - -Server: #ActiveSyncServer# -Domain: #SamDomain# -SSL: must be checked -Your username: #SamUsername# - -================================= -Password Changes -================================= - -Passwords can be changed at any time using Webmail or the Control Panel (https://controlpanel.virtuworks.net). - - -================================= -Control Panel -================================= - -If you need to change the details of your account, you can easily do this using the Control Panel (https://controlpanel.virtuworks.net). - - -================================= -Support -================================= - +Set @ExchangeMailboxSetupLetterTextBody = N' +Hello #Account.DisplayName#, + +Thanks for choosing VirtuWorks as your Exchange hosting provider. + + +User Accounts + +The following user accounts have been created for you. + +Username: #Account.UserPrincipalName# +E-mail: #Account.PrimaryEmailAddress# + +Password Reset Url: #PswResetUrl# + + + +================================= +DNS +================================= + +In order for us to accept mail for your domain, you will need to point your MX records to: + +#SmtpServer# + +================================= +Webmail (OWA, Outlook Web Access) +================================= + +https://mail.virtuworks.net/owa + +================================= +Outlook (Windows Clients) +================================= + +To configure Outlook 2010 to work with VirtuWorks servers, please reference: + +https://portal.virtuworks.net/whmcs/knowledgebase.php?action=displayarticle&id=2 + +If you need to download and install the Outlook 2010 client: + +Outlook 2010 Download URL: +32 Bit - http://www.virtuworks.net/downloads/Outlook2010-32bit.zip +64 Bit - http://www.virtuworks.net/downloads/Outlook2010-64bit.zip +KEY: HXGFV-DY3HM-4W2BQ-3R7KQ-K8P49 + +================================= +ActiveSync, iPhone, iPad +================================= + +Server: #ActiveSyncServer# +Domain: #SamDomain# +SSL: must be checked +Your username: #SamUsername# + +================================= +Password Changes +================================= + +Passwords can be changed at any time using Webmail or the Control Panel (https://controlpanel.virtuworks.net). + + +================================= +Control Panel +================================= + +If you need to change the details of your account, you can easily do this using the Control Panel (https://controlpanel.virtuworks.net). + + +================================= +Support +================================= + You have 2 options, email help@virtuworks.com or use the web interface at http://www.virtuworks.com/contact/' IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'ExchangeMailboxSetupLetter' AND [PropertyName]= N'TextBody' ) @@ -10674,3 +10828,265 @@ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER OFF GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetSearchObject') +DROP PROCEDURE GetSearchObject +GO +CREATE PROCEDURE [dbo].[GetSearchObject] +( + @ActorID int, + @UserID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @StatusID int, + @RoleID int, + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int = 0, + @Recursive bit, + @ColType nvarchar(50) = '', + @FullType nvarchar(50) = '', + @OnlyFind bit +) +AS + +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +DECLARE @columnUsername nvarchar(20) +SET @columnUsername = 'Username' + +DECLARE @columnEmail nvarchar(20) +SET @columnEmail = 'Email' + +DECLARE @columnCompanyName nvarchar(20) +SET @columnCompanyName = 'CompanyName' + +DECLARE @columnFullName nvarchar(20) +SET @columnFullName = 'FullName' + +DECLARE @curUsers cursor +DECLARE @curSpace cursor + +DECLARE @sqlSpace nvarchar(2000) +DECLARE @sqlUsers nvarchar(2000) +DECLARE @sqlReturn nvarchar(4000) + +IF @FilterColumn = '' AND @FilterValue <> '' +SET @FilterColumn = 'TextSearch' + +SET @sqlUsers = ' +DECLARE @HasUserRights bit +SET @HasUserRights = dbo.CheckActorUserRights(@ActorID, @UserID) +DECLARE @Users TABLE +( + ItemPosition int IDENTITY(0,1), + UserID int +) +INSERT INTO @Users (UserID) +SELECT ' + +IF @OnlyFind = 1 +SET @sqlUsers = @sqlUsers + 'TOP ' + CAST(@MaximumRows AS varchar(12)) + ' ' + +SET @sqlUsers = @sqlUsers + 'U.UserID +FROM UsersDetailed AS U +WHERE + U.UserID <> @UserID AND U.IsPeer = 0 AND + ( + (@Recursive = 0 AND OwnerID = @UserID) OR + (@Recursive = 1 AND dbo.CheckUserParent(@UserID, U.UserID) = 1) + ) + AND ((@StatusID = 0) OR (@StatusID > 0 AND U.StatusID = @StatusID)) + AND ((@RoleID = 0) OR (@RoleID > 0 AND U.RoleID = @RoleID)) + AND @HasUserRights = 1 +SET @curValue = cursor local for +SELECT + U.ItemID, + U.TextSearch, + U.ColumnType, + ''Users'' as FullType, + 0 as PackageID, + 0 as AccountID +FROM @Users AS TU +INNER JOIN +( +SELECT ItemID, TextSearch, ColumnType +FROM( +SELECT U0.UserID as ItemID, U0.Username as TextSearch, @columnUsername as ColumnType +FROM dbo.Users AS U0 +UNION +SELECT U1.UserID as ItemID, U1.Email as TextSearch, @columnEmail as ColumnType +FROM dbo.Users AS U1 +UNION +SELECT U2.UserID as ItemID, U2.CompanyName as TextSearch, @columnCompanyName as ColumnType +FROM dbo.Users AS U2 +UNION +SELECT U3.UserID as ItemID, U3.FirstName + '' '' + U3.LastName as TextSearch, @columnFullName as ColumnType +FROM dbo.Users AS U3) as U +WHERE TextSearch<>'' '' OR ISNULL(TextSearch, 0) > 0 +) + AS U ON TU.UserID = U.ItemID' + +SET @sqlUsers = @sqlUsers + ' open @curValue' + +exec sp_executesql @sqlUsers, N'@UserID int, @FilterValue nvarchar(50), @ActorID int, @Recursive bit, @StatusID int, @RoleID int, @columnUsername nvarchar(20), @columnEmail nvarchar(20), @columnCompanyName nvarchar(20), @columnFullName nvarchar(20), @curValue cursor output', +@UserID, @FilterValue, @ActorID, @Recursive, @StatusID, @RoleID, @columnUsername, @columnEmail, @columnCompanyName, @columnFullName, @curValue=@curUsers output + +SET @sqlSpace = ' + DECLARE @ItemsService TABLE + ( + ItemID int + ) + INSERT INTO @ItemsService (ItemID) + SELECT ' + +IF @OnlyFind = 1 +SET @sqlSpace = @sqlSpace + 'TOP ' + CAST(@MaximumRows AS varchar(12)) + ' ' + +SET @sqlSpace = @sqlSpace + 'SI.ItemID + FROM ServiceItems AS SI + INNER JOIN Packages AS P ON P.PackageID = SI.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + WHERE + dbo.CheckUserParent(@UserID, P.UserID) = 1 + DECLARE @ItemsDomain TABLE + ( + ItemID int + ) + INSERT INTO @ItemsDomain (ItemID) + SELECT + D.DomainID + FROM Domains AS D + INNER JOIN Packages AS P ON P.PackageID = D.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + WHERE + dbo.CheckUserParent(@UserID, P.UserID) = 1 + + SET @curValue = cursor local for + SELECT + + SI.ItemID as ItemID, + SI.ItemName as TextSearch, + STYPE.DisplayName as ColumnType, + STYPE.DisplayName as FullType, + SI.PackageID as PackageID, + 0 as AccountID + FROM @ItemsService AS I + INNER JOIN ServiceItems AS SI ON I.ItemID = SI.ItemID + INNER JOIN ServiceItemTypes AS STYPE ON SI.ItemTypeID = STYPE.ItemTypeID + WHERE STYPE.Searchable = 1 + UNION + SELECT + D.DomainID AS ItemID, + D.DomainName as TextSearch, + ''Domain'' as ColumnType, + ''Domain'' as FullType, + D.PackageID as PackageID, + 0 as AccountID + FROM @ItemsDomain AS I + INNER JOIN Domains AS D ON I.ItemID = D.DomainID + WHERE D.IsDomainPointer=0 + UNION + SELECT + EA.ItemID AS ItemID, + EA.AccountName as TextSearch, + ''ExchangeAccount'' as ColumnType, + ''ExchangeAccount'' as FullType, + SI2.PackageID as PackageID, + EA.AccountID as AccountID + FROM @ItemsService AS I2 + INNER JOIN ServiceItems AS SI2 ON I2.ItemID = SI2.ItemID + INNER JOIN ExchangeAccounts AS EA ON I2.ItemID = EA.ItemID +'; + +SET @sqlSpace = @sqlSpace + ' open @curValue' + +exec sp_executesql @sqlSpace, N'@UserID int, @FilterValue nvarchar(50), @ActorID int, @curValue cursor output', +@UserID, @FilterValue, @ActorID, @curValue=@curSpace output + +SET @sqlReturn = ' +DECLARE @ItemID int +DECLARE @TextSearch nvarchar(500) +DECLARE @ColumnType nvarchar(50) +DECLARE @FullType nvarchar(50) +DECLARE @PackageID int +DECLARE @AccountID int +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows +DECLARE @ItemsAll TABLE + ( + ItemPosition int IDENTITY(1,1), + ItemID int, + TextSearch nvarchar(500), + ColumnType nvarchar(50), + FullType nvarchar(50), + PackageID int, + AccountID int + ) + +FETCH NEXT FROM @curSpaceValue INTO @ItemID, @TextSearch, @ColumnType, @FullType, @PackageID, @AccountID +WHILE @@FETCH_STATUS = 0 +BEGIN +INSERT INTO @ItemsAll(ItemID, TextSearch, ColumnType, FullType, PackageID, AccountID) +VALUES(@ItemID, @TextSearch, @ColumnType, @FullType, @PackageID, @AccountID) +FETCH NEXT FROM @curSpaceValue INTO @ItemID, @TextSearch, @ColumnType, @FullType, @PackageID, @AccountID +END + +FETCH NEXT FROM @curUsersValue INTO @ItemID, @TextSearch, @ColumnType, @FullType, @PackageID, @AccountID +WHILE @@FETCH_STATUS = 0 +BEGIN +INSERT INTO @ItemsAll(ItemID, TextSearch, ColumnType, FullType, PackageID, AccountID) +VALUES(@ItemID, @TextSearch, @ColumnType, @FullType, @PackageID, @AccountID) +FETCH NEXT FROM @curUsersValue INTO @ItemID, @TextSearch, @ColumnType, @FullType, @PackageID, @AccountID +END + +DECLARE @ItemsReturn TABLE + ( + ItemPosition int IDENTITY(1,1), + ItemID int, + TextSearch nvarchar(500), + ColumnType nvarchar(50), + FullType nvarchar(50), + PackageID int, + AccountID int + ) +INSERT INTO @ItemsReturn(ItemID, TextSearch, ColumnType, FullType, PackageID, AccountID) +SELECT ItemID, TextSearch, ColumnType, FullType, PackageID, AccountID +FROM @ItemsAll AS IA WHERE (1 = 1) ' + + +IF @ColType <> '' +SET @sqlReturn = @sqlReturn + ' AND IA.ColumnType in ( ' + @ColType + ' ) '; + +IF @FullType <> '' +SET @sqlReturn = @sqlReturn + ' AND IA.FullType = ''' + @FullType + ''''; + +IF @FilterValue <> '' +SET @sqlReturn = @sqlReturn + ' AND IA.' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sqlReturn = @sqlReturn + ' ORDER BY ' + @SortColumn + ' ' +SET @sqlReturn = @sqlReturn + ' +SELECT COUNT(ItemID) FROM @ItemsReturn; +SELECT DISTINCT(ColumnType) FROM @ItemsReturn WHERE (1 = 1) '; +IF @FullType <> '' +SET @sqlReturn = @sqlReturn + ' AND FullType = ''' + @FullType + ''''; +SET @sqlReturn = @sqlReturn + '; '; +SET @sqlReturn = @sqlReturn + ' +SELECT ItemPosition, ItemID, TextSearch, ColumnType, FullType, PackageID, AccountID +FROM @ItemsReturn AS IR WHERE (1 = 1) +' + +IF @MaximumRows > 0 +SET @sqlReturn = @sqlReturn + ' AND IR.ItemPosition BETWEEN @StartRow AND @EndRow'; + +exec sp_executesql @sqlReturn, N'@StartRow int, @MaximumRows int, @FilterValue nvarchar(50), @curSpaceValue cursor, @curUsersValue cursor', +@StartRow, @MaximumRows, @FilterValue, @curSpace, @curUsers + +CLOSE @curSpace +DEALLOCATE @curSpace +CLOSE @curUsers +DEALLOCATE @curUsers +RETURN diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserInfo.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserInfo.cs index 259d0c53..1850c5bf 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserInfo.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserInfo.cs @@ -51,7 +51,7 @@ namespace WebsitePanel.EnterpriseServer private bool isDemo; private string comments; private string username; - private string password; +// private string password; private string firstName; private string lastName; private string email; @@ -78,6 +78,39 @@ namespace WebsitePanel.EnterpriseServer { } + public UserInfo(UserInfo src) + { + userId = src.userId; + ownerId = src.ownerId; + roleId = src.roleId; + statusId = src.statusId; + loginStatusId = src.loginStatusId; + failedLogins = src.failedLogins; + created = src.created; + changed = src.changed; + isPeer = src.isPeer; + isDemo = src.isDemo; + comments = src.comments; + username = src.username; + firstName = src.firstName; + lastName = src.lastName; + email = src.email; + secondaryEmail = src.secondaryEmail; + address = src.address; + city = src.city; + country = src.country; + state = src.state; + zip = src.zip; + primaryPhone = src.primaryPhone; + secondaryPhone = src.secondaryPhone; + fax = src.fax; + instantMessenger = src.instantMessenger; + htmlMail = src.htmlMail; + companyName = src.companyName; + ecommerceEnabled = src.ecommerceEnabled; + subscriberNumber = src.subscriberNumber; + } + /// /// User role ID: /// Administrator = 1, @@ -200,11 +233,11 @@ namespace WebsitePanel.EnterpriseServer set { this.username = value; } } - public string Password - { - get { return this.password; } - set { this.password = value; } - } +// public string Password +// { +// get { return this.password; } +// set { this.password = value; } +// } public string FirstName { @@ -347,7 +380,18 @@ namespace WebsitePanel.EnterpriseServer { public ushort VLanID { get; set; } public string Comment { get; set; } - } + }; + + public class UserInfoInternal : UserInfo + { + private string password; + + public string Password + { + get { return this.password; } + set { this.password = value; } + } + }; } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/UsersProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/UsersProxy.cs index d19bafce..0b3fc9dd 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/UsersProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/UsersProxy.cs @@ -840,20 +840,23 @@ namespace WebsitePanel.EnterpriseServer /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/AddUser", RequestNamespace = "http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace = "http://smbsaas/websitepanel/enterpriseserver", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public int AddUser(UserInfo user, bool sendLetter) + public int AddUser(UserInfo user, bool sendLetter, string password) { object[] results = this.Invoke("AddUser", new object[] { user, - sendLetter}); + sendLetter, + password + }); return ((int)(results[0])); } /// - public System.IAsyncResult BeginAddUser(UserInfo user, bool sendLetter, System.AsyncCallback callback, object asyncState) + public System.IAsyncResult BeginAddUser(UserInfo user, bool sendLetter, string password, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("AddUser", new object[] { user, - sendLetter}, callback, asyncState); + sendLetter, + password}, callback, asyncState); } /// @@ -864,13 +867,13 @@ namespace WebsitePanel.EnterpriseServer } /// - public void AddUserAsync(UserInfo user, bool sendLetter) + public void AddUserAsync(UserInfo user, bool sendLetter, string password) { - this.AddUserAsync(user, sendLetter, null); + this.AddUserAsync(user, sendLetter, password, null); } /// - public void AddUserAsync(UserInfo user, bool sendLetter, object userState) + public void AddUserAsync(UserInfo user, bool sendLetter, string password, object userState) { if ((this.AddUserOperationCompleted == null)) { @@ -878,7 +881,8 @@ namespace WebsitePanel.EnterpriseServer } this.InvokeAsync("AddUser", new object[] { user, - sendLetter}, this.AddUserOperationCompleted, userState); + sendLetter, + password}, this.AddUserOperationCompleted, userState); } private void OnAddUserOperationCompleted(object arg) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Common/ServiceUsernameTokenManager.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Common/ServiceUsernameTokenManager.cs index eb81f69f..1902f125 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Common/ServiceUsernameTokenManager.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Common/ServiceUsernameTokenManager.cs @@ -69,7 +69,7 @@ namespace WebsitePanel.EnterpriseServer protected override string AuthenticateToken(UsernameToken token) { // try to load user account - UserInfo user = UserController.GetUserInternally(token.Username); + UserInfoInternal user = UserController.GetUserInternally(token.Username); if (user == null) return null; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/ContractSystem/ContractController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/ContractSystem/ContractController.cs index aac2727c..0d870c89 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/ContractSystem/ContractController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/ContractSystem/ContractController.cs @@ -182,7 +182,7 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer.ContractSystem // if (customerId > -1) { - ES.UserInfo userInfo = (internally) ? ES.UserController.GetUserInternally(customerId) : + ES.UserInfoInternal userInfo = (internally) ? ES.UserController.GetUserInternally(customerId) : ES.UserController.GetUser(customerId); // if (internally) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/Provisioning/DomainNameController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/Provisioning/DomainNameController.cs index a4140b9e..c50b4aba 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/Provisioning/DomainNameController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/Provisioning/DomainNameController.cs @@ -520,12 +520,12 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer return settings; } - private CommandParams PrepeareAccountParams(UserInfo userInfo) + private CommandParams PrepeareAccountParams(UserInfo userInfo, string password) { CommandParams args = new CommandParams(); args[CommandParams.USERNAME] = userInfo.Username; - args[CommandParams.PASSWORD] = userInfo.Password; + args[CommandParams.PASSWORD] = password; args[CommandParams.FIRST_NAME] = userInfo.FirstName; args[CommandParams.LAST_NAME] = userInfo.LastName; args[CommandParams.EMAIL] = userInfo.Email; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/TriggerSystem/CommonTrigger.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/TriggerSystem/CommonTrigger.cs index e749e42c..b4906d20 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/TriggerSystem/CommonTrigger.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Ecommerce/TriggerSystem/CommonTrigger.cs @@ -113,7 +113,7 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer // create user account ES.UserInfo userInfo = new ES.UserInfo(); userInfo.Username = account[ContractAccount.USERNAME]; - userInfo.Password = account[ContractAccount.PASSWORD]; +// userInfo.Password = account[ContractAccount.PASSWORD]; userInfo.Email = account[ContractAccount.EMAIL]; userInfo.FirstName = account[ContractAccount.FIRST_NAME]; userInfo.LastName = account[ContractAccount.LAST_NAME]; @@ -133,7 +133,7 @@ namespace WebsitePanel.Ecommerce.EnterpriseServer userInfo.OwnerId = contract.ResellerId; userInfo.Created = DateTime.Now; // create account - int resultCode = ES.UserController.AddUser(userInfo, true); + int resultCode = ES.UserController.AddUser(userInfo, true, account[ContractAccount.PASSWORD]); // if (resultCode > 0) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs index fcb2b7e5..8c55041d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Packages/PackageController.cs @@ -431,7 +431,7 @@ namespace WebsitePanel.EnterpriseServer return result; // load user info - UserInfo user = UserController.GetUser(userId); + UserInfoInternal user = UserController.GetUser(userId); if (createFtpAccount) { @@ -2095,7 +2095,7 @@ namespace WebsitePanel.EnterpriseServer items["user"] = user; // get reseller details - UserInfo reseller = UserController.GetUser(user.OwnerId); + UserInfoInternal reseller = UserController.GetUser(user.OwnerId); if (reseller != null) { reseller.Password = ""; @@ -2132,7 +2132,7 @@ namespace WebsitePanel.EnterpriseServer items["user"] = user; // get reseller details - UserInfo reseller = UserController.GetUser(user.OwnerId); + UserInfoInternal reseller = UserController.GetUser(user.OwnerId); if (reseller != null) { reseller.Password = ""; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/StatisticsServers/StatisticsServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/StatisticsServers/StatisticsServerController.cs index b28248a6..7c05d896 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/StatisticsServers/StatisticsServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/StatisticsServers/StatisticsServerController.cs @@ -112,10 +112,12 @@ namespace WebsitePanel.EnterpriseServer UserInfo user = PackageController.GetPackageOwner(item.PackageId); if (user != null) { + UserInfoInternal userInternal = UserController.GetUserInternally(user.UserId); + site.StatisticsUrl = Utils.ReplaceStringVariable(site.StatisticsUrl, "username", - HttpUtility.UrlEncode(user.Username)); + HttpUtility.UrlEncode(userInternal.Username)); site.StatisticsUrl = Utils.ReplaceStringVariable(site.StatisticsUrl, "password", - HttpUtility.UrlEncode(user.Password)); + HttpUtility.UrlEncode(userInternal.Password)); } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Users/UserController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Users/UserController.cs index de9d56c3..fabe98bc 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Users/UserController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Users/UserController.cs @@ -58,7 +58,7 @@ namespace WebsitePanel.EnterpriseServer try { // try to get user from database - UserInfo user = GetUserInternally(username); + UserInfoInternal user = GetUserInternally(username); // check if the user exists if (user == null) @@ -99,7 +99,7 @@ namespace WebsitePanel.EnterpriseServer // compare user passwords - if (user.Password != password) + if (CryptoUtils.SHA1(user.Password) != password) { if (lockOut >= 0) DataProvider.UpdateUserFailedLoginAttempt(user.UserId, lockOut, false); @@ -145,7 +145,7 @@ namespace WebsitePanel.EnterpriseServer try { // try to get user from database - UserInfo user = GetUserInternally(username); + UserInfoInternal user = GetUserInternally(username); // check if the user exists if (user == null) @@ -155,8 +155,8 @@ namespace WebsitePanel.EnterpriseServer } // compare user passwords - if (user.Password == password) - return user; + if (CryptoUtils.SHA1(user.Password) == password) + return new UserInfo(user); return null; } @@ -239,7 +239,7 @@ namespace WebsitePanel.EnterpriseServer items["Email"] = true; // get reseller details - UserInfo reseller = UserController.GetUser(user.OwnerId); + UserInfoInternal reseller = UserController.GetUser(user.OwnerId); if (reseller != null) { reseller.Password = ""; @@ -264,10 +264,10 @@ namespace WebsitePanel.EnterpriseServer } } - internal static UserInfo GetUserInternally(int userId) + internal static UserInfoInternal GetUserInternally(int userId) { // try to get user from database - UserInfo user = ObjectUtils.FillObjectFromDataReader( + UserInfoInternal user = ObjectUtils.FillObjectFromDataReader( DataProvider.GetUserByIdInternally(userId)); if (user != null) @@ -275,10 +275,10 @@ namespace WebsitePanel.EnterpriseServer return user; } - internal static UserInfo GetUserInternally(string username) + internal static UserInfoInternal GetUserInternally(string username) { // try to get user from database - UserInfo user = ObjectUtils.FillObjectFromDataReader( + UserInfoInternal user = ObjectUtils.FillObjectFromDataReader( DataProvider.GetUserByUsernameInternally(username)); if (user != null) @@ -288,10 +288,10 @@ namespace WebsitePanel.EnterpriseServer return user; } - public static UserInfo GetUser(int userId) + public static UserInfoInternal GetUser(int userId) { // try to get user from database - UserInfo user = ObjectUtils.FillObjectFromDataReader( + UserInfoInternal user = ObjectUtils.FillObjectFromDataReader( DataProvider.GetUserById(SecurityContext.User.UserId, userId)); if (user != null) @@ -299,10 +299,10 @@ namespace WebsitePanel.EnterpriseServer return user; } - public static UserInfo GetUser(string username) + public static UserInfoInternal GetUser(string username) { // try to get user from database - UserInfo user = ObjectUtils.FillObjectFromDataReader( + UserInfoInternal user = ObjectUtils.FillObjectFromDataReader( DataProvider.GetUserByUsername(SecurityContext.User.UserId, username)); if (user != null) @@ -381,7 +381,7 @@ namespace WebsitePanel.EnterpriseServer return DataProvider.GetUsers(SecurityContext.User.UserId, ownerId, recursive); } - public static int AddUser(UserInfo user, bool sendLetter) + public static int AddUser(UserInfo user, bool sendLetter, string password) { // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo); @@ -424,7 +424,7 @@ namespace WebsitePanel.EnterpriseServer user.IsPeer, user.Comments, user.Username.Trim(), - CryptoUtils.Encrypt(user.Password), + CryptoUtils.Encrypt(password), user.FirstName, user.LastName, user.Email, diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Wizards/UserCreationWizard.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Wizards/UserCreationWizard.cs index e343fccd..d283dfbf 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Wizards/UserCreationWizard.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Wizards/UserCreationWizard.cs @@ -119,11 +119,11 @@ namespace WebsitePanel.EnterpriseServer user.Email = email; user.SecondaryEmail = secondaryEmail; user.Username = username; - user.Password = password; +// user.Password = password; user.HtmlMail = htmlMail; // add a new user - createdUserId = UserController.AddUser(user, false); + createdUserId = UserController.AddUser(user, false, password); if (createdUserId < 0) { // exit diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esUsers.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esUsers.asmx.cs index 64ccb43d..eea1c318 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esUsers.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esUsers.asmx.cs @@ -57,13 +57,15 @@ namespace WebsitePanel.EnterpriseServer [WebMethod] public UserInfo GetUserById(int userId) { - return UserController.GetUser(userId); + UserInfoInternal uinfo = UserController.GetUser(userId); + return (uinfo != null) ? new UserInfo(uinfo) : null; } [WebMethod] public UserInfo GetUserByUsername(string username) { - return UserController.GetUser(username); + UserInfoInternal uinfo = UserController.GetUser(username); + return (uinfo != null) ? new UserInfo(uinfo) : null; } [WebMethod] @@ -136,9 +138,9 @@ namespace WebsitePanel.EnterpriseServer } [WebMethod] - public int AddUser(UserInfo user, bool sendLetter) + public int AddUser(UserInfo user, bool sendLetter, string password) { - return UserController.AddUser(user, sendLetter); + return UserController.AddUser(user, sendLetter, password); } [WebMethod] @@ -175,7 +177,7 @@ namespace WebsitePanel.EnterpriseServer user.IsPeer = isPeer; user.IsDemo = isDemo; user.Username = username; - user.Password = password; +// user.Password = password; user.FirstName = firstName; user.LastName = lastName; user.Email = email; @@ -192,7 +194,7 @@ namespace WebsitePanel.EnterpriseServer user.HtmlMail = htmlMail; user.CompanyName = companyName; user.EcommerceEnabled = ecommerceEnabled; - return UserController.AddUser(user, sendLetter); + return UserController.AddUser(user, sendLetter, password); } [WebMethod] diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs index 02dead74..28e536b7 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs @@ -4479,7 +4479,7 @@ namespace WebsitePanel.Providers.HostedSolution { ExchangeLog.LogStart("CheckOrganizationPublicFolderMailbox"); - Collection result = GetPublicFolderMailbox(runSpace, orgCanonicalName, GetPublicFolderMailboxName(organizationId)); + Collection result = GetPublicFolderMailbox(runSpace, orgCanonicalName, GetPublicFolderMailboxName(organizationId), true); if (result == null || result.Count == 0) { ExchangeTransaction transaction = StartTransaction(); @@ -4501,7 +4501,7 @@ namespace WebsitePanel.Providers.HostedSolution { ExchangeLog.LogStart("CheckOrganizationRootFolder"); - Collection result = GetPublicFolderObject(runSpace, orgCanonicalName+"/"+GetPublicFolderMailboxName(organizationId), "\\" + folder); + Collection result = GetPublicFolderObject(runSpace, orgCanonicalName+"/"+GetPublicFolderMailboxName(organizationId), "\\" + folder, true); if (result == null || result.Count == 0) { ExchangeTransaction transaction = StartTransaction(); @@ -4617,22 +4617,22 @@ namespace WebsitePanel.Providers.HostedSolution ExchangeLog.LogEnd("DeletePublicFolderInternal"); } - private Collection GetPublicFolderObject(Runspace runSpace, string mailbox, string id) + private Collection GetPublicFolderObject(Runspace runSpace, string mailbox, string id, bool checkExist = false) { Command cmd = new Command("Get-PublicFolder"); cmd.Parameters.Add("Identity", id); //cmd.Parameters.Add("Mailbox", mailbox); - Collection result = ExecuteShellCommand(runSpace, cmd); + Collection result = ExecuteShellCommand(runSpace, cmd, true, !checkExist); return result; } - private Collection GetPublicFolderMailbox(Runspace runSpace, string organizationDistinguishedName, string name) + private Collection GetPublicFolderMailbox(Runspace runSpace, string organizationDistinguishedName, string name, bool checkExist) { Command cmd = new Command("Get-Mailbox"); cmd.Parameters.Add("Identity", name); cmd.Parameters.Add("PublicFolder"); cmd.Parameters.Add("OrganizationalUnit", organizationDistinguishedName); - Collection result = ExecuteShellCommand(runSpace, cmd); + Collection result = ExecuteShellCommand(runSpace, cmd, true, !checkExist); return result; } @@ -5369,7 +5369,7 @@ namespace WebsitePanel.Providers.HostedSolution string resultObjectDN = null; Command cmd = new Command("Get-AddressList"); cmd.Parameters.Add("Identity", id); - Collection result = this.ExecuteShellCommand(runSpace, cmd); + Collection result = this.ExecuteShellCommand(runSpace, cmd, true, false); if ((result != null) && (result.Count > 0)) { resultObjectDN = this.GetResultObjectDN(result); @@ -6242,13 +6242,19 @@ namespace WebsitePanel.Providers.HostedSolution internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd) { - return ExecuteShellCommand(runSpace, cmd, true); + return ExecuteShellCommand(runSpace, cmd, true, true); } internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController) { object[] errors; - return ExecuteShellCommand(runSpace, cmd, useDomainController, out errors); + return ExecuteShellCommand(runSpace, cmd, useDomainController, out errors, true); + } + + internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController, bool writeErrorExchangeLog) + { + object[] errors; + return ExecuteShellCommand(runSpace, cmd, useDomainController, out errors, writeErrorExchangeLog); } internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, ResultObject res) @@ -6272,10 +6278,10 @@ namespace WebsitePanel.Providers.HostedSolution internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, out object[] errors) { - return ExecuteShellCommand(runSpace, cmd, true, out errors); + return ExecuteShellCommand(runSpace, cmd, true, out errors, true); } - internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController, out object[] errors) + internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd, bool useDomainController, out object[] errors, bool writeErrorExchangeLog) { ExchangeLog.LogStart("ExecuteShellCommand"); List errorList = new List(); @@ -6309,8 +6315,12 @@ namespace WebsitePanel.Providers.HostedSolution foreach (object item in pipeLine.Error.ReadToEnd()) { errorList.Add(item); - string errorMessage = string.Format("Invoke error: {0}", item); - ExchangeLog.LogWarning(errorMessage); + + if (writeErrorExchangeLog) + { + string errorMessage = string.Format("Invoke error: {0}", item); + ExchangeLog.LogWarning(errorMessage); + } } } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Images/logo.png b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Images/logo.png index 8db3bf62..bf543851 100644 Binary files a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Images/logo.png and b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Images/logo.png differ diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css index 2173c20a..2ab67ad3 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css @@ -455,4 +455,76 @@ div#breadcrumb_wrapper a:last-child { .navbar-right { margin-right: 0; } +} + +.navbar-inverse { + background-color: #F4F4F4; + border-color: #d4d4d4; + background: rgb(251,251,251); + background: -moz-linear-gradient(top, rgba(251,251,251,1) 0%, rgba(242,242,242,1) 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(251,251,251,1)), color-stop(100%,rgba(242,242,242,1))); + background: -webkit-linear-gradient(top, rgba(251,251,251,1) 0%,rgba(242,242,242,1) 100%); + background: -o-linear-gradient(top, rgba(251,251,251,1) 0%,rgba(242,242,242,1) 100%); + background: -ms-linear-gradient(top, rgba(251,251,251,1) 0%,rgba(242,242,242,1) 100%); + background: linear-gradient(to bottom, rgba(251,251,251,1) 0%,rgba(242,242,242,1) 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fbfbfb', endColorstr='#f2f2f2',GradientType=0 ); + -webkit-box-shadow: 0 1px 10px rgba(0,0,0,.1); + -moz-box-shadow: 0 1px 10px rgba(0,0,0,.1); + box-shadow: 0 1px 10px rgba(0,0,0,.1); +} +.navbar-inverse .navbar-text, .navbar-inverse .navbar-brand, .navbar-text, #logout { + color: #565656; +} + +.navbar-inverse .navbar-brand:hover, .navbar-inverse .navbar-brand:focus, .navbar-text:hover, #logout:hover { + color: #565656; + background-color: transparent; + opacity: 1; +} + +div#breadcrumb_wrapper { + background-color: #F7F7F7; + border: 1px solid #d4d4d4; + margin-top: 9px; +} +.progress { + height:21px; + + background-color: #ffffff; + border: 1px solid #BBBBBB; + border-radius: 3px!important; +} +.progress-bar { + background-color: #F4C18F; + -webkit-box-shadow: none; + box-shadow: none; +} +body { + background-color: #FAFAFA; +} +p.progress-text { + position: absolute; + left: 44%; + color: #515151; +} +p.resource-subtext { + color: #AEAEAE; +} +#logout :hover { + color: #333; +} + +.file-link:hover { + text-decoration:none; +} +.file-link p { + color: #818181; + font-size: 13pt; +} +.file-link p:hover { + color: #333!important; +} +.icon-size { + width: 60px; + height: 60px; } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/CustomAttributes/OrganizationPasswordPolicyAttribute.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/CustomAttributes/OrganizationPasswordPolicyAttribute.cs index 6fea16be..9cffde91 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/CustomAttributes/OrganizationPasswordPolicyAttribute.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/CustomAttributes/OrganizationPasswordPolicyAttribute.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Text.RegularExpressions; using System.Web; using System.Web.Mvc; using WebsitePanel.Providers.HostedSolution; @@ -53,9 +54,9 @@ namespace WebsitePanel.WebDavPortal.CustomAttributes if (settings.PasswordComplexityEnabled) { - var symbolsCount = valueString.Count(Char.IsSymbol); var numbersCount = valueString.Count(Char.IsDigit); var upperLetterCount = valueString.Count(Char.IsUpper); + var symbolsCount = Regex.Matches(valueString, @"[~!@#$%^&*_\-+'\|\\(){}\[\]:;\""'<>,.?/]").Count; if (upperLetterCount < settings.UppercaseLettersCount) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/validation/passwordeditor.unobtrusive.js b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/validation/passwordeditor.unobtrusive.js index 799b8f82..03d49e3e 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/validation/passwordeditor.unobtrusive.js +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/validation/passwordeditor.unobtrusive.js @@ -45,7 +45,7 @@ $.validator.addMethod("numberscount", function (value, element, count) { $.validator.unobtrusive.adapters.addSingleVal("symbolscount", "count"); $.validator.addMethod("symbolscount", function (value, element, count) { - if (value.replace(/[a-zA-Z0-9_]/g, "").length < count) { + if (value.replace(/[^~!@#$%^&*_\-+'\|\\(){}\[\]:;\"'<>,.?/]/g, "").length < count) { return false; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Account/PasswordResetFinalStep.cshtml b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Account/PasswordResetFinalStep.cshtml index 6432a19b..2d5abbbf 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Account/PasswordResetFinalStep.cshtml +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Account/PasswordResetFinalStep.cshtml @@ -8,7 +8,8 @@ @using (Html.BeginRouteForm(AccountRouteNames.PasswordResetFinalStep, FormMethod.Post, new { @class = "form-horizontal user-password-reset-final-step bs-val-styles col-lg-9 col-lg-offset-3", id = "user-password-reset" })) { - + @Html.HiddenFor(x=>x.Login) + @UI.PasswordReset diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml index 9285872a..9f5dbcdc 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml @@ -64,7 +64,7 @@ @percent% - @ViewDataHelper.BytesToSize(resource.ContentLength) / @ViewDataHelper.BytesToSize(resource.AllocatedSpace) + @ViewDataHelper.BytesToSize(resource.ContentLength) / @ViewDataHelper.BytesToSize(resource.AllocatedSpace) } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs index b4793320..d3c706c0 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs @@ -43,6 +43,7 @@ using System.Web.Security; using System.Web.UI.WebControls; using System.Net; using System.Net.Mail; +using System.Security.Cryptography; using Microsoft.Web.Services3; using WebsitePanel.EnterpriseServer; @@ -336,15 +337,30 @@ namespace WebsitePanel.Portal return DefaultPage.GetLocalizedPageName(pageId); } + public static string SHA1(string plainText) + { + // Convert plain text into a byte array. + byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText); + + HashAlgorithm hash = new SHA1Managed(); ; + + // Compute hash value of our plain text with appended salt. + byte[] hashBytes = hash.ComputeHash(plainTextBytes); + + // Return the result. + return Convert.ToBase64String(hashBytes); + } public static int AuthenticateUser(string username, string password, string ipAddress, bool rememberLogin, string preferredLocale, string theme) { esAuthentication authService = new esAuthentication(); ConfigureEnterpriseServerProxy(authService, false); + string passwordSH = SHA1(password); + try { - int authResult = authService.AuthenticateUser(username, password, ipAddress); + int authResult = authService.AuthenticateUser(username, passwordSH, ipAddress); if (authResult < 0) { @@ -352,13 +368,13 @@ namespace WebsitePanel.Portal } else { - UserInfo user = authService.GetUserByUsernamePassword(username, password, ipAddress); + UserInfo user = authService.GetUserByUsernamePassword(username, passwordSH, ipAddress); if (user != null) { if (IsRoleAllowedToLogin(user.Role)) { // issue authentication ticket - FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, user.Password, user.Role, rememberLogin); + FormsAuthenticationTicket ticket = CreateAuthTicket(user.Username, password, user.Role, rememberLogin); SetAuthTicket(ticket, rememberLogin); CompleteUserLogin(username, rememberLogin, preferredLocale, theme); @@ -513,7 +529,7 @@ namespace WebsitePanel.Portal } } - public static int AddUserAccount(List log, UserInfo user, bool sendLetter) + public static int AddUserAccount(List log, UserInfo user, bool sendLetter, string password) { esUsers usersService = new esUsers(); ConfigureEnterpriseServerProxy(usersService, true); @@ -521,7 +537,7 @@ namespace WebsitePanel.Portal try { // add user to WebsitePanel server - return usersService.AddUser(user, sendLetter); + return usersService.AddUser(user, sendLetter, password); } catch (Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/UsersHelper.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/UsersHelper.cs index 9c97f47c..d6b12bb6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/UsersHelper.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/UsersHelper.cs @@ -210,10 +210,10 @@ namespace WebsitePanel.Portal return dsUsers; } - public static int AddUser(List log, int portalId, UserInfo user, bool sendLetter) + public static int AddUser(List log, int portalId, UserInfo user, bool sendLetter, string password) { // add user to WebsitePanel server - return ES.Services.Users.AddUser(user, sendLetter); + return ES.Services.Users.AddUser(user, sendLetter, password); } public static void AddUserVLan(int userId, UserVlan vLan) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/PeersEditPeer.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/PeersEditPeer.ascx.cs index 5f8a110c..e5359606 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/PeersEditPeer.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/PeersEditPeer.ascx.cs @@ -195,7 +195,7 @@ namespace WebsitePanel.Portal user.SecondaryEmail = txtSecondaryEmail.Text; user.HtmlMail = ddlMailFormat.SelectedIndex == 1; user.Username = txtUsername.Text; - user.Password = userPassword.Password; +// user.Password = userPassword.Password; user.IsDemo = chkDemo.Checked; user.LoginStatusId = loginStatus.SelectedIndex; @@ -220,7 +220,7 @@ namespace WebsitePanel.Portal try { //int userId = UsersHelper.AddUser(log, PortalId, user); - int userId = PortalUtils.AddUserAccount(log, user, false); + int userId = PortalUtils.AddUserAccount(log, user, false, userPassword.Password); if (userId < 0) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateUserAccount.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateUserAccount.ascx.cs index 4c67a45c..bf2fa0af 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateUserAccount.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/UserCreateUserAccount.ascx.cs @@ -103,7 +103,7 @@ namespace WebsitePanel.Portal user.SecondaryEmail = txtSecondaryEmail.Text; user.HtmlMail = ddlMailFormat.SelectedIndex == 1; user.Username = txtUsername.Text.Trim(); - user.Password = userPassword.Password; +// user.Password = userPassword.Password; // contact info user.CompanyName = contact.CompanyName; @@ -123,7 +123,7 @@ namespace WebsitePanel.Portal try { //int userId = UsersHelper.AddUser(log, PortalId, user); - int userId = PortalUtils.AddUserAccount(log, user, chkAccountLetter.Checked); + int userId = PortalUtils.AddUserAccount(log, user, chkAccountLetter.Checked, userPassword.Password); if (userId == BusinessErrorCodes.ERROR_INVALID_USER_NAME) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs index 3f36fcf9..26502684 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs @@ -206,23 +206,7 @@ namespace WebsitePanel.Portal { lblSharedIP.Text = string.Format("({0})", ipsGeneral[0].ExternalIP); } - else - { - string[] settings = ES.Services.Servers.GetServiceSettings(site.ServiceId); - foreach (string setting in settings) - { - int idx = setting.IndexOf('='); - string option = setting.Substring(0, idx); - if (String.Compare(option, "publicsharedip", true) == 0) - { - string res = setting.Substring(idx + 1); - if (!String.IsNullOrEmpty(res)) - lblSharedIP.Text = string.Format("({0})", res); - break; - } - } - } - lblSharedIP.Visible = !String.IsNullOrEmpty(lblSharedIP.Text); + lblSharedIP.Visible = generalIPExists; } dedicatedIP.Visible = site.IsDedicatedIP;
+Hello #user.FirstName#, +
+We received a request to reset the password for your account. Your password reset pincode: +
+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +
+Best regards +
@percent%
@ViewDataHelper.BytesToSize(resource.ContentLength) / @ViewDataHelper.BytesToSize(resource.AllocatedSpace)