diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs index af25ea50..6ba412b9 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs @@ -2155,16 +2155,16 @@ namespace WebsitePanel.EnterpriseServer { /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetRdsCollectionLocalAdmins", 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 OrganizationUser[] GetRdsCollectionLocalAdmins(int itemId) { + public OrganizationUser[] GetRdsCollectionLocalAdmins(int collectionId) { object[] results = this.Invoke("GetRdsCollectionLocalAdmins", new object[] { - itemId}); + collectionId}); return ((OrganizationUser[])(results[0])); } /// - public System.IAsyncResult BeginGetRdsCollectionLocalAdmins(int itemId, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginGetRdsCollectionLocalAdmins(int collectionId, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("GetRdsCollectionLocalAdmins", new object[] { - itemId}, callback, asyncState); + collectionId}, callback, asyncState); } /// @@ -2174,17 +2174,17 @@ namespace WebsitePanel.EnterpriseServer { } /// - public void GetRdsCollectionLocalAdminsAsync(int itemId) { - this.GetRdsCollectionLocalAdminsAsync(itemId, null); + public void GetRdsCollectionLocalAdminsAsync(int collectionId) { + this.GetRdsCollectionLocalAdminsAsync(collectionId, null); } /// - public void GetRdsCollectionLocalAdminsAsync(int itemId, object userState) { + public void GetRdsCollectionLocalAdminsAsync(int collectionId, object userState) { if ((this.GetRdsCollectionLocalAdminsOperationCompleted == null)) { this.GetRdsCollectionLocalAdminsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetRdsCollectionLocalAdminsOperationCompleted); } this.InvokeAsync("GetRdsCollectionLocalAdmins", new object[] { - itemId}, this.GetRdsCollectionLocalAdminsOperationCompleted, userState); + collectionId}, this.GetRdsCollectionLocalAdminsOperationCompleted, userState); } private void OnGetRdsCollectionLocalAdminsOperationCompleted(object arg) { @@ -2196,18 +2196,18 @@ namespace WebsitePanel.EnterpriseServer { /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SaveRdsCollectionLocalAdmins", 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 SaveRdsCollectionLocalAdmins(OrganizationUser[] users, int itemId) { + public ResultObject SaveRdsCollectionLocalAdmins(OrganizationUser[] users, int collectionId) { object[] results = this.Invoke("SaveRdsCollectionLocalAdmins", new object[] { users, - itemId}); + collectionId}); return ((ResultObject)(results[0])); } /// - public System.IAsyncResult BeginSaveRdsCollectionLocalAdmins(OrganizationUser[] users, int itemId, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginSaveRdsCollectionLocalAdmins(OrganizationUser[] users, int collectionId, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("SaveRdsCollectionLocalAdmins", new object[] { users, - itemId}, callback, asyncState); + collectionId}, callback, asyncState); } /// @@ -2217,18 +2217,18 @@ namespace WebsitePanel.EnterpriseServer { } /// - public void SaveRdsCollectionLocalAdminsAsync(OrganizationUser[] users, int itemId) { - this.SaveRdsCollectionLocalAdminsAsync(users, itemId, null); + public void SaveRdsCollectionLocalAdminsAsync(OrganizationUser[] users, int collectionId) { + this.SaveRdsCollectionLocalAdminsAsync(users, collectionId, null); } /// - public void SaveRdsCollectionLocalAdminsAsync(OrganizationUser[] users, int itemId, object userState) { + public void SaveRdsCollectionLocalAdminsAsync(OrganizationUser[] users, int collectionId, object userState) { if ((this.SaveRdsCollectionLocalAdminsOperationCompleted == null)) { this.SaveRdsCollectionLocalAdminsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSaveRdsCollectionLocalAdminsOperationCompleted); } this.InvokeAsync("SaveRdsCollectionLocalAdmins", new object[] { users, - itemId}, this.SaveRdsCollectionLocalAdminsOperationCompleted, userState); + collectionId}, this.SaveRdsCollectionLocalAdminsOperationCompleted, userState); } private void OnSaveRdsCollectionLocalAdminsOperationCompleted(object arg) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs index 04da46cb..e1561f26 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs @@ -268,14 +268,14 @@ namespace WebsitePanel.EnterpriseServer return RestartRdsServerInternal(itemId, fqdnName); } - public static List GetRdsCollectionLocalAdmins(int itemId) + public static List GetRdsCollectionLocalAdmins(int collectionId) { - return GetRdsCollectionLocalAdminsInternal(itemId); + return GetRdsCollectionLocalAdminsInternal(collectionId); } - public static ResultObject SaveRdsCollectionLocalAdmins(OrganizationUser[] users, int itemId) + public static ResultObject SaveRdsCollectionLocalAdmins(OrganizationUser[] users, int collectionId) { - return SaveRdsCollectionLocalAdminsInternal(users, itemId); + return SaveRdsCollectionLocalAdminsInternal(users, collectionId); } private static RdsCollection GetRdsCollectionInternal(int collectionId) @@ -310,10 +310,12 @@ namespace WebsitePanel.EnterpriseServer return collection; } - private static List GetRdsCollectionLocalAdminsInternal(int itemId) + private static List GetRdsCollectionLocalAdminsInternal(int collectionId) { var result = new List(); - Organization org = OrganizationController.GetOrganization(itemId); + var collection = ObjectUtils.FillObjectFromDataReader(DataProvider.GetRDSCollectionById(collectionId)); + var servers = ObjectUtils.CreateListFromDataReader(DataProvider.GetRDSServersByCollectionId(collection.Id)).ToList(); + Organization org = OrganizationController.GetOrganization(collection.ItemId); if (org == null) { @@ -322,19 +324,20 @@ namespace WebsitePanel.EnterpriseServer var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); - var organizationUsers = OrganizationController.GetOrganizationUsersPaged(itemId, null, null, null, 0, Int32.MaxValue).PageUsers; - var organizationAdmins = rds.GetRdsCollectionLocalAdmins(org.OrganizationId); + var organizationUsers = OrganizationController.GetOrganizationUsersPaged(collection.ItemId, null, null, null, 0, Int32.MaxValue).PageUsers; + var organizationAdmins = rds.GetRdsCollectionLocalAdmins(servers.First().FqdName); - return organizationUsers.Where(o => organizationAdmins.Select(a => a.ToLower()).Contains(o.SamAccountName.ToLower())).ToList(); + return organizationUsers.Where(o => organizationAdmins.Select(a => a.ToLower()).Contains(o.DomainUserName.ToLower())).ToList(); } - private static ResultObject SaveRdsCollectionLocalAdminsInternal(OrganizationUser[] users, int itemId) + private static ResultObject SaveRdsCollectionLocalAdminsInternal(OrganizationUser[] users, int collectionId) { var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "SAVE_LOCAL_ADMINS"); try - { - Organization org = OrganizationController.GetOrganization(itemId); + { + var collection = ObjectUtils.FillObjectFromDataReader(DataProvider.GetRDSCollectionById(collectionId)); + Organization org = OrganizationController.GetOrganization(collection.ItemId); if (org == null) { @@ -344,7 +347,9 @@ namespace WebsitePanel.EnterpriseServer } var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); - rds.SaveRdsCollectionLocalAdmins(users.Select(u => u.AccountName).ToArray(), org.OrganizationId); + var servers = ObjectUtils.CreateListFromDataReader(DataProvider.GetRDSServersByCollectionId(collection.Id)).ToList(); + + rds.SaveRdsCollectionLocalAdmins(users, servers.Select(s => s.FqdName).ToArray()); } catch (Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs index 9cbd8c42..e6391df1 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs @@ -315,15 +315,15 @@ namespace WebsitePanel.EnterpriseServer } [WebMethod] - public List GetRdsCollectionLocalAdmins(int itemId) + public List GetRdsCollectionLocalAdmins(int collectionId) { - return RemoteDesktopServicesController.GetRdsCollectionLocalAdmins(itemId); + return RemoteDesktopServicesController.GetRdsCollectionLocalAdmins(collectionId); } [WebMethod] - public ResultObject SaveRdsCollectionLocalAdmins(OrganizationUser[] users, int itemId) + public ResultObject SaveRdsCollectionLocalAdmins(OrganizationUser[] users, int collectionId) { - return RemoteDesktopServicesController.SaveRdsCollectionLocalAdmins(users, itemId); + return RemoteDesktopServicesController.SaveRdsCollectionLocalAdmins(users, collectionId); } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs index 86448293..9ecc03eb 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs @@ -31,6 +31,7 @@ using System.Collections; using System.Collections.Generic; using System.Net; using System.Net.Sockets; +using WebsitePanel.Providers.HostedSolution; namespace WebsitePanel.Providers.RemoteDesktopServices { @@ -73,8 +74,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices string GetRdsServerStatus(string serverName); void ShutDownRdsServer(string serverName); void RestartRdsServer(string serverName); - void SaveRdsCollectionLocalAdmins(List users, string organizationId); - List GetRdsCollectionLocalAdmins(string organizationId); + void SaveRdsCollectionLocalAdmins(List users, List hosts); + List GetRdsCollectionLocalAdmins(string hostName); void MoveRdsServerToTenantOU(string hostName, string organizationId); void RemoveRdsServerFromTenantOU(string hostName, string organizationId); } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index a9ebf044..515250c5 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -49,6 +49,7 @@ using System.Management.Automation.Runspaces; using System.Collections.ObjectModel; using System.DirectoryServices; using System.Security.Cryptography.X509Certificates; +using System.Collections; namespace WebsitePanel.Providers.RemoteDesktopServices @@ -66,8 +67,11 @@ 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 = "WSPAdministrators"; - private const string RdsServersOU = "RDSServers"; + private const string WspAdministratorsGroupName = "WSP-Administrators"; + private const string WspAdministratorsGroupDescription = "WSP Administrators"; + private const string RdsServersOU = "RDSServers"; + private const uint ADS_GROUP_TYPE_UNIVERSAL_GROUP = 0x00000008; + private const uint ADS_GROUP_TYPE_SECURITY_ENABLED = 0x80000000; #endregion @@ -954,101 +958,206 @@ namespace WebsitePanel.Providers.RemoteDesktopServices #region Local Admins - public void SaveRdsCollectionLocalAdmins(List users, string organizationId) + public void SaveRdsCollectionLocalAdmins(List users, List hosts) { - if (!CheckAdminsGroup(organizationId)) - { - CreateAdminsGroup(organizationId); - } + Runspace runspace = null; - var orgPath = GetOrganizationPath(organizationId); - var orgEntry = ActiveDirectoryUtils.GetADObject(orgPath); - var existingAdmins = ActiveDirectoryUtils.GetGroupObjects(WspAdministratorsGroupName, "user", orgEntry); - var adminsGroupPath = GetWspAdminsGroupPath(organizationId); - - foreach (string userPath in existingAdmins) + try { - ActiveDirectoryUtils.RemoveObjectFromGroup(userPath, adminsGroupPath); - } - - foreach (var user in users) - { - var userPath = GetUserPath(organizationId, user); + runspace = OpenRunspace(); + var index = ServerSettings.ADRootDomain.LastIndexOf("."); + var domainName = ServerSettings.ADRootDomain; - if (ActiveDirectoryUtils.AdObjectExists(userPath)) + if (index > 0) { - var userObject = ActiveDirectoryUtils.GetADObject(userPath); - var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(userObject, "sAMAccountName"); - ActiveDirectoryUtils.AddObjectToGroup(userPath, adminsGroupPath); + domainName = ServerSettings.ADRootDomain.Substring(0, index); } + + 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())); + } + } + + var existingAdmins = GetExistingLocalAdmins(hostName, runspace).Select(e => e.ToLower()); + var formUsers = users.Select(u => string.Format("{0}\\{1}", domainName, u.SamAccountName).ToLower()); + var newUsers = users.Where(u => !existingAdmins.Contains(string.Format("{0}\\{1}", domainName, u.SamAccountName).ToLower())); + var removedUsers = existingAdmins.Where(e => !formUsers.Contains(e)); + + foreach (var user in newUsers) + { + AddNewLocalAdmin(hostName, user.SamAccountName, runspace); + } + + foreach (var user in removedUsers) + { + RemoveLocalAdmin(hostName, user, runspace); + } + } } + finally + { + CloseRunspace(runspace); + } } - public List GetRdsCollectionLocalAdmins(string organizationId) - { - var adminsGroupPath = GetWspAdminsGroupPath(organizationId); - var orgPath = GetOrganizationPath(organizationId); - var orgEntry = ActiveDirectoryUtils.GetADObject(orgPath); - var rdsAdmins = ActiveDirectoryUtils.GetGroupObjects(WspAdministratorsGroupName, "user", orgEntry); - var rootPath = GetRootOUPath(); - var rootEntry = ActiveDirectoryUtils.GetADObject(rootPath); - - var collectionUsers = ActiveDirectoryUtils.GetGroupObjects(organizationId, "user", rootEntry); - var orgAdmins = collectionUsers.Intersect(rdsAdmins); + public List GetRdsCollectionLocalAdmins(string hostName) + { + Runspace runspace = null; var result = new List(); - foreach (var admin in orgAdmins) + try { - var userObject = ActiveDirectoryUtils.GetADObject(admin); - var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(userObject, "sAMAccountName"); - result.Add(samName); + runspace = OpenRunspace(); + + if (CheckLocalAdminsGroupExists(hostName, runspace)) + { + result = GetExistingLocalAdmins(hostName, runspace); + } + } + finally + { + CloseRunspace(runspace); } return result; } - private bool CheckAdminsGroup(string organizationId) + private bool CheckLocalAdminsGroupExists(string hostName, Runspace runspace) { - var adminsGroupPath = GetWspAdminsGroupPath(organizationId); - return ActiveDirectoryUtils.AdObjectExists(adminsGroupPath); + 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 void CreateAdminsGroup(string organizationId) + private object[] CreateLocalAdministratorsGroup(string hostName, Runspace runspace) { - var adminsRootGroupPath = GetWspAdminsRootGroupPath(organizationId); - ActiveDirectoryUtils.CreateGroup(adminsRootGroupPath, WspAdministratorsGroupName); - - string groupPath = string.Format("WinNT://{0}/{1}/{2},group", ServerSettings.ADRootDomain, PrimaryDomainController, WspAdministratorsGroupName); - - using (var userGroup = new DirectoryEntry(groupPath)) + var scripts = new List { - string localAdministratorsPath = string.Format("WinNT://{0}/{1},group", PrimaryDomainController, "Administrators"); + 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()" + }; - using (DirectoryEntry group = new DirectoryEntry(localAdministratorsPath)) + object[] errors = null; + ExecuteRemoteShellCommand(runspace, hostName, scripts, out errors); + + if (!errors.Any()) + { + scripts = new List { - group.Invoke("Add", groupPath); - group.CommitChanges(); + 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 List GetExistingLocalAdmins(string hostName, Runspace runspace) + { + var result = new List(); + + var scripts = new List + { + string.Format("net localgroup {0} | select -skip 6", WspAdministratorsGroupName) + }; + + object[] errors = null; + var exitingAdmins = ExecuteRemoteShellCommand(runspace, hostName, scripts, out errors); + + if (!errors.Any()) + { + foreach(var user in exitingAdmins.Take(exitingAdmins.Count - 2)) + { + result.Add(user.ToString()); } } + + return result; } + private object[] AddNewLocalAdmin(string hostName, string samAccountName, Runspace runspace) + { + var scripts = new List + { + string.Format("$GroupObj = [ADSI]\"WinNT://{0}/{1}\"", hostName, WspAdministratorsGroupName), + string.Format("$GroupObj.Add(\"WinNT://{0}/{1}\")", ServerSettings.ADRootDomain, samAccountName) + }; + + object[] errors = null; + ExecuteRemoteShellCommand(runspace, hostName, scripts, out errors); + + return errors; + } + + private object[] RemoveLocalAdmin(string hostName, string user, Runspace runspace) + { + var userObject = user.Split('\\'); + + var scripts = new List + { + string.Format("$GroupObj = [ADSI]\"WinNT://{0}/{1}\"", hostName, WspAdministratorsGroupName), + string.Format("$GroupObj.Remove(\"WinNT://{0}/{1}\")", userObject[0], userObject[1]) + }; + + object[] errors = null; + ExecuteRemoteShellCommand(runspace, hostName, scripts, out errors); + + return errors; + } + #endregion #region SSL public void InstallCertificate(byte[] certificate, string password, string hostName) { - var x509Cert = new X509Certificate2(certificate, password, X509KeyStorageFlags.Exportable); + Runspace runspace = null; + + try + { + var x509Cert = new X509Certificate2(certificate, password, X509KeyStorageFlags.Exportable); + runspace = OpenRunspace(); + CopyCertificateFile(certificate, hostName, runspace); + } + finally + { + CloseRunspace(runspace); + } } - private string CopyCertificateFile(byte[] certificate, string hostName) + private string CopyCertificateFile(byte[] certificate, string hostName, Runspace runspace) { var destinationPath = string.Format("\\{0}\\c$\\remoteCert.pfx", hostName); return destinationPath; } - private void DeleteCertificate(string path) + private void DeleteCertificate(string path, Runspace runspace) { } @@ -1464,32 +1573,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices AppendDomainPath(sb, RootDomain); return sb.ToString(); - } - - internal string GetWspAdminsRootGroupPath(string organizationId) - { - StringBuilder sb = new StringBuilder(); - AppendProtocol(sb); - AppendDomainController(sb); - AppendOUPath(sb, organizationId); - AppendOUPath(sb, RootOU); - AppendDomainPath(sb, RootDomain); - - return sb.ToString(); - } - - internal string GetWspAdminsGroupPath(string organizationId) - { - StringBuilder sb = new StringBuilder(); - AppendProtocol(sb); - AppendDomainController(sb); - AppendCNPath(sb, WspAdministratorsGroupName); - AppendOUPath(sb, organizationId); - AppendOUPath(sb, RootOU); - AppendDomainPath(sb, RootDomain); - - return sb.ToString(); - } + } internal string GetUsersGroupPath(string organizationId, string collection) { @@ -1778,7 +1862,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices return ExecuteShellCommand(runSpace, invokeCommand, false, out errors); } - internal Collection ExecuteRemoteShellCommand(Runspace runSpace, string hostName, List scripts, params string[] moduleImports) + internal Collection ExecuteRemoteShellCommand(Runspace runSpace, string hostName, List scripts, out object[] errors, params string[] moduleImports) { Command invokeCommand = new Command("Invoke-Command"); invokeCommand.Parameters.Add("ComputerName", hostName); @@ -1792,7 +1876,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices invokeCommand.Parameters.Add("ScriptBlock", sb); - return ExecuteShellCommand(runSpace, invokeCommand, false); + return ExecuteShellCommand(runSpace, invokeCommand, false, out errors); } internal Collection ExecuteShellCommand(Runspace runSpace, Command cmd) diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs index 2c3cfeed..b3bd520c 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs @@ -18,6 +18,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { using System.Web.Services.Protocols; using System; using System.Diagnostics; + using WebsitePanel.Providers.HostedSolution; /// @@ -1506,17 +1507,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SaveRdsCollectionLocalAdmins", 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 void SaveRdsCollectionLocalAdmins(string[] users, string organizationId) { + public void SaveRdsCollectionLocalAdmins(OrganizationUser[] users, string[] hosts) { this.Invoke("SaveRdsCollectionLocalAdmins", new object[] { users, - organizationId}); + hosts}); } /// - public System.IAsyncResult BeginSaveRdsCollectionLocalAdmins(string[] users, string organizationId, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginSaveRdsCollectionLocalAdmins(OrganizationUser[] users, string[] hosts, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("SaveRdsCollectionLocalAdmins", new object[] { users, - organizationId}, callback, asyncState); + hosts}, callback, asyncState); } /// @@ -1525,18 +1526,18 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } /// - public void SaveRdsCollectionLocalAdminsAsync(string[] users, string organizationId) { - this.SaveRdsCollectionLocalAdminsAsync(users, organizationId, null); + public void SaveRdsCollectionLocalAdminsAsync(OrganizationUser[] users, string[] hosts) { + this.SaveRdsCollectionLocalAdminsAsync(users, hosts, null); } /// - public void SaveRdsCollectionLocalAdminsAsync(string[] users, string organizationId, object userState) { + public void SaveRdsCollectionLocalAdminsAsync(OrganizationUser[] users, string[] hosts, object userState) { if ((this.SaveRdsCollectionLocalAdminsOperationCompleted == null)) { this.SaveRdsCollectionLocalAdminsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSaveRdsCollectionLocalAdminsOperationCompleted); } this.InvokeAsync("SaveRdsCollectionLocalAdmins", new object[] { users, - organizationId}, this.SaveRdsCollectionLocalAdminsOperationCompleted, userState); + hosts}, this.SaveRdsCollectionLocalAdminsOperationCompleted, userState); } private void OnSaveRdsCollectionLocalAdminsOperationCompleted(object arg) { @@ -1549,16 +1550,16 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetRdsCollectionLocalAdmins", 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 string[] GetRdsCollectionLocalAdmins(string organizationId) { + public string[] GetRdsCollectionLocalAdmins(string hostName) { object[] results = this.Invoke("GetRdsCollectionLocalAdmins", new object[] { - organizationId}); + hostName}); return ((string[])(results[0])); } /// - public System.IAsyncResult BeginGetRdsCollectionLocalAdmins(string organizationId, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginGetRdsCollectionLocalAdmins(string hostName, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("GetRdsCollectionLocalAdmins", new object[] { - organizationId}, callback, asyncState); + hostName}, callback, asyncState); } /// @@ -1568,17 +1569,17 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } /// - public void GetRdsCollectionLocalAdminsAsync(string organizationId) { - this.GetRdsCollectionLocalAdminsAsync(organizationId, null); + public void GetRdsCollectionLocalAdminsAsync(string hostName) { + this.GetRdsCollectionLocalAdminsAsync(hostName, null); } /// - public void GetRdsCollectionLocalAdminsAsync(string organizationId, object userState) { + public void GetRdsCollectionLocalAdminsAsync(string hostName, object userState) { if ((this.GetRdsCollectionLocalAdminsOperationCompleted == null)) { this.GetRdsCollectionLocalAdminsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetRdsCollectionLocalAdminsOperationCompleted); } this.InvokeAsync("GetRdsCollectionLocalAdmins", new object[] { - organizationId}, this.GetRdsCollectionLocalAdminsOperationCompleted, userState); + hostName}, this.GetRdsCollectionLocalAdminsOperationCompleted, userState); } private void OnGetRdsCollectionLocalAdminsOperationCompleted(object arg) { diff --git a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs index 32d6533d..decdada6 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs @@ -42,6 +42,7 @@ using WebsitePanel.Providers; using WebsitePanel.Providers.OS; using WebsitePanel.Providers.RemoteDesktopServices; using WebsitePanel.Server.Utils; +using WebsitePanel.Providers.HostedSolution; namespace WebsitePanel.Server { @@ -565,12 +566,12 @@ namespace WebsitePanel.Server } [WebMethod, SoapHeader("settings")] - public void SaveRdsCollectionLocalAdmins(List users, string organizationId) + public void SaveRdsCollectionLocalAdmins(List users, List hosts) { try { Log.WriteStart("'{0}' SaveRdsCollectionLocalAdmins", ProviderSettings.ProviderName); - RDSProvider.SaveRdsCollectionLocalAdmins(users, organizationId); + RDSProvider.SaveRdsCollectionLocalAdmins(users, hosts); Log.WriteEnd("'{0}' SaveRdsCollectionLocalAdmins", ProviderSettings.ProviderName); } catch (Exception ex) @@ -581,12 +582,12 @@ namespace WebsitePanel.Server } [WebMethod, SoapHeader("settings")] - public List GetRdsCollectionLocalAdmins(string organizationId) + public List GetRdsCollectionLocalAdmins(string hostName) { try { Log.WriteStart("'{0}' GetRdsCollectionLocalAdmins", ProviderSettings.ProviderName); - var result = RDSProvider.GetRdsCollectionLocalAdmins(organizationId); + var result = RDSProvider.GetRdsCollectionLocalAdmins(hostName); Log.WriteEnd("'{0}' GetRdsCollectionLocalAdmins", ProviderSettings.ProviderName); return result; 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 482edee5..68fa9ae4 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -5659,6 +5659,9 @@ RDS server not assigned to organization + + Local admins not added + RDS User logging off error diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx index e73c543a..e7277028 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx @@ -30,7 +30,7 @@ - <%-- @@ -48,7 +48,7 @@ - --%> +
diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx.designer.cs index b1666d95..f61636b8 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSCreateCollection.ascx.designer.cs @@ -75,6 +75,42 @@ namespace WebsitePanel.Portal.RDS { /// protected global::System.Web.UI.WebControls.RequiredFieldValidator valCollectionName; + /// + /// secSelectSertificate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.CollapsiblePanel secSelectSertificate; + + /// + /// panelSelectSertificate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel panelSelectSertificate; + + /// + /// upPFX control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.FileUpload upPFX; + + /// + /// txtPFXInstallPassword control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtPFXInstallPassword; + /// /// RDSServersPanel control. /// 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 6125bc19..1ea540d9 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSLocalAdmins.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSLocalAdmins.ascx.cs @@ -12,9 +12,8 @@ namespace WebsitePanel.Portal.RDS protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) - { - var organizationUsers = ES.Services.Organizations.GetOrganizationUsersPaged(PanelRequest.ItemID, null, null, null, 0, Int32.MaxValue).PageUsers; - var collectionLocalAdmins = ES.Services.RDS.GetRdsCollectionLocalAdmins(PanelRequest.ItemID); + { + var collectionLocalAdmins = ES.Services.RDS.GetRdsCollectionLocalAdmins(PanelRequest.CollectionID); var collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID); litCollectionName.Text = collection.DisplayName; @@ -26,11 +25,11 @@ namespace WebsitePanel.Portal.RDS { try { - ES.Services.RDS.SaveRdsCollectionLocalAdmins(users.GetUsers(), PanelRequest.ItemID); + ES.Services.RDS.SaveRdsCollectionLocalAdmins(users.GetUsers(), PanelRequest.CollectionID); } catch (Exception ex) { - messageBox.ShowErrorMessage(ex.Message); + ShowErrorMessage("RDSLOCALADMINS_NOT_ADDED", ex); return false; }