From f8de8a70d10c99db59b9fc36847b649644a4d9fe Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 4 Mar 2015 06:47:05 -0800 Subject: [PATCH 01/19] RDS Certificate fixes --- .../RemoteDesktopServicesProxy.cs | 72 ++++++++++++++ .../RemoteDesktopServicesController.cs | 22 ++++- .../esRemoteDesktopServices.asmx.cs | 6 ++ .../RemoteDesktopServices/RdsServer.cs | 1 + .../Windows2012.cs | 94 +++---------------- .../WebsitePanel/Code/Helpers/RDSHelper.cs | 1 + .../App_LocalResources/RDS_Settings.ascx.resx | 15 +++ .../ProviderControls/RDS_Settings.ascx | 76 ++++++++++++--- .../ProviderControls/RDS_Settings.ascx.cs | 25 ++++- .../RDS_Settings.ascx.designer.cs | 54 +++++++++++ .../WebsitePanel/RDSServers.ascx | 2 +- .../WebsitePanel.Portal.Modules.csproj | 4 +- 12 files changed, 270 insertions(+), 102 deletions(-) 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..afc2a442 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) 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.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index ca1b4c3b..d86af8ba 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -67,13 +67,13 @@ namespace WebsitePanel.Providers.RemoteDesktopServices private const string Admins = "Admins"; 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 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 WspAdministratorsGroupDescription = "WSP Org Administrators"; private const string RdsServersOU = "RDSServers"; 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 @@ -343,13 +343,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices //add session servers to group foreach (var rdsServer in collection.Servers) - { - if (!CheckLocalAdminsGroupExists(rdsServer.FqdName, runSpace)) - { - CreateLocalAdministratorsGroup(rdsServer.FqdName, runSpace); - } - - AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); + { + AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); AddComputerToCollectionAdComputerGroup(organizationId, collection.Name, rdsServer); } } @@ -575,20 +570,11 @@ namespace WebsitePanel.Providers.RemoteDesktopServices ExecuteShellCommand(runSpace, cmd, false); CheckOrCreateHelpDeskComputerGroup(); - string helpDeskGroupSamAccountName = CheckOrCreateAdGroup(GetHelpDeskGroupPath(RDSHelpDeskGroup), GetRootOUPath(), RDSHelpDeskGroup, RDSHelpDeskGroupDescription); - - if (!CheckLocalAdminsGroupExists(server.FqdName, runSpace)) - { - CreateLocalAdministratorsGroup(server.FqdName, runSpace); - } + string helpDeskGroupSamAccountName = CheckOrCreateAdGroup(GetHelpDeskGroupPath(RDSHelpDeskGroup), GetRootOUPath(), RDSHelpDeskGroup, RDSHelpDeskGroupDescription); AddAdGroupToLocalAdmins(runSpace, server.FqdName, helpDeskGroupSamAccountName); AddComputerToCollectionAdComputerGroup(organizationId, collectionName, server); - } - catch (Exception e) - { - - } + } finally { CloseRunspace(runSpace); @@ -1001,18 +987,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 +1004,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 +1077,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) }; 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..d8e514f9 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,19 @@ Certificate Password: + + SSL Certificate + + + Select Certificate: + + + Expiry Date: + + + Issued By: + + + SAN Name: + \ 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..d98a066e 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" %> + +
+ +   + +
- - - -
+ + + + + + + + + +
+ +
+ + + +
+ +
+ +   + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+
+
+
+ -
@@ -84,4 +130,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..020cc80d 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"]; @@ -163,7 +184,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..0a5bf54b 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. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDSServers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDSServers.ascx index c38baf43..1a6ef547 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDSServers.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDSServers.ascx @@ -84,7 +84,7 @@ - diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj index 28b18295..bcae2dea 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -5865,7 +5865,9 @@ - + + Designer + Designer From 165847909fa27a0cea96765465c84dce148e3556 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 4 Mar 2015 06:55:34 -0800 Subject: [PATCH 02/19] RDS Certificate fixes --- .../WebsitePanel/ProviderControls/RDS_Settings.ascx.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 020cc80d..19c684e7 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 @@ -69,9 +69,9 @@ namespace WebsitePanel.Portal.ProviderControls 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 =", ""); + 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 =", ""); + lblSanName.Text = x509.SubjectName.Name.Replace("CN=", ""); } } From f75f2073a39b27ba8ce0c74a77d800d21c617a1f Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Wed, 4 Mar 2015 10:42:47 -0500 Subject: [PATCH 03/19] Added tag build-2.1.0.604 for changeset 468033cf4db8 From 7bc697534bbf136a2c397bac3c244359a2f7c446 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Thu, 5 Mar 2015 07:07:48 -0800 Subject: [PATCH 04/19] RDS fixes --- .../RemoteDesktopServicesController.cs | 50 +++++++++++-------- .../RemoteDesktopServices/RdsServersPaged.cs | 3 +- .../Windows2012.cs | 12 ++++- .../WebsitePanel_SharedResources.ascx.resx | 3 ++ .../ProviderControls/RDS_Settings.ascx | 2 +- .../RDS/RDSCreateCollection.ascx.cs | 2 +- .../RDS/RDSEditApplicationUsers.ascx.cs | 9 ++++ .../RDS/RDSEditCollectionUsers.ascx.cs | 10 ++++ .../WebsitePanel/RDS/RDSLocalAdmins.ascx.cs | 2 + .../RDS/UserControls/RDSCollectionUsers.ascx | 4 +- .../UserControls/RDSCollectionUsers.ascx.cs | 12 ++++- .../WebsitePanel/RDSServers.ascx | 25 +++++----- .../WebsitePanel/RDSServers.ascx.designer.cs | 36 ++++++------- .../WebsitePanel/RDSServersAddserver.ascx | 8 +-- .../WebsitePanel/RDSServersAddserver.ascx.cs | 6 +-- .../RDSServersAddserver.ascx.designer.cs | 28 ----------- 16 files changed, 121 insertions(+), 91 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs index afc2a442..dad53cc7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs @@ -532,9 +532,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) @@ -822,7 +836,7 @@ namespace WebsitePanel.EnterpriseServer FillRdsServerData(tmpServer); } - result.Servers = tmpServers.ToArray(); + result.Servers = tmpServers.ToArray(); return result; } @@ -1016,25 +1030,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) @@ -1753,7 +1764,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) { @@ -1761,8 +1772,7 @@ namespace WebsitePanel.EnterpriseServer } return result; - } - + } private static ResultObject DeleteRemoteDesktopServiceInternal(int itemId) { @@ -1811,7 +1821,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.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.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index d86af8ba..930584d2 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -1343,7 +1343,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 { 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/ProviderControls/RDS_Settings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx index d98a066e..62f67170 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx @@ -10,7 +10,7 @@ - + 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..4b4d828b 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,15 @@ 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; + } + } 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..f18e7ad0 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,15 @@ 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; + } + } litCollectionName.Text = collection.DisplayName; users.SetUsers(collectionUsers); 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..d65093ef 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 { 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..f4fbbd8f 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 @@ -132,6 +132,15 @@ 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; + } + } accounts = accounts.Where(x => !GetUsers().Select(p => p.AccountName).Contains(x.AccountName)).ToArray(); Array.Sort(accounts, CompareAccount); @@ -221,7 +230,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 1a6ef547..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 - - + +
+ + + + + + + + - - - - - - +
-

