From 1c4b8c10062141f9b704ae7260292482f393ce02 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 17 Dec 2014 05:53:53 -0800 Subject: [PATCH] Managing remote application users --- .../RemoteDesktopServicesProxy.cs | 159 ++++++++++++++++++ .../RemoteDesktopServicesController.cs | 67 +++++++- .../esRemoteDesktopServices.asmx.cs | 11 ++ .../IRemoteDesktopServices.cs | 2 + .../Windows2012.cs | 64 +++++++ .../RemoteDesktopServicesProxy.cs | 155 +++++++++++++++++ .../RemoteDesktopServices.asmx.cs | 35 +++- .../ESModule_ControlsHierarchy.config | 1 + .../App_Data/WebsitePanel_Modules.config | 1 + .../RDSEditApplicationUsers.ascx.resx | 144 ++++++++++++++++ .../RDS/RDSEditApplicationUsers.ascx | 46 +++++ .../RDS/RDSEditApplicationUsers.ascx.cs | 50 ++++++ .../RDSEditApplicationUsers.ascx.designer.cs | 114 +++++++++++++ .../RDS/RDSEditCollectionApps.ascx.cs | 2 +- .../RDS/UserControls/RDSCollectionApps.ascx | 7 +- .../UserControls/RDSCollectionApps.ascx.cs | 12 ++ .../WebsitePanel.Portal.Modules.csproj | 17 +- 17 files changed, 881 insertions(+), 6 deletions(-) create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditApplicationUsers.ascx.resx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs create mode 100644 WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.designer.cs diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs index acccc914..8b6f1e32 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/RemoteDesktopServicesProxy.cs @@ -88,6 +88,10 @@ namespace WebsitePanel.EnterpriseServer { private System.Threading.SendOrPostCallback GetOrganizationRdsUsersCountOperationCompleted; + private System.Threading.SendOrPostCallback GetApplicationUsersOperationCompleted; + + private System.Threading.SendOrPostCallback SetApplicationUsersOperationCompleted; + /// public esRemoteDesktopServices() { this.Url = "http://localhost:9002/esRemoteDesktopServices.asmx"; @@ -180,6 +184,12 @@ namespace WebsitePanel.EnterpriseServer { /// public event GetOrganizationRdsUsersCountCompletedEventHandler GetOrganizationRdsUsersCountCompleted; + /// + public event GetApplicationUsersCompletedEventHandler GetApplicationUsersCompleted; + + /// + public event SetApplicationUsersCompletedEventHandler SetApplicationUsersCompleted; + /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetRdsCollection", 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 RdsCollection GetRdsCollection(int collectionId) { @@ -1503,6 +1513,103 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetApplicationUsers", 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 string[] GetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp) { + object[] results = this.Invoke("GetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp}); + return ((string[])(results[0])); + } + + /// + public System.IAsyncResult BeginGetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("GetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp}, callback, asyncState); + } + + /// + public string[] EndGetApplicationUsers(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string[])(results[0])); + } + + /// + public void GetApplicationUsersAsync(int itemId, int collectionId, RemoteApplication remoteApp) { + this.GetApplicationUsersAsync(itemId, collectionId, remoteApp, null); + } + + /// + public void GetApplicationUsersAsync(int itemId, int collectionId, RemoteApplication remoteApp, object userState) { + if ((this.GetApplicationUsersOperationCompleted == null)) { + this.GetApplicationUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetApplicationUsersOperationCompleted); + } + this.InvokeAsync("GetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp}, this.GetApplicationUsersOperationCompleted, userState); + } + + private void OnGetApplicationUsersOperationCompleted(object arg) { + if ((this.GetApplicationUsersCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetApplicationUsersCompleted(this, new GetApplicationUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SetApplicationUsers", 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 SetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, string[] users) { + object[] results = this.Invoke("SetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp, + users}); + return ((ResultObject)(results[0])); + } + + /// + public System.IAsyncResult BeginSetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, string[] users, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("SetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp, + users}, callback, asyncState); + } + + /// + public ResultObject EndSetApplicationUsers(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((ResultObject)(results[0])); + } + + /// + public void SetApplicationUsersAsync(int itemId, int collectionId, RemoteApplication remoteApp, string[] users) { + this.SetApplicationUsersAsync(itemId, collectionId, remoteApp, users, null); + } + + /// + public void SetApplicationUsersAsync(int itemId, int collectionId, RemoteApplication remoteApp, string[] users, object userState) { + if ((this.SetApplicationUsersOperationCompleted == null)) { + this.SetApplicationUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetApplicationUsersOperationCompleted); + } + this.InvokeAsync("SetApplicationUsers", new object[] { + itemId, + collectionId, + remoteApp, + users}, this.SetApplicationUsersOperationCompleted, userState); + } + + private void OnSetApplicationUsersOperationCompleted(object arg) { + if ((this.SetApplicationUsersCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetApplicationUsersCompleted(this, new SetApplicationUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// public new void CancelAsync(object userState) { base.CancelAsync(userState); @@ -2262,4 +2369,56 @@ namespace WebsitePanel.EnterpriseServer { } } } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void GetApplicationUsersCompletedEventHandler(object sender, GetApplicationUsersCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetApplicationUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetApplicationUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public string[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string[])(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void SetApplicationUsersCompletedEventHandler(object sender, SetApplicationUsersCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SetApplicationUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SetApplicationUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public ResultObject Result { + get { + this.RaiseExceptionIfNecessary(); + return ((ResultObject)(this.results[0])); + } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs index 471a6adb..2c21c32f 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs @@ -203,6 +203,16 @@ namespace WebsitePanel.EnterpriseServer return GetOrganizationRdsUsersCountInternal(itemId); } + public static List GetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp) + { + return GetApplicationUsersInternal(itemId, collectionId, remoteApp); + } + + public static ResultObject SetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, List users) + { + return SetApplicationUsersInternal(itemId, collectionId, remoteApp, users); + } + private static RdsCollection GetRdsCollectionInternal(int collectionId) { var collection = ObjectUtils.FillObjectFromDataReader(DataProvider.GetRDSCollectionById(collectionId)); @@ -832,7 +842,7 @@ namespace WebsitePanel.EnterpriseServer private static List GetRdsCollectionUsersInternal(int collectionId) { return ObjectUtils.CreateListFromDataReader(DataProvider.GetRDSCollectionUsersByRDSCollectionId(collectionId)); - } + } private static ResultObject SetUsersToRdsCollectionInternal(int itemId, int collectionId, List users) { @@ -912,6 +922,61 @@ namespace WebsitePanel.EnterpriseServer return result; } + private static List GetApplicationUsersInternal(int itemId, int collectionId, RemoteApplication remoteApp) + { + var result = new List(); + Organization org = OrganizationController.GetOrganization(itemId); + + if (org == null) + { + return result; + } + + var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); + var collection = GetRdsCollection(collectionId); + + result.AddRange(rds.GetApplicationUsers(collection.Name, remoteApp.DisplayName)); + + return result; + } + + private static ResultObject SetApplicationUsersInternal(int itemId, int collectionId, RemoteApplication remoteApp, List users) + { + var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "SET_REMOTE_APP_USERS"); + + try + { + Organization org = OrganizationController.GetOrganization(itemId); + if (org == null) + { + result.IsSuccess = false; + result.AddError("", new NullReferenceException("Organization not found")); + return result; + } + + var collection = GetRdsCollection(collectionId); + var rds = GetRemoteDesktopServices(GetRemoteDesktopServiceID(org.PackageId)); + rds.SetApplicationUsers(collection.Name, remoteApp, users.ToArray()); + } + catch (Exception ex) + { + result.AddError("REMOTE_DESKTOP_SERVICES_SET_REMOTE_APP_USERS", ex); + } + finally + { + if (!result.IsSuccess) + { + TaskManager.CompleteResultTask(result); + } + else + { + TaskManager.CompleteResultTask(); + } + } + + return result; + } + private static ResultObject AddRemoteApplicationToCollectionInternal(int itemId, RdsCollection collection, RemoteApplication remoteApp) { var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "ADD_REMOTE_APP_TO_COLLECTION"); diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs index 05baf26c..f05d3ca3 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esRemoteDesktopServices.asmx.cs @@ -236,5 +236,16 @@ namespace WebsitePanel.EnterpriseServer return RemoteDesktopServicesController.GetOrganizationRdsUsersCount(itemId); } + [WebMethod] + public List GetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp) + { + return RemoteDesktopServicesController.GetApplicationUsers(itemId, collectionId, remoteApp); + } + + [WebMethod] + public ResultObject SetApplicationUsers(int itemId, int collectionId, RemoteApplication remoteApp, List users) + { + return RemoteDesktopServicesController.SetApplicationUsers(itemId, collectionId, remoteApp, users); + } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs index 7a92294a..6de22e8d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/RemoteDesktopServices/IRemoteDesktopServices.cs @@ -61,5 +61,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices bool CheckSessionHostFeatureInstallation(string hostName); bool CheckServerAvailability(string hostName); + string[] GetApplicationUsers(string collectionName, string applicationName); + bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users); } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index b01884db..16552df1 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -496,6 +496,70 @@ namespace WebsitePanel.Providers.RemoteDesktopServices #region Remote Applications + public string[] GetApplicationUsers(string collectionName, string applicationName) + { + Runspace runspace = null; + List result = new List(); + + try + { + runspace = OpenRunspace(); + + Command cmd = new Command("Get-RDRemoteApp"); + cmd.Parameters.Add("CollectionName", collectionName); + cmd.Parameters.Add("ConnectionBroker", ConnectionBroker); + cmd.Parameters.Add("DisplayName", applicationName); + + var application = ExecuteShellCommand(runspace, cmd, false).FirstOrDefault(); + + if (application != null) + { + var users = (string[])(GetPSObjectProperty(application, "UserGroups")); + + if (users != null) + { + result.AddRange(users); + } + } + } + finally + { + CloseRunspace(runspace); + } + + return result.ToArray(); + } + + public bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users) + { + Runspace runspace = null; + bool result = true; + + try + { + runspace = OpenRunspace(); + + Command cmd = new Command("Set-RDRemoteApp"); + cmd.Parameters.Add("CollectionName", collectionName); + cmd.Parameters.Add("ConnectionBroker", ConnectionBroker); + cmd.Parameters.Add("DisplayName", remoteApp.DisplayName); + cmd.Parameters.Add("UserGroups", users); + cmd.Parameters.Add("Alias", remoteApp.Alias); + + ExecuteShellCommand(runspace, cmd, false).FirstOrDefault(); + } + catch(Exception) + { + result = false; + } + finally + { + CloseRunspace(runspace); + } + + return result; + } + public List GetAvailableRemoteApplications(string collectionName) { var startApps = new List(); diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs index a78e54ae..f3f14bca 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/RemoteDesktopServicesProxy.cs @@ -65,6 +65,10 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { private System.Threading.SendOrPostCallback CheckServerAvailabilityOperationCompleted; + private System.Threading.SendOrPostCallback GetApplicationUsersOperationCompleted; + + private System.Threading.SendOrPostCallback SetApplicationUsersOperationCompleted; + /// public RemoteDesktopServices() { this.Url = "http://localhost:9003/RemoteDesktopServices.asmx"; @@ -124,6 +128,12 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { /// public event CheckServerAvailabilityCompletedEventHandler CheckServerAvailabilityCompleted; + /// + public event GetApplicationUsersCompletedEventHandler GetApplicationUsersCompleted; + + /// + public event SetApplicationUsersCompletedEventHandler SetApplicationUsersCompleted; + /// [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)] @@ -918,6 +928,99 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } } + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetApplicationUsers", 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[] GetApplicationUsers(string collectionName, string applicationName) { + object[] results = this.Invoke("GetApplicationUsers", new object[] { + collectionName, + applicationName}); + return ((string[])(results[0])); + } + + /// + public System.IAsyncResult BeginGetApplicationUsers(string collectionName, string applicationName, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("GetApplicationUsers", new object[] { + collectionName, + applicationName}, callback, asyncState); + } + + /// + public string[] EndGetApplicationUsers(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string[])(results[0])); + } + + /// + public void GetApplicationUsersAsync(string collectionName, string applicationName) { + this.GetApplicationUsersAsync(collectionName, applicationName, null); + } + + /// + public void GetApplicationUsersAsync(string collectionName, string applicationName, object userState) { + if ((this.GetApplicationUsersOperationCompleted == null)) { + this.GetApplicationUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetApplicationUsersOperationCompleted); + } + this.InvokeAsync("GetApplicationUsers", new object[] { + collectionName, + applicationName}, this.GetApplicationUsersOperationCompleted, userState); + } + + private void OnGetApplicationUsersOperationCompleted(object arg) { + if ((this.GetApplicationUsersCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetApplicationUsersCompleted(this, new GetApplicationUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/SetApplicationUsers", 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 SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users) { + object[] results = this.Invoke("SetApplicationUsers", new object[] { + collectionName, + remoteApp, + users}); + return ((bool)(results[0])); + } + + /// + public System.IAsyncResult BeginSetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("SetApplicationUsers", new object[] { + collectionName, + remoteApp, + users}, callback, asyncState); + } + + /// + public bool EndSetApplicationUsers(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((bool)(results[0])); + } + + /// + public void SetApplicationUsersAsync(string collectionName, RemoteApplication remoteApp, string[] users) { + this.SetApplicationUsersAsync(collectionName, remoteApp, users, null); + } + + /// + public void SetApplicationUsersAsync(string collectionName, RemoteApplication remoteApp, string[] users, object userState) { + if ((this.SetApplicationUsersOperationCompleted == null)) { + this.SetApplicationUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetApplicationUsersOperationCompleted); + } + this.InvokeAsync("SetApplicationUsers", new object[] { + collectionName, + remoteApp, + users}, this.SetApplicationUsersOperationCompleted, userState); + } + + private void OnSetApplicationUsersOperationCompleted(object arg) { + if ((this.SetApplicationUsersCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SetApplicationUsersCompleted(this, new SetApplicationUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// public new void CancelAsync(object userState) { base.CancelAsync(userState); @@ -1281,4 +1384,56 @@ namespace WebsitePanel.Providers.RemoteDesktopServices { } } } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void GetApplicationUsersCompletedEventHandler(object sender, GetApplicationUsersCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetApplicationUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetApplicationUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public string[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string[])(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void SetApplicationUsersCompletedEventHandler(object sender, SetApplicationUsersCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SetApplicationUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SetApplicationUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs index d515b37a..46ebb460 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/RemoteDesktopServices.asmx.cs @@ -359,6 +359,39 @@ namespace WebsitePanel.Server throw; } } - } + [WebMethod, SoapHeader("settings")] + public string[] GetApplicationUsers(string collectionName, string applicationName) + { + try + { + Log.WriteStart("'{0}' GetApplicationUsers", ProviderSettings.ProviderName); + var result = RDSProvider.GetApplicationUsers(collectionName, applicationName); + Log.WriteEnd("'{0}' GetApplicationUsers", ProviderSettings.ProviderName); + return result; + } + catch (Exception ex) + { + Log.WriteError(String.Format("'{0}' GetApplicationUsers", ProviderSettings.ProviderName), ex); + throw; + } + } + + [WebMethod, SoapHeader("settings")] + public bool SetApplicationUsers(string collectionName, RemoteApplication remoteApp, string[] users) + { + try + { + Log.WriteStart("'{0}' SetApplicationUsers", ProviderSettings.ProviderName); + var result = RDSProvider.SetApplicationUsers(collectionName, remoteApp, users); + Log.WriteEnd("'{0}' SetApplicationUsers", ProviderSettings.ProviderName); + return result; + } + catch (Exception ex) + { + Log.WriteError(String.Format("'{0}' SetApplicationUsers", ProviderSettings.ProviderName), ex); + throw; + } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config index 43015b80..5e7e4ae7 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/ESModule_ControlsHierarchy.config @@ -141,5 +141,6 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config index 239c3893..da90d397 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Modules.config @@ -574,6 +574,7 @@ + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditApplicationUsers.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditApplicationUsers.ascx.resx new file mode 100644 index 00000000..a1ffcecb --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/App_LocalResources/RDSEditApplicationUsers.ascx.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ShowProgressDialog('Adding RDS Server ...'); + + + Save Changes + + + + + + Edit RDS Application + + + Edit RDS Application + + + Application Name: + + + Server Name + + + No RDS Servers have been added yet. To add a new RDS Servers click "Add RDS Server" button. + + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx new file mode 100644 index 00000000..2dc96cb7 --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx @@ -0,0 +1,46 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RDSEditApplicationUsers.ascx.cs" Inherits="WebsitePanel.Portal.RDS.RDSEditApplicationUsers" %> +<%@ Register Src="../UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %> +<%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %> +<%@ Register Src="UserControls/RDSCollectionUsers.ascx" TagName="CollectionUsers" TagPrefix="wsp"%> + + + + +
+
+
+
+
+
+
+ + +
+
+ + + + + + + +
+ +
+ +
+ +
+ +
+
+ +
+ + +
+
+
+
+
+
\ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs new file mode 100644 index 00000000..95b7448f --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using WebsitePanel.Providers.RemoteDesktopServices; + +namespace WebsitePanel.Portal.RDS +{ + public partial class RDSEditApplicationUsers : WebsitePanelModuleBase + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + var collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID); + var applications = ES.Services.RDS.GetCollectionRemoteApplications(PanelRequest.ItemID, collection.Name); + var remoteApp = applications.Where(x => x.DisplayName.Equals(PanelRequest.ApplicationID, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); + var collectionUsers = ES.Services.RDS.GetRdsCollectionUsers(PanelRequest.CollectionID); + var applicationUsers = ES.Services.RDS.GetApplicationUsers(PanelRequest.ItemID, PanelRequest.CollectionID, remoteApp); + + locCName.Text = collection.Name; + + users.SetUsers(collectionUsers.Where(x => applicationUsers.Contains(x.SamAccountName)).ToArray()); + } + } + + protected void btnSave_Click(object sender, EventArgs e) + { + if (!Page.IsValid) + { + return; + } + + try + { + var collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID); + var applications = ES.Services.RDS.GetCollectionRemoteApplications(PanelRequest.ItemID, collection.Name); + var remoteApp = applications.Where(x => x.DisplayName.Equals(PanelRequest.ApplicationID, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); + ES.Services.RDS.SetApplicationUsers(PanelRequest.ItemID, PanelRequest.CollectionID, remoteApp, users.GetUsers().Select(x => x.AccountName).ToArray()); + + Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "rds_collection_edit_apps", "CollectionId=" + PanelRequest.CollectionID, "ItemID=" + PanelRequest.ItemID)); + } + catch (Exception) + { + } + } + } +} \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.designer.cs new file mode 100644 index 00000000..8ece837d --- /dev/null +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditApplicationUsers.ascx.designer.cs @@ -0,0 +1,114 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebsitePanel.Portal.RDS { + + + public partial class RDSEditApplicationUsers { + + /// + /// asyncTasks control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.EnableAsyncTasksSupport asyncTasks; + + /// + /// imgEditRDSCollection control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Image imgEditRDSCollection; + + /// + /// locTitle control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locTitle; + + /// + /// messageBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.UserControls.SimpleMessageBox messageBox; + + /// + /// locApplicationName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locApplicationName; + + /// + /// locCName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locCName; + + /// + /// UsersPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl UsersPanel; + + /// + /// locUsersSection control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locUsersSection; + + /// + /// users control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.RDS.UserControls.RDSCollectionUsers users; + + /// + /// btnSave control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSave; + + /// + /// valSummary control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ValidationSummary valSummary; + } +} diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionApps.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionApps.ascx.cs index 0d647cb3..cfd3e35d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionApps.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/RDSEditCollectionApps.ascx.cs @@ -48,7 +48,7 @@ namespace WebsitePanel.Portal.RDS locCName.Text = collection.Name; - remoreApps.SetApps(collectionApps); + remoreApps.SetApps(collectionApps, Module); } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx index fc3a8844..147cee05 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/RDS/UserControls/RDSCollectionApps.ascx @@ -21,13 +21,18 @@ - + + + + Users + +
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 d00a249e..684b9dd7 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 @@ -54,6 +54,12 @@ namespace WebsitePanel.Portal.RDS.UserControls BindApps(apps, false); } + public void SetApps(RemoteApplication[] apps, WebPortal.PageModule module) + { + Module = module; + BindApps(apps, false); + } + public RemoteApplication[] GetApps() { return GetGridViewApps(SelectedState.All).ToArray(); @@ -218,5 +224,11 @@ namespace WebsitePanel.Portal.RDS.UserControls { return string.Compare(app1.DisplayName, app2.DisplayName); } + + public string GetCollectionUsersEditUrl(string appId) + { + return EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "rds_application_edit_users", + "CollectionId=" + PanelRequest.CollectionID, "ItemID=" + PanelRequest.ItemID, "ApplicationID=" + appId); + } } } \ No newline at end of file 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 cbc1312c..c98276a8 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitePanel.Portal.Modules.csproj @@ -246,6 +246,13 @@ AddRDSServer.ascx + + RDSEditApplicationUsers.ascx + ASPXCodeBehind + + + RDSEditApplicationUsers.ascx + RDSEditCollection.ascx ASPXCodeBehind @@ -4282,6 +4289,7 @@ + @@ -4294,7 +4302,10 @@ - + + Designer + + Designer @@ -5607,7 +5618,9 @@ Designer - + + Designer +