diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index ac791ff8..b8da593d 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -5508,6 +5508,29 @@ CREATE TABLE [dbo].[RDSCollectionSettings]( GO +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'SecurityLayer' AND [object_id] = OBJECT_ID(N'RDSCollectionSettings')) +BEGIN + ALTER TABLE [dbo].[RDSCollectionSettings] ADD SecurityLayer NVARCHAR(20) null; +END +GO + +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'EncryptionLevel' AND [object_id] = OBJECT_ID(N'RDSCollectionSettings')) +BEGIN + ALTER TABLE [dbo].[RDSCollectionSettings] ADD EncryptionLevel NVARCHAR(20) null; +END +GO + +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'AuthenticateUsingNLA' AND [object_id] = OBJECT_ID(N'RDSCollectionSettings')) +BEGIN + ALTER TABLE [dbo].[RDSCollectionSettings] ADD AuthenticateUsingNLA BIT null; +END +GO + + + IF NOT EXISTS(SELECT * FROM SYS.TABLES WHERE name = 'RDSCertificates') CREATE TABLE [dbo].[RDSCertificates]( [ID] [int] IDENTITY(1,1) NOT NULL, diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs index c5fba734..1bcb1bff 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs @@ -122,6 +122,8 @@ namespace WebsitePanel.EnterpriseServer { private System.Threading.SendOrPostCallback GetRdsCertificateByServiceIdOperationCompleted; + private System.Threading.SendOrPostCallback GetRdsCertificateByItemIdOperationCompleted; + private System.Threading.SendOrPostCallback AddRdsCertificateOperationCompleted; /// @@ -267,6 +269,9 @@ namespace WebsitePanel.EnterpriseServer { /// public event GetRdsCertificateByServiceIdCompletedEventHandler GetRdsCertificateByServiceIdCompleted; + /// + public event GetRdsCertificateByItemIdCompletedEventHandler GetRdsCertificateByItemIdCompleted; + /// public event AddRdsCertificateCompletedEventHandler AddRdsCertificateCompleted; @@ -2335,6 +2340,47 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetRdsCertificateByItemId", 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 RdsCertificate GetRdsCertificateByItemId(int itemId) { + object[] results = this.Invoke("GetRdsCertificateByItemId", new object[] { + itemId}); + return ((RdsCertificate)(results[0])); + } + + /// + public System.IAsyncResult BeginGetRdsCertificateByItemId(int itemId, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("GetRdsCertificateByItemId", new object[] { + itemId}, callback, asyncState); + } + + /// + public RdsCertificate EndGetRdsCertificateByItemId(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((RdsCertificate)(results[0])); + } + + /// + public void GetRdsCertificateByItemIdAsync(int itemId) { + this.GetRdsCertificateByItemIdAsync(itemId, null); + } + + /// + public void GetRdsCertificateByItemIdAsync(int itemId, object userState) { + if ((this.GetRdsCertificateByItemIdOperationCompleted == null)) { + this.GetRdsCertificateByItemIdOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetRdsCertificateByItemIdOperationCompleted); + } + this.InvokeAsync("GetRdsCertificateByItemId", new object[] { + itemId}, this.GetRdsCertificateByItemIdOperationCompleted, userState); + } + + private void OnGetRdsCertificateByItemIdOperationCompleted(object arg) { + if ((this.GetRdsCertificateByItemIdCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetRdsCertificateByItemIdCompleted(this, new GetRdsCertificateByItemIdCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/AddRdsCertificate", 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 ResultObject AddRdsCertificate(RdsCertificate certificate) { @@ -3578,6 +3624,32 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void GetRdsCertificateByItemIdCompletedEventHandler(object sender, GetRdsCertificateByItemIdCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetRdsCertificateByItemIdCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetRdsCertificateByItemIdCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public RdsCertificate Result { + get { + this.RaiseExceptionIfNecessary(); + return ((RdsCertificate)(this.results[0])); + } + } + } + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] public delegate void AddRdsCertificateCompletedEventHandler(object sender, AddRdsCertificateCompletedEventArgs e); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs index 763e96aa..2b0e1ab3 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs @@ -288,6 +288,11 @@ namespace WebsitePanel.EnterpriseServer return GetRdsCertificateByServiceIdInternal(serviceId); } + public static RdsCertificate GetRdsCertificateByItemId(int itemId) + { + return GetRdsCertificateByItemIdInternal(itemId); + } + public static ResultObject AddRdsCertificate(RdsCertificate certificate) { return AddRdsCertificateInternal(certificate); @@ -346,6 +351,21 @@ namespace WebsitePanel.EnterpriseServer return result; } + private static RdsCertificate GetRdsCertificateByItemIdInternal(int itemId) + { + Organization org = OrganizationController.GetOrganization(itemId); + + if (org == null) + { + return null; + } + + int serviceId = GetRemoteDesktopServiceID(org.PackageId); + var result = ObjectUtils.FillObjectFromDataReader(DataProvider.GetRdsCertificateByServiceId(serviceId)); + + return result; + } + private static ResultObject AddRdsCertificateInternal(RdsCertificate certificate) { var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "ADD_RDS_SERVER"); @@ -431,7 +451,7 @@ namespace WebsitePanel.EnterpriseServer var organizationUsers = OrganizationController.GetOrganizationUsersPaged(collection.ItemId, null, null, null, 0, Int32.MaxValue).PageUsers; var organizationAdmins = rds.GetRdsCollectionLocalAdmins(org.OrganizationId, collection.Name); - return organizationUsers.Where(o => organizationAdmins.Select(a => a.ToLower()).Contains(o.DomainUserName.ToLower())).ToList(); + return organizationUsers.Where(o => organizationAdmins.Select(a => a.ToLower()).Contains(o.SamAccountName.ToLower())).ToList(); } private static ResultObject SaveRdsCollectionLocalAdminsInternal(OrganizationUser[] users, int collectionId) @@ -479,19 +499,22 @@ namespace WebsitePanel.EnterpriseServer var collection = ObjectUtils.FillObjectFromDataReader(DataProvider.GetRDSCollectionById(collectionId)); var settings = ObjectUtils.FillObjectFromDataReader(DataProvider.GetRdsCollectionSettingsByCollectionId(collectionId)); - if (settings.SecurityLayer == null) + if (settings != null) { - settings.SecurityLayer = SecurityLayerValues.Negotiate.ToString(); - } + if (settings.SecurityLayer == null) + { + settings.SecurityLayer = SecurityLayerValues.Negotiate.ToString(); + } - if (settings.EncryptionLevel == null) - { - settings.EncryptionLevel = EncryptionLevel.ClientCompatible.ToString(); - } + if (settings.EncryptionLevel == null) + { + settings.EncryptionLevel = EncryptionLevel.ClientCompatible.ToString(); + } - if (settings.AuthenticateUsingNLA == null) - { - settings.AuthenticateUsingNLA = true; + if (settings.AuthenticateUsingNLA == null) + { + settings.AuthenticateUsingNLA = true; + } } return settings; @@ -512,9 +535,23 @@ namespace WebsitePanel.EnterpriseServer private static int AddRdsCollectionInternal(int itemId, RdsCollection collection) { var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "ADD_RDS_COLLECTION"); + var domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName; try { + foreach(var server in collection.Servers) + { + if (!server.FqdName.EndsWith(domainName, StringComparison.CurrentCultureIgnoreCase)) + { + throw TaskManager.WriteError(new Exception("Fully Qualified Domain Name not valid.")); + } + + if (!CheckRDSServerAvaliable(server.FqdName)) + { + throw TaskManager.WriteError(new Exception(string.Format("Unable to connect to {0} server.", server.FqdName))); + } + } + // load organization Organization org = OrganizationController.GetOrganization(itemId); if (org == null) @@ -802,7 +839,7 @@ namespace WebsitePanel.EnterpriseServer FillRdsServerData(tmpServer); } - result.Servers = tmpServers.ToArray(); + result.Servers = tmpServers.ToArray(); return result; } @@ -996,25 +1033,22 @@ namespace WebsitePanel.EnterpriseServer { if (CheckRDSServerAvaliable(rdsServer.FqdName)) { - rdsServer.Id = DataProvider.AddRDSServer(rdsServer.Name, rdsServer.FqdName, rdsServer.Description); + var domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName; + + if (rdsServer.FqdName.EndsWith(domainName, StringComparison.CurrentCultureIgnoreCase)) + { + rdsServer.Id = DataProvider.AddRDSServer(rdsServer.Name, rdsServer.FqdName, rdsServer.Description); + } + else + { + throw TaskManager.WriteError(new Exception("Fully Qualified Domain Name not valid.")); + } } else { - result.AddError("REMOTE_DESKTOP_SERVICES_ADD_RDS_SERVER", new Exception("The server that you are adding, is not available")); - return result; + throw TaskManager.WriteError(new Exception(string.Format("Unable to connect to {0} server. Please double check Server Full Name setting and retry.", rdsServer.FqdName))); } - } - catch (Exception ex) - { - if (ex.InnerException != null) - { - result.AddError("Unable to add RDS Server", ex.InnerException); - } - else - { - result.AddError("Unable to add RDS Server", ex); - } - } + } finally { if (!result.IsSuccess) @@ -1733,7 +1767,7 @@ namespace WebsitePanel.EnterpriseServer { bool result = false; var ping = new Ping(); - var reply = ping.Send(hostname, 1000); + var reply = ping.Send(hostname, 1000); if (reply.Status == IPStatus.Success) { @@ -1741,8 +1775,7 @@ namespace WebsitePanel.EnterpriseServer } return result; - } - + } private static ResultObject DeleteRemoteDesktopServiceInternal(int itemId) { @@ -1791,7 +1824,7 @@ namespace WebsitePanel.EnterpriseServer private static RemoteDesktopServices GetRemoteDesktopServices(int serviceId) { var rds = new RemoteDesktopServices(); - ServiceProviderProxy.Init(rds, serviceId); + ServiceProviderProxy.Init(rds, serviceId); return rds; } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs index f377ff8d..cd1567ff 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs @@ -338,6 +338,12 @@ namespace WebsitePanel.EnterpriseServer return RemoteDesktopServicesController.GetRdsCertificateByServiceId(serviceId); } + [WebMethod] + public RdsCertificate GetRdsCertificateByItemId(int itemId) + { + return RemoteDesktopServicesController.GetRdsCertificateByItemId(itemId); + } + [WebMethod] public ResultObject AddRdsCertificate(RdsCertificate certificate) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/RdsServer.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/RdsServer.cs index aa181ba7..f1485912 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/RdsServer.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/RdsServer.cs @@ -48,5 +48,6 @@ namespace WebsitePanel.Providers.RemoteDesktopServices public int? RdsCollectionId { get; set; } public bool ConnectionEnabled { get; set; } public string Status { get; set; } + public bool SslAvailable { get; set; } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/RdsServersPaged.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/RdsServersPaged.cs index db523c2d..199ab34f 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/RdsServersPaged.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/RdsServersPaged.cs @@ -26,11 +26,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + namespace WebsitePanel.Providers.RemoteDesktopServices { public class RdsServersPaged { public int RecordsCount { get; set; } - public RdsServer[] Servers { get; set; } + public RdsServer[] Servers { get; set; } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs index b2eed0b3..f0a8caf3 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs @@ -342,7 +342,7 @@ namespace WebsitePanel.Providers.EnterpriseStorage } } - file.Summary = reader[6] as string; + file.Summary = SanitizeXmlString(reader[6] as string); result.Add(file); } @@ -354,6 +354,36 @@ namespace WebsitePanel.Providers.EnterpriseStorage } + public string SanitizeXmlString(string xml) + { + if (xml == null) + { + return null; + } + + var buffer = new StringBuilder(xml.Length); + + foreach (char c in xml.Where(c => IsLegalXmlChar(c))) + { + buffer.Append(c); + } + + return buffer.ToString(); + } + + public bool IsLegalXmlChar(int character) + { + return + ( + character == 0x9 /* == '\t' == 9 */ || + character == 0xA /* == '\n' == 10 */ || + character == 0xD /* == '\r' == 13 */ || + (character >= 0x20 && character <= 0xD7FF) || + (character >= 0xE000 && character <= 0xFFFD) || + (character >= 0x10000 && character <= 0x10FFFF) + ); + } + #region HostingServiceProvider methods public override string[] Install() diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index ca1b4c3b..41c6e520 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -68,12 +68,15 @@ namespace WebsitePanel.Providers.RemoteDesktopServices private const string RdsGroupFormat = "rds-{0}-{1}"; private const string RdsModuleName = "RemoteDesktopServices"; private const string AddNpsString = "netsh nps add np name=\"\"{0}\"\" policysource=\"1\" processingorder=\"{1}\" conditionid=\"0x3d\" conditiondata=\"^5$\" conditionid=\"0x1fb5\" conditiondata=\"{2}\" conditionid=\"0x1e\" conditiondata=\"UserAuthType:(PW|CA)\" profileid=\"0x1005\" profiledata=\"TRUE\" profileid=\"0x100f\" profiledata=\"TRUE\" profileid=\"0x1009\" profiledata=\"0x7\" profileid=\"0x1fe6\" profiledata=\"0x40000000\""; - private const string WspAdministratorsGroupName = "WSP-Org-Administrators"; - private const string WspAdministratorsGroupDescription = "WSP Org Administrators"; - private const string RdsServersOU = "RDSServers"; - private const string RDSHelpDeskComputerGroup = "Websitepanel-RDSHelpDesk-Computer"; + private const string WspAdministratorsGroupDescription = "WSP RDS Collection Adminstrators"; + private const string RdsCollectionUsersGroupDescription = "WSP RDS Collection Users"; + private const string RdsCollectionComputersGroupDescription = "WSP RDS Collection Computers"; + private const string RdsServersOU = "RDSServersOU"; + private const string RdsServersRootOU = "RDSRootServersOU"; + private const string RDSHelpDeskComputerGroup = "Websitepanel-RDSHelpDesk-Computer"; private const string RDSHelpDeskGroup = "WSP-HelpDeskAdministrators"; - private const string RDSHelpDeskGroupDescription = "WSP Help Desk Administrators"; + private const string RDSHelpDeskGroupDescription = "WSP Help Desk Administrators"; + private const string LocalAdministratorsGroupName = "Administrators"; #endregion @@ -95,6 +98,14 @@ namespace WebsitePanel.Providers.RemoteDesktopServices } } + private string ComputersRootOU + { + get + { + return ProviderSettings["ComputersRootOU"]; + } + } + private string CentralNpsHost { get @@ -301,24 +312,13 @@ namespace WebsitePanel.Providers.RemoteDesktopServices EditRdsCollectionSettingsInternal(collection, runSpace); var orgPath = GetOrganizationPath(organizationId); - - if (!ActiveDirectoryUtils.AdObjectExists(GetComputerGroupPath(organizationId, collection.Name))) - { - //Create computer group - ActiveDirectoryUtils.CreateGroup(orgPath, GetComputersGroupName(collection.Name)); - - //todo Connection broker server must be added by default ??? - //ActiveDirectoryUtils.AddObjectToGroup(GetComputerPath(ConnectionBroker), GetComputerGroupPath(organizationId, collection.Name)); - } - + CheckOrCreateAdGroup(GetComputerGroupPath(organizationId, collection.Name), orgPath, GetComputersGroupName(collection.Name), RdsCollectionComputersGroupDescription); CheckOrCreateHelpDeskComputerGroup(); string helpDeskGroupSamAccountName = CheckOrCreateAdGroup(GetHelpDeskGroupPath(RDSHelpDeskGroup), GetRootOUPath(), RDSHelpDeskGroup, RDSHelpDeskGroupDescription); - - if (!ActiveDirectoryUtils.AdObjectExists(GetUsersGroupPath(organizationId, collection.Name))) - { - //Create user group - ActiveDirectoryUtils.CreateGroup(orgPath, GetUsersGroupName(collection.Name)); - } + string groupName = GetLocalAdminsGroupName(collection.Name); + string groupPath = GetGroupPath(organizationId, collection.Name, groupName); + string localAdminsGroupSamAccountName = CheckOrCreateAdGroup(groupPath, GetOrganizationPath(organizationId), groupName, WspAdministratorsGroupDescription); + CheckOrCreateAdGroup(GetUsersGroupPath(organizationId, collection.Name), orgPath, GetUsersGroupName(collection.Name), RdsCollectionUsersGroupDescription); var capPolicyName = GetPolicyName(organizationId, collection.Name, RdsPolicyTypes.RdCap); var rapPolicyName = GetPolicyName(organizationId, collection.Name, RdsPolicyTypes.RdRap); @@ -339,17 +339,14 @@ namespace WebsitePanel.Providers.RemoteDesktopServices } //add user group to collection - AddUserGroupsToCollection(runSpace, collection.Name, new List { GetUsersGroupName(collection.Name) }); + AddUserGroupsToCollection(runSpace, collection.Name, new List { GetUsersGroupName(collection.Name) }); //add session servers to group foreach (var rdsServer in collection.Servers) - { - if (!CheckLocalAdminsGroupExists(rdsServer.FqdName, runSpace)) - { - CreateLocalAdministratorsGroup(rdsServer.FqdName, runSpace); - } - + { + MoveRdsServerToTenantOU(rdsServer.Name, organizationId); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); + AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, localAdminsGroupSamAccountName); AddComputerToCollectionAdComputerGroup(organizationId, collection.Name, rdsServer); } } @@ -576,19 +573,14 @@ namespace WebsitePanel.Providers.RemoteDesktopServices CheckOrCreateHelpDeskComputerGroup(); string helpDeskGroupSamAccountName = CheckOrCreateAdGroup(GetHelpDeskGroupPath(RDSHelpDeskGroup), GetRootOUPath(), RDSHelpDeskGroup, RDSHelpDeskGroupDescription); + string groupName = GetLocalAdminsGroupName(collectionName); + string groupPath = GetGroupPath(organizationId, collectionName, groupName); + string localAdminsGroupSamAccountName = CheckOrCreateAdGroup(groupPath, GetOrganizationPath(organizationId), groupName, WspAdministratorsGroupDescription); - if (!CheckLocalAdminsGroupExists(server.FqdName, runSpace)) - { - CreateLocalAdministratorsGroup(server.FqdName, runSpace); - } - + AddAdGroupToLocalAdmins(runSpace, server.FqdName, LocalAdministratorsGroupName); AddAdGroupToLocalAdmins(runSpace, server.FqdName, helpDeskGroupSamAccountName); AddComputerToCollectionAdComputerGroup(organizationId, collectionName, server); - } - catch (Exception e) - { - - } + } finally { CloseRunspace(runSpace); @@ -1001,18 +993,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices } foreach (var hostName in hosts) - { - if (!CheckLocalAdminsGroupExists(hostName, runspace)) - { - var errors = CreateLocalAdministratorsGroup(hostName, runspace); - - if (errors.Any()) - { - Log.WriteWarning(string.Join("\r\n", errors.Select(e => e.ToString()).ToArray())); - throw new Exception(string.Join("\r\n", errors.Select(e => e.ToString()).ToArray())); - } - } - + { AddAdGroupToLocalAdmins(runspace, hostName, helpDeskGroupSamAccountName); AddAdGroupToLocalAdmins(runspace, hostName, localAdminsGroupSamAccountName); @@ -1029,60 +1010,13 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { string groupName = GetLocalAdminsGroupName(collectionName); return GetUsersToCollectionAdGroup(collectionName, groupName, organizationId); - } - - private bool CheckLocalAdminsGroupExists(string hostName, Runspace runspace) - { - var scripts = new List - { - string.Format("net localgroup {0}", WspAdministratorsGroupName) - }; - - object[] errors = null; - var result = ExecuteRemoteShellCommand(runspace, hostName, scripts, out errors); - - if (!errors.Any()) - { - return true; - } - - return false; - } - - private object[] CreateLocalAdministratorsGroup(string hostName, Runspace runspace) - { - var scripts = new List - { - string.Format("$cn = [ADSI]\"WinNT://{0}\"", hostName), - string.Format("$group = $cn.Create(\"Group\", \"{0}\")", WspAdministratorsGroupName), - "$group.setinfo()", - string.Format("$group.description = \"{0}\"", WspAdministratorsGroupDescription), - "$group.setinfo()" - }; - - object[] errors = null; - ExecuteRemoteShellCommand(runspace, hostName, scripts, out errors); - - if (!errors.Any()) - { - scripts = new List - { - string.Format("$GroupObj = [ADSI]\"WinNT://{0}/Administrators\"", hostName), - string.Format("$GroupObj.Add(\"WinNT://{0}/{1}\")", hostName.ToLower().Replace(string.Format(".{0}", ServerSettings.ADRootDomain.ToLower()), ""), WspAdministratorsGroupName) - }; - - errors = null; - ExecuteRemoteShellCommand(runspace, hostName, scripts, out errors); - } - - return errors; - } + } private void RemoveGroupFromLocalAdmin(string fqdnName, string hostName, string groupName, Runspace runspace) { var scripts = new List { - string.Format("$GroupObj = [ADSI]\"WinNT://{0}/{1}\"", hostName, WspAdministratorsGroupName), + string.Format("$GroupObj = [ADSI]\"WinNT://{0}/{1}\"", hostName, LocalAdministratorsGroupName), string.Format("$GroupObj.Remove(\"WinNT://{0}/{1}\")", ServerSettings.ADRootDomain, RDSHelpDeskGroup), string.Format("$GroupObj.Remove(\"WinNT://{0}/{1}\")", ServerSettings.ADRootDomain, groupName) }; @@ -1149,7 +1083,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { var scripts = new List { - string.Format("$GroupObj = [ADSI]\"WinNT://{0}/{1}\"", hostName, WspAdministratorsGroupName), + string.Format("$GroupObj = [ADSI]\"WinNT://{0}/{1}\"", hostName, LocalAdministratorsGroupName), string.Format("$GroupObj.Add(\"WinNT://{0}/{1}\")", ServerSettings.ADRootDomain, samAccountName) }; @@ -1348,28 +1282,22 @@ namespace WebsitePanel.Providers.RemoteDesktopServices } private void AddComputerToCollectionAdComputerGroup(string organizationId, string collectionName, RdsServer server) - { - var computerPath = GetComputerPath(server.Name, false); - var computerGroupName = GetComputersGroupName( collectionName); + { + var computerGroupName = GetComputersGroupName( collectionName); + var computerObject = GetComputerObject(server.Name); - if (!ActiveDirectoryUtils.AdObjectExists(computerPath)) - { - computerPath = GetComputerPath(server.Name, true); - } - - if (ActiveDirectoryUtils.AdObjectExists(computerPath)) - { - var computerObject = ActiveDirectoryUtils.GetADObject(computerPath); + if (computerObject != null) + { var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(computerObject, "sAMAccountName"); if (!ActiveDirectoryUtils.IsComputerInGroup(samName, computerGroupName)) { - ActiveDirectoryUtils.AddObjectToGroup(computerPath, GetComputerGroupPath(organizationId, collectionName)); + ActiveDirectoryUtils.AddObjectToGroup(computerObject.Path, GetComputerGroupPath(organizationId, collectionName)); } if (!ActiveDirectoryUtils.IsComputerInGroup(samName, RDSHelpDeskComputerGroup)) { - ActiveDirectoryUtils.AddObjectToGroup(computerPath, GetHelpDeskGroupPath(RDSHelpDeskComputerGroup)); + ActiveDirectoryUtils.AddObjectToGroup(computerObject.Path, GetHelpDeskGroupPath(RDSHelpDeskComputerGroup)); } } @@ -1377,30 +1305,24 @@ namespace WebsitePanel.Providers.RemoteDesktopServices } private void RemoveComputerFromCollectionAdComputerGroup(string organizationId, string collectionName, RdsServer server) - { - var computerPath = GetComputerPath(server.Name, false); + { var computerGroupName = GetComputersGroupName(collectionName); + var computerObject = GetComputerObject(server.Name); - if (!ActiveDirectoryUtils.AdObjectExists(computerPath)) - { - computerPath = GetComputerPath(server.Name, true); - } - - if (ActiveDirectoryUtils.AdObjectExists(computerPath)) - { - var computerObject = ActiveDirectoryUtils.GetADObject(computerPath); + if (computerObject != null) + { var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(computerObject, "sAMAccountName"); if (ActiveDirectoryUtils.IsComputerInGroup(samName, computerGroupName)) { - ActiveDirectoryUtils.RemoveObjectFromGroup(computerPath, GetComputerGroupPath(organizationId, collectionName)); + ActiveDirectoryUtils.RemoveObjectFromGroup(computerObject.Path, GetComputerGroupPath(organizationId, collectionName)); } if (ActiveDirectoryUtils.AdObjectExists(GetHelpDeskGroupPath(RDSHelpDeskComputerGroup))) { if (ActiveDirectoryUtils.IsComputerInGroup(samName, RDSHelpDeskComputerGroup)) { - ActiveDirectoryUtils.RemoveObjectFromGroup(computerPath, GetHelpDeskGroupPath(RDSHelpDeskComputerGroup)); + ActiveDirectoryUtils.RemoveObjectFromGroup(computerObject.Path, GetHelpDeskGroupPath(RDSHelpDeskComputerGroup)); } } } @@ -1415,7 +1337,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { runSpace = OpenRunspace(); var feature = AddFeature(runSpace, hostName, "RDS-RD-Server", true, true); - installationResult = (bool)GetPSObjectProperty(feature, "Success"); + installationResult = (bool)GetPSObjectProperty(feature, "Success"); + + if (!IsFeatureInstalled(hostName, "Desktop-Experience", runSpace)) + { + feature = AddFeature(runSpace, hostName, "Desktop-Experience", true, false); + } + + if (!IsFeatureInstalled(hostName, "NET-Framework-Core", runSpace)) + { + feature = AddFeature(runSpace, hostName, "NET-Framework-Core", true, false); + } } finally { @@ -1425,59 +1357,72 @@ namespace WebsitePanel.Providers.RemoteDesktopServices return installationResult; } + private void CheckOrCreateComputersRoot(string computersRootPath) + { + if (ActiveDirectoryUtils.AdObjectExists(computersRootPath) && !ActiveDirectoryUtils.AdObjectExists(GetRdsServersGroupPath())) + { + //ActiveDirectoryUtils.CreateGroup(computersRootPath, RdsServersRootOU); + ActiveDirectoryUtils.CreateOrganizationalUnit(RdsServersRootOU, computersRootPath); + } + } + public void MoveRdsServerToTenantOU(string hostName, string organizationId) { var tenantComputerGroupPath = GetTenantComputerGroupPath(organizationId); if (!ActiveDirectoryUtils.AdObjectExists(tenantComputerGroupPath)) { - ActiveDirectoryUtils.CreateGroup(GetOrganizationPath(organizationId), RdsServersOU); + ActiveDirectoryUtils.CreateOrganizationalUnit(RdsServersOU, GetOrganizationPath(organizationId)); } - hostName = hostName.ToLower().Replace(string.Format(".{0}", ServerSettings.ADRootDomain.ToLower()), ""); - var computerPath = GetComputerPath(hostName, true); + hostName = hostName.ToLower().Replace(string.Format(".{0}", ServerSettings.ADRootDomain.ToLower()), ""); + var rootComputerPath = GetRdsServerPath(hostName); + var tenantComputerPath = GetTenantComputerPath(hostName, organizationId); - if(!ActiveDirectoryUtils.AdObjectExists(computerPath)) - { - computerPath = GetComputerPath(hostName, false); - } + if (!string.IsNullOrEmpty(ComputersRootOU)) + { + CheckOrCreateComputersRoot(GetComputersRootPath()); + } + + var computerObject = GetComputerObject(hostName); - if (ActiveDirectoryUtils.AdObjectExists(computerPath)) + if (computerObject != null) { - var computerObject = ActiveDirectoryUtils.GetADObject(computerPath); var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(computerObject, "sAMAccountName"); if (!ActiveDirectoryUtils.IsComputerInGroup(samName, RdsServersOU)) - { + { DirectoryEntry group = new DirectoryEntry(tenantComputerGroupPath); - group.Invoke("Add", computerObject.Path); - - group.CommitChanges(); + computerObject.MoveTo(group); } - } + } } public void RemoveRdsServerFromTenantOU(string hostName, string organizationId) { var tenantComputerGroupPath = GetTenantComputerGroupPath(organizationId); - hostName = hostName.ToLower().Replace(string.Format(".{0}", ServerSettings.ADRootDomain.ToLower()), ""); - var tenantComputerPath = GetTenantComputerPath(hostName, organizationId); + hostName = hostName.ToLower().Replace(string.Format(".{0}", ServerSettings.ADRootDomain.ToLower()), ""); - var computerPath = GetComputerPath(hostName, true); - - if (!ActiveDirectoryUtils.AdObjectExists(computerPath)) + if (!string.IsNullOrEmpty(ComputersRootOU)) { - computerPath = GetComputerPath(hostName, false); + CheckOrCreateComputersRoot(GetComputersRootPath()); + } + + if (!ActiveDirectoryUtils.AdObjectExists(tenantComputerGroupPath)) + { + ActiveDirectoryUtils.CreateOrganizationalUnit(RdsServersOU, GetOrganizationPath(organizationId)); } - - if (ActiveDirectoryUtils.AdObjectExists(computerPath)) + + var computerObject = GetComputerObject(hostName); + + if (computerObject != null) { - var computerObject = ActiveDirectoryUtils.GetADObject(computerPath); var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(computerObject, "sAMAccountName"); - - if (ActiveDirectoryUtils.IsComputerInGroup(samName, RdsServersOU)) + + if (ActiveDirectoryUtils.AdObjectExists(GetComputersRootPath()) && !string.IsNullOrEmpty(ComputersRootOU) && !ActiveDirectoryUtils.IsComputerInGroup(samName, RdsServersRootOU)) { - ActiveDirectoryUtils.RemoveObjectFromGroup(computerPath, tenantComputerGroupPath); + DirectoryEntry group = new DirectoryEntry(GetRdsServersGroupPath()); + computerObject.MoveTo(group); } } } @@ -1605,6 +1550,10 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { remoteApp.Users = users; } + else + { + remoteApp.Users = null; + } return remoteApp; } @@ -1760,26 +1709,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices return sb.ToString(); } - private string GetComputerPath(string objName, bool domainController) + private DirectoryEntry GetComputerObject(string computerName) { - StringBuilder sb = new StringBuilder(); - // append provider - AppendProtocol(sb); - AppendDomainController(sb); - AppendCNPath(sb, objName); - if (domainController) + DirectorySearcher deSearch = new DirectorySearcher { - AppendOUPath(sb, AdDcComputers); - } - else - { - AppendCNPath(sb, Computers); - - } - AppendDomainPath(sb, RootDomain); - - return sb.ToString(); - } + Filter = string.Format("(&(objectCategory=computer)(name={0}))", computerName) + }; + + SearchResult results = deSearch.FindOne(); + + return results.GetDirectoryEntry(); + } private string GetTenantComputerPath(string objName, string organizationId) { @@ -1788,7 +1728,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices AppendProtocol(sb); AppendDomainController(sb); AppendCNPath(sb, objName); - AppendCNPath(sb, RdsServersOU); + AppendOUPath(sb, RdsServersOU); AppendOUPath(sb, organizationId); AppendOUPath(sb, RootOU); AppendDomainPath(sb, RootDomain); @@ -1796,13 +1736,63 @@ namespace WebsitePanel.Providers.RemoteDesktopServices return sb.ToString(); } + private string GetComputersRootPath() + { + StringBuilder sb = new StringBuilder(); + + AppendProtocol(sb); + AppendDomainController(sb); + AppendOUPath(sb, ComputersRootOU); + AppendDomainPath(sb, RootDomain); + + return sb.ToString(); + } + + private string GetRdsServersGroupPath() + { + StringBuilder sb = new StringBuilder(); + + AppendProtocol(sb); + AppendDomainController(sb); + AppendOUPath(sb, RdsServersRootOU); + AppendOUPath(sb, ComputersRootOU); + AppendDomainPath(sb, RootDomain); + + return sb.ToString(); + } + + private string GetRdsServerPath(string name) + { + StringBuilder sb = new StringBuilder(); + + AppendProtocol(sb); + AppendDomainController(sb); + AppendCNPath(sb, name); + AppendOUPath(sb, RdsServersRootOU); + AppendOUPath(sb, ComputersRootOU); + AppendDomainPath(sb, RootDomain); + + return sb.ToString(); + } + + private string GetRootPath() + { + StringBuilder sb = new StringBuilder(); + + AppendProtocol(sb); + AppendDomainController(sb); + AppendDomainPath(sb, RootDomain); + + return sb.ToString(); + } + internal string GetTenantComputerGroupPath(string organizationId) { StringBuilder sb = new StringBuilder(); AppendProtocol(sb); AppendDomainController(sb); - AppendCNPath(sb, RdsServersOU); + AppendOUPath(sb, RdsServersOU); AppendOUPath(sb, organizationId); AppendOUPath(sb, RootOU); AppendDomainPath(sb, RootDomain); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIs80/SSL/SSLModuleService80.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIs80/SSL/SSLModuleService80.cs index 58b731a6..01b8ab73 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIs80/SSL/SSLModuleService80.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIs80/SSL/SSLModuleService80.cs @@ -84,7 +84,7 @@ namespace WebsitePanel.Providers.Web.Iis X509CertificateCollection existCerts2 = storeMy.Certificates.Find(X509FindType.FindBySerialNumber, servercert.SerialNumber, false); var certData = existCerts2[0].Export(X509ContentType.Pfx); storeMy.Close(); - var x509Cert = new X509Certificate2(certData); + var x509Cert = new X509Certificate2(certData, string.Empty, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet); if (UseCCS) { @@ -176,10 +176,10 @@ namespace WebsitePanel.Providers.Web.Iis if (UseCCS) { // We need to use this constructor or we won't be able to export this certificate - x509Cert = new X509Certificate2(certificate, password, X509KeyStorageFlags.Exportable); + x509Cert = new X509Certificate2(certificate, password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet); var certData = x509Cert.Export(X509ContentType.Pfx); - var convertedCert = new X509Certificate2(certData, string.Empty, X509KeyStorageFlags.Exportable); + var convertedCert = new X509Certificate2(certData, string.Empty, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet); // Attempts to move certificate to CCS UNC path try @@ -205,7 +205,7 @@ namespace WebsitePanel.Providers.Web.Iis } else { - x509Cert = new X509Certificate2(certificate, password); + x509Cert = new X509Certificate2(certificate, password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet); // Step 1: Register X.509 certificate in the store // Trying to keep X.509 store open as less as possible @@ -278,7 +278,7 @@ namespace WebsitePanel.Providers.Web.Iis // Read certificate data from file var certData = new byte[fileStream.Length]; fileStream.Read(certData, 0, (int) fileStream.Length); - var convertedCert = new X509Certificate2(certData, CCSCommonPassword, X509KeyStorageFlags.Exportable); + var convertedCert = new X509Certificate2(certData, CCSCommonPassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet); fileStream.Close(); @@ -311,7 +311,7 @@ namespace WebsitePanel.Providers.Web.Iis { hostNames.AddRange(certificate.Extensions.Cast() .Where(e => e.Oid.Value == "2.5.29.17") // Subject Alternative Names - .SelectMany(e => e.Format(true).Split(new[] {"\r\n", "\n", "\n"}, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Split('=')[1]))); + .SelectMany(e => e.Format(true).Split(new[] {"\r\n", "\n", "\n"}, StringSplitOptions.RemoveEmptyEntries).Where(s => s.Contains("=")).Select(s => s.Split('=')[1])).Where(s => !s.Contains(" "))); } var simpleName = certificate.GetNameInfo(X509NameType.SimpleName, false); @@ -320,7 +320,20 @@ namespace WebsitePanel.Providers.Web.Iis hostNames.Add(simpleName); } - // For every hostname (only one if using old school dedicated IP binding) + var wildcardHostName = hostNames.SingleOrDefault(h => h.StartsWith("*.")); + + // If a wildcard certificate is used + if (wildcardHostName != null) + { + if (!dedicatedIp) + { + // If using a wildcard ssl and not a dedicated IP, we take all the matching bindings on the site and use it to bind to SSL also. + hostNames.Remove(wildcardHostName); + hostNames.AddRange(website.Bindings.Where(b => !string.IsNullOrEmpty(b.Host) && b.Host.EndsWith(wildcardHostName.Substring(2))).Select(b => b.Host)); + } + } + + // For every hostname foreach (var hostName in hostNames) { var bindingInformation = string.Format("{0}:443:{1}", website.SiteIPAddress ?? "*", dedicatedIp ? "" : hostName); diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Extensions/UriExtensions.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Extensions/UriExtensions.cs index 8ba4aeeb..0311ecce 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Extensions/UriExtensions.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Extensions/UriExtensions.cs @@ -9,5 +9,13 @@ namespace WebsitePanel.WebDav.Core.Extensions { return new Uri(paths.Aggregate(uri.AbsoluteUri, (current, path) => string.Format("{0}/{1}", current.TrimEnd('/'), path.TrimStart('/')))); } + + public static string ToStringPath(this Uri uri) + { + var hostStart = uri.ToString().IndexOf(uri.Host, System.StringComparison.Ordinal); + var hostLength = uri.Host.Length; + + return uri.ToString().Substring(hostStart + hostLength, uri.ToString().Length - hostStart - hostLength); + } } } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs index 1a099ebf..8a46fff6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs @@ -260,7 +260,7 @@ namespace WebsitePanel.WebDav.Core { get { - string displayName = _href.AbsoluteUri.Trim('/').Replace(_baseUri.AbsoluteUri.Trim('/'), ""); + string displayName = _href.ToString().Trim('/').Replace(_baseUri.ToString().Trim('/'), ""); displayName = Regex.Replace(displayName, "\\/$", ""); Match displayNameMatch = Regex.Match(displayName, "([\\/]+)$"); if (displayNameMatch.Success) @@ -483,7 +483,7 @@ namespace WebsitePanel.WebDav.Core { _href = href; - var baseUrl = href.AbsoluteUri.Remove(href.AbsoluteUri.Length - href.Segments.Last().Length); + var baseUrl = href.ToString().Remove(href.ToString().Length - href.ToString().Trim('/').Split('/').Last().Length); _baseUri = new Uri(baseUrl); } diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs index 7b59436e..de3626fd 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs @@ -52,7 +52,7 @@ namespace WebsitePanel.WebDav.Core.Managers Href = new Uri(x.Url), ItemType = ItemType.Folder, ContentLength = x.Size * 1024 * 1024, - AllocatedSpace = x.FRSMQuotaMB * 1024 * 1024, + AllocatedSpace = (long)x.FRSMQuotaMB * 1024 * 1024, IsRootItem = true }).ToArray(); } diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs index 0940d23a..4f709e53 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs @@ -383,7 +383,8 @@ namespace WebsitePanel.WebDavPortal.Controllers foreach (var item in items) { var opener = _openerManager[Path.GetExtension(item.DisplayName)]; - var pathPart = item.Href.AbsolutePath.Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/'); + //var pathPart = item.Href.ToString().Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/'); + var pathPart = item.Href.ToStringPath().Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/'); switch (opener) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Helpers/ViewDataHelper.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Helpers/ViewDataHelper.cs new file mode 100644 index 00000000..6bcbccc6 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Helpers/ViewDataHelper.cs @@ -0,0 +1,31 @@ +using System; + +namespace WebsitePanel.WebDavPortal.Helpers +{ + public class ViewDataHelper + { + public static string BytesToSize(long bytes) + { + if (bytes == 0) + { + return string.Format("0 {0}", Resources.UI.Byte); + } + + var k = 1024; + + var sizes = new[] + { + Resources.UI.Bytes, + Resources.UI.KilobyteShort, + Resources.UI.MegabyteShort, + Resources.UI.GigabyteShort, + Resources.UI.TerabyteShort, + Resources.UI.PetabyteShort, + Resources.UI.ExabyteShort + }; + + var i = (int) Math.Floor(Math.Log(bytes)/Math.Log(k)); + return string.Format("{0} {1}", Math.Round(bytes/Math.Pow(k, i), 3), sizes[i]); + } + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Resources/UI.Designer.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Resources/UI.Designer.cs index f7a90c29..4a5a4578 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Resources/UI.Designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Resources/UI.Designer.cs @@ -69,6 +69,24 @@ namespace WebsitePanel.WebDavPortal.Resources { } } + /// + /// Looks up a localized string similar to Byte. + /// + public static string Byte { + get { + return ResourceManager.GetString("Byte", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bytes. + /// + public static string Bytes { + get { + return ResourceManager.GetString("Bytes", resourceCulture); + } + } + /// /// Looks up a localized string similar to Cancel. /// @@ -105,15 +123,6 @@ namespace WebsitePanel.WebDavPortal.Resources { } } - /// - /// Looks up a localized string similar to Create. - /// - public static string Create { - get { - return ResourceManager.GetString("Create", resourceCulture); - } - } - /// /// Looks up a localized string similar to Delete. /// @@ -150,15 +159,6 @@ namespace WebsitePanel.WebDavPortal.Resources { } } - /// - /// Looks up a localized string similar to Enter file name. - /// - public static string EnterFileName { - get { - return ResourceManager.GetString("EnterFileName", resourceCulture); - } - } - /// /// Looks up a localized string similar to Error. /// @@ -169,11 +169,11 @@ namespace WebsitePanel.WebDavPortal.Resources { } /// - /// Looks up a localized string similar to Excel workbook. + /// Looks up a localized string similar to EB. /// - public static string ExcelWorkbook { + public static string ExabyteShort { get { - return ResourceManager.GetString("ExcelWorkbook", resourceCulture); + return ResourceManager.GetString("ExabyteShort", resourceCulture); } } @@ -186,24 +186,6 @@ namespace WebsitePanel.WebDavPortal.Resources { } } - /// - /// Looks up a localized string similar to File name. - /// - public static string FileName { - get { - return ResourceManager.GetString("FileName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File extension will be added automatically. - /// - public static string FileNameExtensionHint { - get { - return ResourceManager.GetString("FileNameExtensionHint", resourceCulture); - } - } - /// /// Looks up a localized string similar to File Upload. /// @@ -231,15 +213,6 @@ namespace WebsitePanel.WebDavPortal.Resources { } } - /// - /// Looks up a localized string similar to File already exist. - /// - public static string ItemExist { - get { - return ResourceManager.GetString("ItemExist", resourceCulture); - } - } - /// /// Looks up a localized string similar to {0} items was removed.. /// @@ -249,6 +222,24 @@ namespace WebsitePanel.WebDavPortal.Resources { } } + /// + /// Looks up a localized string similar to KB. + /// + public static string KilobyteShort { + get { + return ResourceManager.GetString("KilobyteShort", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to MB. + /// + public static string MegabyteShort { + get { + return ResourceManager.GetString("MegabyteShort", resourceCulture); + } + } + /// /// Looks up a localized string similar to Modified. /// @@ -294,6 +285,15 @@ namespace WebsitePanel.WebDavPortal.Resources { } } + /// + /// Looks up a localized string similar to PB. + /// + public static string PetabyteShort { + get { + return ResourceManager.GetString("PetabyteShort", resourceCulture); + } + } + /// /// Looks up a localized string similar to Please wait.... /// @@ -303,15 +303,6 @@ namespace WebsitePanel.WebDavPortal.Resources { } } - /// - /// Looks up a localized string similar to Powerpoint presentation. - /// - public static string PowerPointPresentation { - get { - return ResourceManager.GetString("PowerPointPresentation", resourceCulture); - } - } - /// /// Looks up a localized string similar to Processing. /// @@ -384,6 +375,15 @@ namespace WebsitePanel.WebDavPortal.Resources { } } + /// + /// Looks up a localized string similar to TB. + /// + public static string TerabyteShort { + get { + return ResourceManager.GetString("TerabyteShort", resourceCulture); + } + } + /// /// Looks up a localized string similar to Type. /// @@ -402,15 +402,6 @@ namespace WebsitePanel.WebDavPortal.Resources { } } - /// - /// Looks up a localized string similar to Word document. - /// - public static string WordDocument { - get { - return ResourceManager.GetString("WordDocument", resourceCulture); - } - } - /// /// Looks up a localized string similar to Yes. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Resources/UI.resx b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Resources/UI.resx index 624df9ea..2ffe1406 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Resources/UI.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Resources/UI.resx @@ -120,6 +120,12 @@ Actions + + Byte + + + Bytes + Cancel @@ -132,9 +138,6 @@ Confirm - - Create - Delete @@ -147,24 +150,15 @@ Are you sure you want to delete {0} item(s)? - - Enter file name - Error - - Excel workbook + + EB File - - File name - - - File extension will be added automatically - File Upload @@ -174,12 +168,15 @@ Info - - File already exist - {0} items was removed. + + KB + + + MB + Modified @@ -195,12 +192,12 @@ or drag and drop files here. + + PB + Please wait... - - Powerpoint presentation - Processing @@ -225,15 +222,15 @@ Table + + TB + Type Upload - - Word document - Yes diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml index 274f677b..9285872a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml @@ -4,6 +4,7 @@ @using WebsitePanel.WebDav.Core.Config @using WebsitePanel.WebDavPortal.FileOperations @using Ninject; +@using WebsitePanel.WebDavPortal.Helpers @using WebsitePanel.WebDavPortal.Resources @using WebsitePanel.WebDavPortal.UI @using WebsitePanel.WebDavPortal.UI.Routes @@ -63,7 +64,7 @@

@percent%

-

@Math.Round(Convert.ToDecimal(resource.ContentLength) / 1024, 2) / @Math.Round(Convert.ToDecimal(resource.AllocatedSpace) / 1024, 2) @UI.GigabyteShort

+

@ViewDataHelper.BytesToSize(resource.ContentLength) / @ViewDataHelper.BytesToSize(resource.AllocatedSpace)

}
diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj index 8c5bfd40..5e8b2a86 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj @@ -183,6 +183,7 @@ Global.asax + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx index 27590807..5269c27d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -5656,6 +5656,9 @@ Session host certificate not installed + + RDS Server not added + Session host certificate has been installed diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/RDSHelper.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/RDSHelper.cs index 9b7c00d2..625145e4 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/RDSHelper.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/RDSHelper.cs @@ -57,6 +57,7 @@ namespace WebsitePanel.Portal if (rdsServer.ItemId.HasValue) { rdsServer.Status = ES.Services.RDS.GetRdsServerStatus(rdsServer.ItemId.Value, rdsServer.FqdName); + rdsServer.SslAvailable = ES.Services.RDS.GetRdsCertificateByItemId(rdsServer.ItemId.Value) != null; } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/RDS_Settings.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/RDS_Settings.ascx.resx index 1b443a76..dd9c465d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/RDS_Settings.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/RDS_Settings.ascx.resx @@ -129,4 +129,22 @@ Certificate Password: + + SSL Certificate + + + Select Certificate: + + + Expiry Date: + + + Issued By: + + + SAN Name: + + + Computers Root OU: + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx index 57dbeecb..415fd085 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx @@ -1,17 +1,63 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RDS_Settings.ascx.cs" Inherits="WebsitePanel.Portal.ProviderControls.RDS_Settings" %> - - - - - - - - - +<%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> + +
+ +   + +
- - - -
+ + + + + + + + + +
+ +
+ + + +
+ +
+ +   + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+
+
+
+ + + + + -
@@ -30,6 +76,15 @@
+ + + + +
@@ -84,4 +139,6 @@
\ No newline at end of file + +
+
\ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx.cs index d85a1c61..8806b61d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx.cs @@ -26,8 +26,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +using AjaxControlToolkit; using System; using System.Collections.Generic; +using System.Security.Cryptography.X509Certificates; using System.Web.UI.WebControls; using WebsitePanel.EnterpriseServer; using WebsitePanel.Providers.Common; @@ -39,7 +41,7 @@ namespace WebsitePanel.Portal.ProviderControls { protected void Page_Load(object sender, EventArgs e) { - + FillCertificateInfo(); } public string GWServers @@ -54,6 +56,25 @@ namespace WebsitePanel.Portal.ProviderControls } } + private void FillCertificateInfo() + { + var certificate = ES.Services.RDS.GetRdsCertificateByServiceId(PanelRequest.ServiceId); + + if (certificate != null) + { + var array = Convert.FromBase64String(certificate.Hash); + char[] chars = new char[array.Length / sizeof(char)]; + System.Buffer.BlockCopy(array, 0, chars, 0, array.Length); + string password = new string(chars); + plCertificateInfo.Visible = true; + byte[] content = Convert.FromBase64String(certificate.Content); + var x509 = new X509Certificate2(content, password); + lblIssuedBy.Text = x509.Issuer.Replace("CN=", "").Replace("OU=", "").Replace("O=", "").Replace("L=", "").Replace("S=", "").Replace("C=", ""); + lblExpiryDate.Text = x509.NotAfter.ToLongDateString(); + lblSanName.Text = x509.SubjectName.Name.Replace("CN=", ""); + } + } + public void BindSettings(System.Collections.Specialized.StringDictionary settings) { txtConnectionBroker.Text = settings["ConnectionBroker"]; @@ -62,6 +83,7 @@ namespace WebsitePanel.Portal.ProviderControls UpdateLyncServersGrid(); txtRootOU.Text = settings["RootOU"]; + txtComputersRootOu.Text = settings["ComputersRootOU"]; txtPrimaryDomainController.Text = settings["PrimaryDomainController"]; if (!string.IsNullOrEmpty(settings["UseCentralNPS"]) && bool.TrueString == settings["UseCentralNPS"]) @@ -82,6 +104,7 @@ namespace WebsitePanel.Portal.ProviderControls { settings["ConnectionBroker"] = txtConnectionBroker.Text; settings["RootOU"] = txtRootOU.Text; + settings["ComputersRootOU"] = txtComputersRootOu.Text; settings["PrimaryDomainController"] = txtPrimaryDomainController.Text; settings["UseCentralNPS"] = chkUseCentralNPS.Checked.ToString(); settings["CentralNPS"] = chkUseCentralNPS.Checked ? txtCentralNPS.Text : string.Empty; @@ -163,7 +186,7 @@ namespace WebsitePanel.Portal.ProviderControls GWServers = str.TrimEnd(';'); UpdateLyncServersGrid(); } - } + } } public class GWServer diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx.designer.cs index 9e1ba55e..81ceb1a6 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx.designer.cs @@ -12,6 +12,15 @@ namespace WebsitePanel.Portal.ProviderControls { public partial class RDS_Settings { + /// + /// secCertificateSettings control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label secCertificateSettings; + /// /// upPFX control. /// @@ -30,6 +39,51 @@ namespace WebsitePanel.Portal.ProviderControls { /// protected global::System.Web.UI.WebControls.TextBox txtPFXInstallPassword; + /// + /// currentCertificate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label currentCertificate; + + /// + /// plCertificateInfo control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel plCertificateInfo; + + /// + /// lblIssuedBy control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblIssuedBy; + + /// + /// lblSanName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblSanName; + + /// + /// lblExpiryDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblExpiryDate; + /// /// lblConnectionBroker control. /// @@ -84,6 +138,33 @@ namespace WebsitePanel.Portal.ProviderControls { /// protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4; + /// + /// lblComputersRootOU control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblComputersRootOU; + + /// + /// txtComputersRootOu control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtComputersRootOu; + + /// + /// RequiredFieldValidator1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1; + /// /// lblPrimaryDomainController control. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx.cs index 2d21ad7e..5f09adc8 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx.cs @@ -69,7 +69,7 @@ namespace WebsitePanel.Portal.RDS } catch (Exception ex) { - messageBox.ShowErrorMessage("RDSCOLLECTION_NOT_CREATED", ex); + ShowErrorMessage("RDSCOLLECTION_NOT_CREATED", ex); } } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs index 2a9be753..a5731696 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs @@ -52,6 +52,19 @@ namespace WebsitePanel.Portal.RDS txtApplicationName.Text = remoteApp.DisplayName; //var remoteAppUsers = organizationUsers.Where(x => applicationUsers.Contains(x.AccountName)); var remoteAppUsers = organizationUsers.Where(x => applicationUsers.Select(a => a.Split('\\').Last().ToLower()).Contains(x.SamAccountName.Split('\\').Last().ToLower())); + var localAdmins = ES.Services.RDS.GetRdsCollectionLocalAdmins(PanelRequest.CollectionID); + + foreach(var user in remoteAppUsers) + { + if (localAdmins.Select(l => l.AccountName).Contains(user.AccountName)) + { + user.IsVIP = true; + } + else + { + user.IsVIP = false; + } + } users.SetUsers(remoteAppUsers.ToArray()); } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionUsers.ascx.cs index 767eab4f..8af9191a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionUsers.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionUsers.ascx.cs @@ -27,6 +27,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; +using System.Linq; using System.Web.UI.WebControls; using WebsitePanel.EnterpriseServer; using WebsitePanel.Providers.Common; @@ -45,6 +46,19 @@ namespace WebsitePanel.Portal.RDS BindQuota(); var collectionUsers = ES.Services.RDS.GetRdsCollectionUsers(PanelRequest.CollectionID); var collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID); + var localAdmins = ES.Services.RDS.GetRdsCollectionLocalAdmins(PanelRequest.CollectionID); + + foreach (var user in collectionUsers) + { + if (localAdmins.Select(l => l.AccountName).Contains(user.AccountName)) + { + user.IsVIP = true; + } + else + { + user.IsVIP = false; + } + } litCollectionName.Text = collection.DisplayName; users.SetUsers(collectionUsers); @@ -63,6 +77,12 @@ namespace WebsitePanel.Portal.RDS { usersQuota.QuotaAvailable = tenantStats.AllocatedRdsUsers - tenantStats.CreatedRdsUsers; } + + if (cntx.Quotas.ContainsKey(Quotas.RDS_USERS)) + { + int rdsUsersCount = ES.Services.RDS.GetOrganizationRdsUsersCount(PanelRequest.ItemID); + users.ButtonAddEnabled = (!(cntx.Quotas[Quotas.RDS_USERS].QuotaAllocatedValue <= rdsUsersCount) || (cntx.Quotas[Quotas.RDS_USERS].QuotaAllocatedValue == -1)); + } } private bool SaveRdsUsers() diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSLocalAdmins.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSLocalAdmins.ascx.cs index 1ea540d9..7ce5ca79 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSLocalAdmins.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSLocalAdmins.ascx.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using WebsitePanel.Providers.HostedSolution; +using WebsitePanel.Providers.RemoteDesktopServices; namespace WebsitePanel.Portal.RDS { @@ -17,6 +19,12 @@ namespace WebsitePanel.Portal.RDS var collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID); litCollectionName.Text = collection.DisplayName; + + foreach(var user in collectionLocalAdmins) + { + user.IsVIP = false; + } + users.SetUsers(collectionLocalAdmins); } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx index bbc141f1..36c6fb36 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx @@ -28,6 +28,7 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs index 0474d715..47e39a3d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs @@ -136,7 +136,7 @@ namespace WebsitePanel.Portal.RDS.UserControls var fullRemote = new StartMenuApp { DisplayName = string.Format("Full Desktop - {0}", host.ToLower()), - FilePath = "%SystemRoot%\\system32\\mstsc.exe", + FilePath = "c:\\windows\\system32\\mstsc.exe", RequiredCommandLine = string.Format("/v:{0}", host.ToLower()) }; @@ -213,6 +213,13 @@ namespace WebsitePanel.Portal.RDS.UserControls app.DisplayName = ((LinkButton)row.FindControl("lnkDisplayName")).Text; app.FilePath = ((HiddenField)row.FindControl("hfFilePath")).Value; app.RequiredCommandLine = ((HiddenField)row.FindControl("hfRequiredCommandLine")).Value; + var users = ((HiddenField)row.FindControl("hfUsers")).Value; + + if (!string.IsNullOrEmpty(users)) + { + app.Users = new string[]{"New"}; + } + if (state == SelectedState.All || (state == SelectedState.Selected && chkSelect.Checked) || diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx index 4ba1e5c0..93432cd3 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx @@ -23,8 +23,9 @@ - + + @@ -81,6 +82,7 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx.cs index fdd2e6ce..76837a86 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx.cs @@ -42,6 +42,18 @@ namespace WebsitePanel.Portal.RDS.UserControls { public const string DirectionString = "DirectionString"; + public bool ButtonAddEnabled + { + get + { + return btnAdd.Enabled; + } + set + { + btnAdd.Enabled = value; + } + } + protected enum SelectedState { All, @@ -74,14 +86,7 @@ namespace WebsitePanel.Portal.RDS.UserControls }"; Page.ClientScript.RegisterClientScriptBlock(typeof(RDSCollectionUsers), "SelectAllCheckboxes", script, true); - } - - PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); - if (cntx.Quotas.ContainsKey(Quotas.RDS_USERS)) - { - int rdsUsersCount = ES.Services.RDS.GetOrganizationRdsUsersCount(PanelRequest.ItemID); - btnAdd.Enabled = (!(cntx.Quotas[Quotas.RDS_USERS].QuotaAllocatedValue <= rdsUsersCount) || (cntx.Quotas[Quotas.RDS_USERS].QuotaAllocatedValue == -1)); - } + } } protected void btnAdd_Click(object sender, EventArgs e) @@ -132,6 +137,19 @@ namespace WebsitePanel.Portal.RDS.UserControls protected void BindPopupAccounts() { OrganizationUser[] accounts = ES.Services.Organizations.GetOrganizationUsersPaged(PanelRequest.ItemID, null, null, null, 0, Int32.MaxValue).PageUsers; + var localAdmins = ES.Services.RDS.GetRdsCollectionLocalAdmins(PanelRequest.CollectionID); + + foreach (var user in accounts) + { + if (localAdmins.Select(l => l.AccountName).Contains(user.AccountName)) + { + user.IsVIP = true; + } + else + { + user.IsVIP = false; + } + } accounts = accounts.Where(x => !GetUsers().Select(p => p.AccountName).Contains(x.AccountName)).ToArray(); Array.Sort(accounts, CompareAccount); @@ -221,7 +239,8 @@ namespace WebsitePanel.Portal.RDS.UserControls { AccountName = (string)gvPopupAccounts.DataKeys[i][0], DisplayName = ((Literal)row.FindControl("litDisplayName")).Text, - SamAccountName = ((HiddenField)row.FindControl("hdnSamName")).Value + SamAccountName = ((HiddenField)row.FindControl("hdnSamName")).Value, + IsVIP = Convert.ToBoolean(((HiddenField)row.FindControl("hdnLocalAdmin")).Value) }); } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDSServers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDSServers.ascx index c38baf43..61130777 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDSServers.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDSServers.ascx @@ -15,10 +15,8 @@ - - -
+
100 - - + +
+ + + + + + + + - @@ -97,13 +104,7 @@ - - - - - - +