@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 6ccbc782..a2c21f6c 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/WebsitePanel.WebDavPortal.csproj @@ -183,6 +183,7 @@ Global.asax + From 2ce49650d4ab2a348762cf3d8db52588ebaed4f3 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Mon, 9 Mar 2015 03:55:14 -0700 Subject: [PATCH 13/19] webdav portal fixes --- WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs index 2f706746..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) From d24cad7ac7f271d702f47e56bd088fa04163f9fb Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Mon, 9 Mar 2015 06:53:35 -0700 Subject: [PATCH 14/19] RDS Fixes --- .../Windows2012.cs | 116 +++++++++++++++++- .../App_LocalResources/RDS_Settings.ascx.resx | 3 + .../ProviderControls/RDS_Settings.ascx | 9 ++ .../ProviderControls/RDS_Settings.ascx.cs | 2 + .../RDS_Settings.ascx.designer.cs | 27 ++++ .../UserControls/RDSCollectionApps.ascx.cs | 2 +- 6 files changed, 154 insertions(+), 5 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index 930584d2..39cac14c 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -70,7 +70,8 @@ namespace WebsitePanel.Providers.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 WspAdministratorsGroupDescription = "WSP Org Administrators"; private const string RdsServersOU = "RDSServers"; - private const string RDSHelpDeskComputerGroup = "Websitepanel-RDSHelpDesk-Computer"; + private const string RdsServersRootOU = "RDSRootServers"; + private const string RDSHelpDeskComputerGroup = "Websitepanel-RDSHelpDesk-Computer"; private const string RDSHelpDeskGroup = "WSP-HelpDeskAdministrators"; private const string RDSHelpDeskGroupDescription = "WSP Help Desk Administrators"; private const string LocalAdministratorsGroupName = "Administrators"; @@ -95,6 +96,14 @@ namespace WebsitePanel.Providers.RemoteDesktopServices } } + private string ComputersRootOU + { + get + { + return ProviderSettings["ComputersRootOU"]; + } + } + private string CentralNpsHost { get @@ -313,6 +322,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices CheckOrCreateHelpDeskComputerGroup(); string helpDeskGroupSamAccountName = CheckOrCreateAdGroup(GetHelpDeskGroupPath(RDSHelpDeskGroup), GetRootOUPath(), RDSHelpDeskGroup, RDSHelpDeskGroupDescription); + string groupName = GetLocalAdminsGroupName(collection.Name); + string groupPath = GetGroupPath(organizationId, collection.Name, groupName); + string localAdminsGroupSamAccountName = CheckOrCreateAdGroup(groupPath, GetOrganizationPath(organizationId), groupName, WspAdministratorsGroupDescription); if (!ActiveDirectoryUtils.AdObjectExists(GetUsersGroupPath(organizationId, collection.Name))) { @@ -344,7 +356,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices //add session servers to group foreach (var rdsServer in collection.Servers) { - AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); + AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); + AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, localAdminsGroupSamAccountName); AddComputerToCollectionAdComputerGroup(organizationId, collection.Name, rdsServer); } } @@ -570,8 +583,12 @@ namespace WebsitePanel.Providers.RemoteDesktopServices ExecuteShellCommand(runSpace, cmd, false); CheckOrCreateHelpDeskComputerGroup(); - string helpDeskGroupSamAccountName = CheckOrCreateAdGroup(GetHelpDeskGroupPath(RDSHelpDeskGroup), GetRootOUPath(), RDSHelpDeskGroup, RDSHelpDeskGroupDescription); + 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); + AddAdGroupToLocalAdmins(runSpace, server.FqdName, LocalAdministratorsGroupName); AddAdGroupToLocalAdmins(runSpace, server.FqdName, helpDeskGroupSamAccountName); AddComputerToCollectionAdComputerGroup(organizationId, collectionName, server); } @@ -1363,6 +1380,14 @@ namespace WebsitePanel.Providers.RemoteDesktopServices return installationResult; } + private void CheckOrCreateComputersRoot(string computersRootPath) + { + if (ActiveDirectoryUtils.AdObjectExists(computersRootPath) && !ActiveDirectoryUtils.AdObjectExists(GetRdsServersGroupPath())) + { + ActiveDirectoryUtils.CreateGroup(computersRootPath, RdsServersRootOU); + } + } + public void MoveRdsServerToTenantOU(string hostName, string organizationId) { var tenantComputerGroupPath = GetTenantComputerGroupPath(organizationId); @@ -1373,7 +1398,14 @@ namespace WebsitePanel.Providers.RemoteDesktopServices } hostName = hostName.ToLower().Replace(string.Format(".{0}", ServerSettings.ADRootDomain.ToLower()), ""); - var computerPath = GetComputerPath(hostName, true); + var computerPath = GetComputerPath(hostName, true); + var rootComputerPath = GetRdsServerPath(hostName); + var tenantComputerPath = GetTenantComputerPath(hostName, organizationId); + + if (!string.IsNullOrEmpty(ComputersRootOU)) + { + CheckOrCreateComputersRoot(GetComputersRootPath()); + } if(!ActiveDirectoryUtils.AdObjectExists(computerPath)) { @@ -1385,6 +1417,14 @@ namespace WebsitePanel.Providers.RemoteDesktopServices var computerObject = ActiveDirectoryUtils.GetADObject(computerPath); var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(computerObject, "sAMAccountName"); + if (!string.IsNullOrEmpty(ComputersRootOU)) + { + if (ActiveDirectoryUtils.IsComputerInGroup(samName, RdsServersRootOU)) + { + ActiveDirectoryUtils.RemoveObjectFromGroup(computerPath, GetRdsServersGroupPath()); + } + } + if (!ActiveDirectoryUtils.IsComputerInGroup(samName, RdsServersOU)) { DirectoryEntry group = new DirectoryEntry(tenantComputerGroupPath); @@ -1400,6 +1440,12 @@ namespace WebsitePanel.Providers.RemoteDesktopServices var tenantComputerGroupPath = GetTenantComputerGroupPath(organizationId); hostName = hostName.ToLower().Replace(string.Format(".{0}", ServerSettings.ADRootDomain.ToLower()), ""); var tenantComputerPath = GetTenantComputerPath(hostName, organizationId); + var rootComputerPath = GetRdsServerPath(hostName); + + if (!string.IsNullOrEmpty(ComputersRootOU)) + { + CheckOrCreateComputersRoot(GetComputersRootPath()); + } var computerPath = GetComputerPath(hostName, true); @@ -1417,6 +1463,14 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { ActiveDirectoryUtils.RemoveObjectFromGroup(computerPath, tenantComputerGroupPath); } + + if (ActiveDirectoryUtils.AdObjectExists(GetComputersRootPath()) && !string.IsNullOrEmpty(ComputersRootOU) && !ActiveDirectoryUtils.IsComputerInGroup(samName, RdsServersRootOU)) + { + DirectoryEntry group = new DirectoryEntry(GetRdsServersGroupPath()); + group.Invoke("Add", computerObject.Path); + + group.CommitChanges(); + } } } @@ -1543,6 +1597,10 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { remoteApp.Users = users; } + else + { + remoteApp.Users = null; + } return remoteApp; } @@ -1734,6 +1792,56 @@ 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); + AppendCNPath(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); + AppendCNPath(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(); 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 d8e514f9..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 @@ -144,4 +144,7 @@ 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 62f67170..415fd085 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/RDS_Settings.ascx @@ -76,6 +76,15 @@ + + + + + + + + + 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 19c684e7..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 @@ -83,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"]) @@ -103,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; 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 0a5bf54b..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 @@ -138,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/UserControls/RDSCollectionApps.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx.cs index c293ea26..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 @@ -215,7 +215,7 @@ namespace WebsitePanel.Portal.RDS.UserControls app.RequiredCommandLine = ((HiddenField)row.FindControl("hfRequiredCommandLine")).Value; var users = ((HiddenField)row.FindControl("hfUsers")).Value; - if (users != null) + if (!string.IsNullOrEmpty(users)) { app.Users = new string[]{"New"}; } From 9c991c861183861f21a3fec333d46aaa4fedf3b2 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Mon, 9 Mar 2015 10:22:42 -0400 Subject: [PATCH 15/19] Added tag build-2.1.0.608 for changeset 4ba072d0a9b2 From 4efc1b045697c4f6e5386fafd5054160636a82be Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Mon, 9 Mar 2015 11:23:41 -0400 Subject: [PATCH 16/19] Added tag build-2.1.0.609 for changeset 4b919035dcca From a7672a30123e510b9f0a60572bcff1958a759d83 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Mon, 9 Mar 2015 12:05:24 -0400 Subject: [PATCH 17/19] Added tag build-2.1.0.610 for changeset 3056ccfd4d17 From fd8ca11f383d14f38bdfcb3911a8a1a059bce7d2 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Tue, 10 Mar 2015 06:31:40 -0700 Subject: [PATCH 18/19] Help desk groups descriptions added --- .../Windows2012.cs | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index 39cac14c..56a70d39 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -67,8 +67,10 @@ namespace WebsitePanel.Providers.RemoteDesktopServices private const string Admins = "Admins"; 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 WspAdministratorsGroupDescription = "WSP Org Administrators"; + 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 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 = "RDSServers"; private const string RdsServersRootOU = "RDSRootServers"; private const string RDSHelpDeskComputerGroup = "Websitepanel-RDSHelpDesk-Computer"; @@ -310,27 +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); string groupName = GetLocalAdminsGroupName(collection.Name); string groupPath = GetGroupPath(organizationId, collection.Name, groupName); string localAdminsGroupSamAccountName = CheckOrCreateAdGroup(groupPath, GetOrganizationPath(organizationId), groupName, WspAdministratorsGroupDescription); - - if (!ActiveDirectoryUtils.AdObjectExists(GetUsersGroupPath(organizationId, collection.Name))) - { - //Create user group - ActiveDirectoryUtils.CreateGroup(orgPath, GetUsersGroupName(collection.Name)); - } + 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); From 743563baa20b8db0ea4e8a214b2a248254f6cfd5 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 11 Mar 2015 01:09:08 -0700 Subject: [PATCH 19/19] RDS fixes --- .../Windows2012.cs | 148 ++++++------------ .../RDS/RDSEditCollectionUsers.ascx.cs | 6 + .../UserControls/RDSCollectionUsers.ascx.cs | 21 ++- 3 files changed, 71 insertions(+), 104 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index 56a70d39..41c6e520 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -71,8 +71,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices 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 = "RDSServers"; - private const string RdsServersRootOU = "RDSRootServers"; + 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"; @@ -339,11 +339,12 @@ 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) - { + { + MoveRdsServerToTenantOU(rdsServer.Name, organizationId); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, localAdminsGroupSamAccountName); AddComputerToCollectionAdComputerGroup(organizationId, collection.Name, rdsServer); @@ -1281,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)); } } @@ -1310,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)); } } } @@ -1372,7 +1361,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { if (ActiveDirectoryUtils.AdObjectExists(computersRootPath) && !ActiveDirectoryUtils.AdObjectExists(GetRdsServersGroupPath())) { - ActiveDirectoryUtils.CreateGroup(computersRootPath, RdsServersRootOU); + //ActiveDirectoryUtils.CreateGroup(computersRootPath, RdsServersRootOU); + ActiveDirectoryUtils.CreateOrganizationalUnit(RdsServersRootOU, computersRootPath); } } @@ -1382,82 +1372,57 @@ namespace WebsitePanel.Providers.RemoteDesktopServices 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 (!string.IsNullOrEmpty(ComputersRootOU)) { CheckOrCreateComputersRoot(GetComputersRootPath()); - } + } + + var computerObject = GetComputerObject(hostName); - if(!ActiveDirectoryUtils.AdObjectExists(computerPath)) + if (computerObject != null) { - computerPath = GetComputerPath(hostName, false); - } - - if (ActiveDirectoryUtils.AdObjectExists(computerPath)) - { - var computerObject = ActiveDirectoryUtils.GetADObject(computerPath); var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(computerObject, "sAMAccountName"); - if (!string.IsNullOrEmpty(ComputersRootOU)) - { - if (ActiveDirectoryUtils.IsComputerInGroup(samName, RdsServersRootOU)) - { - ActiveDirectoryUtils.RemoveObjectFromGroup(computerPath, GetRdsServersGroupPath()); - } - } - 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); - var rootComputerPath = GetRdsServerPath(hostName); + hostName = hostName.ToLower().Replace(string.Format(".{0}", ServerSettings.ADRootDomain.ToLower()), ""); if (!string.IsNullOrEmpty(ComputersRootOU)) { CheckOrCreateComputersRoot(GetComputersRootPath()); - } + } - var computerPath = GetComputerPath(hostName, true); - - if (!ActiveDirectoryUtils.AdObjectExists(computerPath)) + if (!ActiveDirectoryUtils.AdObjectExists(tenantComputerGroupPath)) { - computerPath = GetComputerPath(hostName, false); + 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)) - { - ActiveDirectoryUtils.RemoveObjectFromGroup(computerPath, tenantComputerGroupPath); - } - + if (ActiveDirectoryUtils.AdObjectExists(GetComputersRootPath()) && !string.IsNullOrEmpty(ComputersRootOU) && !ActiveDirectoryUtils.IsComputerInGroup(samName, RdsServersRootOU)) { DirectoryEntry group = new DirectoryEntry(GetRdsServersGroupPath()); - group.Invoke("Add", computerObject.Path); - - group.CommitChanges(); + computerObject.MoveTo(group); } } } @@ -1744,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) { @@ -1772,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); @@ -1798,7 +1754,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices AppendProtocol(sb); AppendDomainController(sb); - AppendCNPath(sb, RdsServersRootOU); + AppendOUPath(sb, RdsServersRootOU); AppendOUPath(sb, ComputersRootOU); AppendDomainPath(sb, RootDomain); @@ -1812,7 +1768,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices AppendProtocol(sb); AppendDomainController(sb); AppendCNPath(sb, name); - AppendCNPath(sb, RdsServersRootOU); + AppendOUPath(sb, RdsServersRootOU); AppendOUPath(sb, ComputersRootOU); AppendDomainPath(sb, RootDomain); @@ -1836,7 +1792,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices 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.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionUsers.ascx.cs index 5bcd026b..8af9191a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionUsers.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionUsers.ascx.cs @@ -77,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/UserControls/RDSCollectionUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionUsers.ascx.cs index 40c4311a..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)