diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs index 5f72aec1..f2a3ca42 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs @@ -252,11 +252,7 @@ namespace WebsitePanel.EnterpriseServer var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); - var package = PackageController.GetPackage(org.PackageId); - - var tenant = UserController.GetUser(package.UserId); - - rds.CreateCollection(org.OrganizationId, tenant.Username, collection); + rds.CreateCollection(org.OrganizationId, collection); collection.Id = DataProvider.AddRDSCollection(itemId, collection.Name, collection.Description); @@ -324,11 +320,7 @@ namespace WebsitePanel.EnterpriseServer var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); - var package = PackageController.GetPackage(org.PackageId); - - var tenant = UserController.GetUser(package.UserId); - - rds.RemoveCollection(org.OrganizationId, tenant.Username, collection.Name); + rds.RemoveCollection(org.OrganizationId, collection.Name); DataProvider.DeleteRDSCollection(collection.Id); } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs index ca7fabd3..6cf5ec6b 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs @@ -39,9 +39,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices /// public interface IRemoteDesktopServices { - bool CreateCollection(string organizationId, string tenantName, RdsCollection collection); + bool CreateCollection(string organizationId, RdsCollection collection); RdsCollection GetCollection(string collectionName); - bool RemoveCollection(string organizationId, string tenantName, string collectionName); + bool RemoveCollection(string organizationId, string collectionName); bool SetUsersInCollection(string organizationId, string collectionName, List users); void AddSessionHostServerToCollection(string organizationId, string collectionName, RdsServer server); void AddSessionHostServersToCollection(string organizationId, string collectionName, List servers); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index a3563eb4..ccc6edea 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -62,7 +62,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices private const string Users = "users"; 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 AddNpsString = "netsh nps add np name=\"\"{0}\"\" policysource=\"1\" processingorder=\"{1}\" conditionid=\"0x3d\" conditiondata=\"^5$\" conditionid=\"0x1fb5\" conditiondata=\"{2}\" conditionid=\"0x1fb4\" conditiondata=\"{3}\" conditionid=\"0x1e\" conditiondata=\"UserAuthType:(PW|CA)\" profileid=\"0x1005\" profiledata=\"TRUE\" profileid=\"0x100f\" profiledata=\"TRUE\" profileid=\"0x1009\" profiledata=\"0x7\" profileid=\"0x1fe6\" profiledata=\"0x40000000\""; #endregion #region Properties @@ -139,7 +139,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices #region RDS Collections - public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection) + public bool CreateCollection(string organizationId, RdsCollection collection) { var result = true; @@ -194,13 +194,13 @@ namespace WebsitePanel.Providers.RemoteDesktopServices ActiveDirectoryUtils.CreateGroup(orgPath, GetUsersGroupName(collection.Name)); } - var policyName = GetPolicyName(tenantName, organizationId, collection.Name); + var policyName = GetPolicyName(organizationId, collection.Name); foreach (var gateway in Gateways) { if (!CentralNps) { - CreateRdCapForce(runSpace, gateway, policyName, new List { GetUsersGroupName(collection.Name) }); + CreateRdCapForce(runSpace, gateway, policyName, collection.Name, new List { GetUsersGroupName(collection.Name) }); } CreateRdRapForce(runSpace, gateway, policyName, collection.Name, new List { GetUsersGroupName(collection.Name) }); @@ -263,7 +263,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices return collection; } - public bool RemoveCollection(string organizationId, string tenantName, string collectionName) + public bool RemoveCollection(string organizationId, string collectionName) { var result = true; @@ -280,7 +280,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices ExecuteShellCommand(runSpace, cmd, false); - var policyName = GetPolicyName(tenantName, organizationId, collectionName); + var policyName = GetPolicyName(organizationId, collectionName); foreach (var gateway in Gateways) { @@ -549,11 +549,15 @@ namespace WebsitePanel.Providers.RemoteDesktopServices var count = showResult.Count(x => Convert.ToString(x).Contains("policy conf")) + 1001; - var groupAd = ActiveDirectoryUtils.GetADObject(GetUsersGroupPath(organizationId, collectionName)); + var userGroupAd = ActiveDirectoryUtils.GetADObject(GetUsersGroupPath(organizationId, collectionName)); - var sid = (byte[])ActiveDirectoryUtils.GetADObjectProperty(groupAd, "objectSid"); + var userGroupSid = (byte[])ActiveDirectoryUtils.GetADObjectProperty(userGroupAd, "objectSid"); - var addCmdString = string.Format(AddNpsString, policyName.Replace(" ", "_"), count, ConvertByteToStringSid(sid)); + var computerGroupAd = ActiveDirectoryUtils.GetADObject(GetComputerGroupPath(organizationId, collectionName)); + + var computerGroupSid = (byte[])ActiveDirectoryUtils.GetADObjectProperty(computerGroupAd, "objectSid"); + + var addCmdString = string.Format(AddNpsString, policyName.Replace(" ", "_"), count, ConvertByteToStringSid(userGroupSid), ConvertByteToStringSid(computerGroupSid)); Command addCmd = new Command(addCmdString); @@ -567,7 +571,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices var removeResult = ExecuteRemoteShellCommand(runSpace, centralNpshost, removeCmd); } - internal void CreateRdCapForce(Runspace runSpace, string gatewayHost, string policyName, List groups) + internal void CreateRdCapForce(Runspace runSpace, string gatewayHost, string policyName, string collectionName, List groups) { //New-Item -Path "RDS:\GatewayServer\CAP" -Name "Allow Admins" -UserGroups "Administrators@." -AuthMethod 1 //Set-Item -Path "RDS:\GatewayServer\CAP\Allow Admins\SessionTimeout" -Value 480 -SessionTimeoutAction 0 @@ -578,11 +582,13 @@ namespace WebsitePanel.Providers.RemoteDesktopServices } var userGroupParametr = string.Format("@({0})",string.Join(",", groups.Select(x => string.Format("\"{0}@{1}\"", x, RootDomain)).ToArray())); + var computerGroupParameter = string.Format("\"{0}@{1}\"", GetComputersGroupName(collectionName), RootDomain); Command rdCapCommand = new Command("New-Item"); rdCapCommand.Parameters.Add("Path", string.Format("\"{0}\"", CapPath)); rdCapCommand.Parameters.Add("Name", string.Format("\"{0}\"", policyName)); rdCapCommand.Parameters.Add("UserGroups", userGroupParametr); + rdCapCommand.Parameters.Add("ComputerGroups", computerGroupParameter); rdCapCommand.Parameters.Add("AuthMethod", 1); ExecuteRemoteShellCommand(runSpace, gatewayHost, rdCapCommand, RdsModuleName); @@ -930,9 +936,9 @@ namespace WebsitePanel.Providers.RemoteDesktopServices ExecuteRemoteShellCommand(runSpace, hostname, rdRapCommand, imports); } - private string GetPolicyName(string tenantName,string organizationId, string collectionName) + private string GetPolicyName(string organizationId, string collectionName) { - return string.Format("{0}-{1}-{2}", tenantName, organizationId, collectionName); + return string.Format("rds-{0}-{1}", organizationId, collectionName); } private string GetComputersGroupName(string collectionName) diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs index 24a78087..e3637eae 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs @@ -117,19 +117,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection) { + public bool CreateCollection(string organizationId, RdsCollection collection) { object[] results = this.Invoke("CreateCollection", new object[] { organizationId, - tenantName, collection}); return ((bool)(results[0])); } /// - public System.IAsyncResult BeginCreateCollection(string organizationId, string tenantName, RdsCollection collection, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginCreateCollection(string organizationId, RdsCollection collection, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("CreateCollection", new object[] { organizationId, - tenantName, collection}, callback, asyncState); } @@ -140,18 +138,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } /// - public void CreateCollectionAsync(string organizationId, string tenantName, RdsCollection collection) { - this.CreateCollectionAsync(organizationId, tenantName, collection, null); + public void CreateCollectionAsync(string organizationId, RdsCollection collection) { + this.CreateCollectionAsync(organizationId, collection, null); } /// - public void CreateCollectionAsync(string organizationId, string tenantName, RdsCollection collection, object userState) { + public void CreateCollectionAsync(string organizationId, RdsCollection collection, object userState) { if ((this.CreateCollectionOperationCompleted == null)) { this.CreateCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateCollectionOperationCompleted); } this.InvokeAsync("CreateCollection", new object[] { organizationId, - tenantName, collection}, this.CreateCollectionOperationCompleted, userState); } @@ -207,19 +204,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/RemoveCollection", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public bool RemoveCollection(string organizationId, string tenantName, string collectionName) { + public bool RemoveCollection(string organizationId, string collectionName) { object[] results = this.Invoke("RemoveCollection", new object[] { organizationId, - tenantName, collectionName}); return ((bool)(results[0])); } /// - public System.IAsyncResult BeginRemoveCollection(string organizationId, string tenantName, string collectionName, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginRemoveCollection(string organizationId, string collectionName, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("RemoveCollection", new object[] { organizationId, - tenantName, collectionName}, callback, asyncState); } @@ -230,18 +225,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } /// - public void RemoveCollectionAsync(string organizationId, string tenantName, string collectionName) { - this.RemoveCollectionAsync(organizationId, tenantName, collectionName, null); + public void RemoveCollectionAsync(string organizationId, string collectionName) { + this.RemoveCollectionAsync(organizationId, collectionName, null); } /// - public void RemoveCollectionAsync(string organizationId, string tenantName, string collectionName, object userState) { + public void RemoveCollectionAsync(string organizationId, string collectionName, object userState) { if ((this.RemoveCollectionOperationCompleted == null)) { this.RemoveCollectionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnRemoveCollectionOperationCompleted); } this.InvokeAsync("RemoveCollection", new object[] { organizationId, - tenantName, collectionName}, this.RemoveCollectionOperationCompleted, userState); } diff --git a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs index b7e4d7a7..0bb0fb26 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs @@ -60,12 +60,12 @@ namespace WebsitePanel.Server } [WebMethod, SoapHeader("settings")] - public bool CreateCollection(string organizationId, string tenantName, RdsCollection collection) + public bool CreateCollection(string organizationId, RdsCollection collection) { try { Log.WriteStart("'{0}' CreateCollection", ProviderSettings.ProviderName); - var result = RDSProvider.CreateCollection(organizationId, tenantName, collection); + var result = RDSProvider.CreateCollection(organizationId, collection); Log.WriteEnd("'{0}' CreateCollection", ProviderSettings.ProviderName); return result; } @@ -94,12 +94,12 @@ namespace WebsitePanel.Server } [WebMethod, SoapHeader("settings")] - public bool RemoveCollection(string organizationId, string tenantName, string collectionName) + public bool RemoveCollection(string organizationId, string collectionName) { try { Log.WriteStart("'{0}' RemoveCollection", ProviderSettings.ProviderName); - var result = RDSProvider.RemoveCollection(organizationId, tenantName, collectionName); + var result = RDSProvider.RemoveCollection(organizationId, collectionName); Log.WriteEnd("'{0}' RemoveCollection", ProviderSettings.ProviderName); return result; }