protected void btnSave_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } try { if (servers.GetServers().Count < 1) { messageBox.ShowErrorMessage("RDS_CREATE_COLLECTION_RDSSERVER_REQUAIRED"); return; } RdsCollection collection = new RdsCollection{ Name = txtCollectionName.Text, DisplayName = txtCollectionName.Text, Servers = servers.GetServers(), Description = "" }; int collectionId = ES.Services.RDS.AddRdsCollection(PanelRequest.ItemID, collection); Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "rds_edit_collection", "CollectionId=" + collectionId, "ItemID=" + PanelRequest.ItemID)); } catch (Exception ex) { ShowErrorMessage("RDSCOLLECTION_NOT_CREATED", ex); } }
public void EditRdsCollectionSettings(RdsCollection collection) { try { Log.WriteStart("'{0}' EditRdsCollectionSettings", ProviderSettings.ProviderName); RDSProvider.EditRdsCollectionSettings(collection); Log.WriteEnd("'{0}' EditRdsCollectionSettings", ProviderSettings.ProviderName); } catch (Exception ex) { Log.WriteError(String.Format("'{0}' EditRdsCollectionSettings", ProviderSettings.ProviderName), ex); throw; } }
public bool CreateCollection(string organizationId, RdsCollection collection) { try { Log.WriteStart("'{0}' CreateCollection", ProviderSettings.ProviderName); var result = RDSProvider.CreateCollection(organizationId, collection); Log.WriteEnd("'{0}' CreateCollection", ProviderSettings.ProviderName); return result; } catch (Exception ex) { Log.WriteError(String.Format("'{0}' CreateCollection", ProviderSettings.ProviderName), ex); throw; } }
public static RdsCollection GetCollection(this Runspace runspace, string collectionName, string connectionBroker, string primaryDomainController) { RdsCollection collection = null; Command cmd = new Command("Get-RDSessionCollection"); cmd.Parameters.Add("CollectionName", collectionName); cmd.Parameters.Add("ConnectionBroker", connectionBroker); var collectionPs = ExecuteShellCommand(runspace, cmd, false, primaryDomainController).FirstOrDefault(); if (collectionPs != null) { collection = new RdsCollection(); collection.Name = Convert.ToString(GetPSObjectProperty(collectionPs, "CollectionName")); collection.Description = Convert.ToString(GetPSObjectProperty(collectionPs, "CollectionDescription")); } return collection; }
public static RdsCollection GetCollection(this Runspace runspace, string collectionName, string connectionBroker, string primaryDomainController) { RdsCollection collection = null; Command cmd = new Command("Get-RDSessionCollection"); cmd.Parameters.Add("CollectionName", collectionName); cmd.Parameters.Add("ConnectionBroker", connectionBroker); var collectionPs = ExecuteShellCommand(runspace, cmd, false, primaryDomainController).FirstOrDefault(); if (collectionPs != null) { collection = new RdsCollection(); collection.Name = Convert.ToString(GetPSObjectProperty(collectionPs, "CollectionName")); collection.Description = Convert.ToString(GetPSObjectProperty(collectionPs, "CollectionDescription")); } return(collection); }
private void BindControls(RdsCollection collection) { slDisconnectedSessionLimit.SelectedLimit = collection.Settings.DisconnectedSessionLimitMin; slActiveSessionLimit.SelectedLimit = collection.Settings.ActiveSessionLimitMin; slIdleSessionLimit.SelectedLimit = collection.Settings.IdleSessionLimitMin; if (collection.Settings.BrokenConnectionAction == BrokenConnectionActionValues.Disconnect.ToString()) { chDisconnect.Checked = true; chAutomaticReconnection.Enabled = true; } else { chEndSession.Checked = true; chAutomaticReconnection.Enabled = false; } chAutomaticReconnection.Checked = collection.Settings.AutomaticReconnectionEnabled; chDeleteOnExit.Checked = collection.Settings.TemporaryFoldersDeletedOnExit; chUseFolders.Checked = collection.Settings.TemporaryFoldersPerSession; if (collection.Settings.ClientDeviceRedirectionOptions != null) { chAudioVideo.Checked = collection.Settings.ClientDeviceRedirectionOptions.Contains(ClientDeviceRedirectionOptionValues.AudioVideoPlayBack.ToString()); chAudioRecording.Checked = collection.Settings.ClientDeviceRedirectionOptions.Contains(ClientDeviceRedirectionOptionValues.AudioRecording.ToString()); chDrives.Checked = collection.Settings.ClientDeviceRedirectionOptions.Contains(ClientDeviceRedirectionOptionValues.Drive.ToString()); chSmartCards.Checked = collection.Settings.ClientDeviceRedirectionOptions.Contains(ClientDeviceRedirectionOptionValues.SmartCard.ToString()); chPlugPlay.Checked = collection.Settings.ClientDeviceRedirectionOptions.Contains(ClientDeviceRedirectionOptionValues.PlugAndPlayDevice.ToString()); chClipboard.Checked = collection.Settings.ClientDeviceRedirectionOptions.Contains(ClientDeviceRedirectionOptionValues.Clipboard.ToString()); } chPrinterRedirection.Checked = collection.Settings.ClientPrinterRedirected; chDefaultDevice.Checked = collection.Settings.ClientPrinterAsDefault; chDefaultDevice.Enabled = collection.Settings.ClientPrinterRedirected; chEasyPrint.Checked = collection.Settings.RDEasyPrintDriverEnabled; chEasyPrint.Enabled = collection.Settings.ClientPrinterRedirected; tbMonitorsNumber.Text = collection.Settings.MaxRedirectedMonitors.ToString(); cbAuthentication.Checked = collection.Settings.AuthenticateUsingNLA; ddSecurityLayer.SelectedValue = collection.Settings.SecurityLayer; ddEncryptionLevel.SelectedValue = collection.Settings.EncryptionLevel; }
public void ImportCollection(string organizationId, RdsCollection collection, List<string> users) { try { Log.WriteStart("'{0}' ImportCollection", ProviderSettings.ProviderName); RDSProvider.ImportCollection(organizationId, collection, users); Log.WriteEnd("'{0}' ImportCollection", ProviderSettings.ProviderName); } catch (Exception ex) { Log.WriteError(String.Format("'{0}' ImportCollection", ProviderSettings.ProviderName), ex); throw; } }
public ResultObject AddRdsServerToCollection(int itemId, RdsServer rdsServer, RdsCollection rdsCollection) { return RemoteDesktopServicesController.AddRdsServerToCollection(itemId, rdsServer, rdsCollection); }
private static ResultObject RemoveRdsCollectionInternal(int itemId, RdsCollection collection) { var result = TaskManager.StartResultTask<ResultObject>("REMOTE_DESKTOP_SERVICES", "REMOVE_RDS_COLLECTION"); try { // load organization Organization org = OrganizationController.GetOrganization(itemId); if (org == null) { result.IsSuccess = false; result.AddError("", new NullReferenceException("Organization not found")); return result; } var rds = RemoteDesktopServicesHelpers.GetRemoteDesktopServices(RemoteDesktopServicesHelpers.GetRemoteDesktopServiceID(org.PackageId)); var servers = ObjectUtils.CreateListFromDataReader<RdsServer>(DataProvider.GetRDSServersByCollectionId(collection.Id)).ToArray(); rds.RemoveCollection(org.OrganizationId, collection.Name, servers); DataProvider.DeleteRDSServerSettings(collection.Id); DataProvider.DeleteRDSCollection(collection.Id); } catch (Exception ex) { result.AddError("REMOTE_DESKTOP_SERVICES_REMOVE_RDS_COLLECTION", ex); } finally { if (!result.IsSuccess) { TaskManager.CompleteResultTask(result); } else { TaskManager.CompleteResultTask(); } } return result; }
public void ImportCollection(string organizationId, RdsCollection collection, List<string> users) { Runspace runSpace = null; try { Log.WriteStart(string.Format("Starting collection import: {0}", collection.Name)); runSpace = OpenRunspace(); var orgPath = GetOrganizationPath(organizationId); 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); 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); foreach (var gateway in Gateways) { CreateHelpDeskRdCapForce(runSpace, gateway); CreateHelpDeskRdRapForce(runSpace, gateway); if (!CentralNps) { CreateRdCapForce(runSpace, gateway, capPolicyName, collection.Name, new List<string> { GetUsersGroupName(collection.Name) }); } CreateRdRapForce(runSpace, gateway, rapPolicyName, collection.Name, new List<string> { GetUsersGroupName(collection.Name) }); } if (CentralNps) { CreateCentralNpsPolicy(runSpace, CentralNpsHost, capPolicyName, collection.Name, organizationId); } //add user group to collection AddUserGroupsToCollection(runSpace, collection.Name, new List<string> { GetUsersGroupName(collection.Name) }); //add session servers to group foreach (var rdsServer in collection.Servers) { MoveSessionHostToCollectionOU(rdsServer.Name, collection.Name, organizationId); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, localAdminsGroupSamAccountName); Log.WriteStart(string.Format("Adding server {0} to AD Group, OrgId: {1}", rdsServer.Name, organizationId)); AddComputerToCollectionAdComputerGroup(organizationId, collection.Name, rdsServer); Log.WriteStart(string.Format("Server {0} added to AD Group, OrgId: {1}", rdsServer.Name, organizationId)); } string collectionComputersPath = GetComputerGroupPath(organizationId, collection.Name); CreatePolicy(runSpace, organizationId, string.Format("{0}-administrators", collection.Name), new DirectoryEntry(GetGroupPath(organizationId, collection.Name, GetLocalAdminsGroupName(collection.Name))), new DirectoryEntry(collectionComputersPath), collection.Name); CreateUsersPolicy(runSpace, organizationId, string.Format("{0}-users", collection.Name), new DirectoryEntry(GetUsersGroupPath(organizationId, collection.Name)) , new DirectoryEntry(collectionComputersPath), collection.Name); CreateHelpDeskPolicy(runSpace, new DirectoryEntry(GetHelpDeskGroupPath(RDSHelpDeskGroup)), new DirectoryEntry(collectionComputersPath), organizationId, collection.Name); SetUsersInCollection(organizationId, collection.Name, users); Log.WriteStart(string.Format("Collection imported: {0}", collection.Name)); } finally { CloseRunspace(runSpace); } }
public void EditRdsCollectionSettings(RdsCollection collection) { this.Invoke("EditRdsCollectionSettings", new object[] { collection}); }
/// <remarks/> public void EditRdsCollectionSettingsAsync(RdsCollection collection) { this.EditRdsCollectionSettingsAsync(collection, null); }
public bool CreateCollection(string organizationId, RdsCollection collection) { object[] results = this.Invoke("CreateCollection", new object[] { organizationId, collection}); return ((bool)(results[0])); }
/// <remarks/> public void CreateCollectionAsync(string organizationId, RdsCollection collection) { this.CreateCollectionAsync(organizationId, collection, null); }
/// <remarks/> public System.IAsyncResult BeginImportCollection(string organizationId, RdsCollection collection, string[] users, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("ImportCollection", new object[] { organizationId, collection, users}, callback, asyncState); }
public bool CreateCollection(string organizationId, RdsCollection collection) { var result = true; Runspace runSpace = null; try { runSpace = OpenRunspace(); Log.WriteWarning("Creating Collection"); var existingServers = GetServersExistingInCollections(runSpace); existingServers = existingServers.Select(x => x.ToUpper()).Intersect(collection.Servers.Select(x => x.FqdName.ToUpper())).ToList(); if (existingServers.Any()) { throw new Exception(string.Format("Server{0} {1} already added to another collection", existingServers.Count == 1 ? "" : "s", string.Join(" ,", existingServers.ToArray()))); } foreach (var server in collection.Servers) { //If server will restart it will not be added to collection //Do not install feature here if (!ExistRdsServerInDeployment(runSpace, server)) { AddRdsServerToDeployment(runSpace, server); } } Log.WriteWarning("powershell: New-RDSessionCollection"); Command cmd = new Command("New-RDSessionCollection"); cmd.Parameters.Add("CollectionName", collection.Name); cmd.Parameters.Add("SessionHost", collection.Servers.Select(x => x.FqdName).ToArray()); cmd.Parameters.Add("ConnectionBroker", ConnectionBroker); if (!string.IsNullOrEmpty(collection.Description)) { cmd.Parameters.Add("CollectionDescription", collection.Description); } var collectionPs = ExecuteShellCommand(runSpace, cmd, false).FirstOrDefault(); if (collectionPs == null) { throw new Exception("Collection not created"); } Log.WriteWarning("powershell: New-RDSessionCollection\tSuccessfully"); EditRdsCollectionSettingsInternal(collection, runSpace); Log.WriteWarning("Settings edited"); var orgPath = GetOrganizationPath(organizationId); Log.WriteWarning(string.Format("orgPath: {0}", orgPath)); 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); 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); foreach (var gateway in Gateways) { CreateHelpDeskRdCapForce(runSpace, gateway); CreateHelpDeskRdRapForce(runSpace, gateway); if (!CentralNps) { CreateRdCapForce(runSpace, gateway, capPolicyName, collection.Name, new List<string> { GetUsersGroupName(collection.Name) }); } CreateRdRapForce(runSpace, gateway, rapPolicyName, collection.Name, new List<string> { GetUsersGroupName(collection.Name) }); } if (CentralNps) { CreateCentralNpsPolicy(runSpace, CentralNpsHost, capPolicyName, collection.Name, organizationId); } //add user group to collection AddUserGroupsToCollection(runSpace, collection.Name, new List<string> { GetUsersGroupName(collection.Name) }); //add session servers to group foreach (var rdsServer in collection.Servers) { MoveSessionHostToCollectionOU(rdsServer.Name, collection.Name, organizationId); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, localAdminsGroupSamAccountName); AddComputerToCollectionAdComputerGroup(organizationId, collection.Name, rdsServer); } string collectionComputersPath = GetComputerGroupPath(organizationId, collection.Name); CreatePolicy(runSpace, organizationId, string.Format("{0}-administrators", collection.Name), new DirectoryEntry(GetGroupPath(organizationId, collection.Name, GetLocalAdminsGroupName(collection.Name))), new DirectoryEntry(collectionComputersPath), collection.Name); CreateUsersPolicy(runSpace, organizationId, string.Format("{0}-users", collection.Name), new DirectoryEntry(GetUsersGroupPath(organizationId, collection.Name)) , new DirectoryEntry(collectionComputersPath), collection.Name); CreateHelpDeskPolicy(runSpace, new DirectoryEntry(GetHelpDeskGroupPath(RDSHelpDeskGroup)), new DirectoryEntry(collectionComputersPath), organizationId, collection.Name); } finally { CloseRunspace(runSpace); } return result; }
public ResultObject RemoveRdsCollection(int itemId, RdsCollection collection) { return RemoteDesktopServicesController.RemoveRdsCollection(itemId, collection); }
internal List<string> EditRdsCollectionSettingsInternal(RdsCollection collection, Runspace runspace) { object[] errors; Command cmd = new Command("Set-RDSessionCollectionConfiguration"); cmd.Parameters.Add("CollectionName", collection.Name); cmd.Parameters.Add("ConnectionBroker", ConnectionBroker); if (string.IsNullOrEmpty(collection.Settings.ClientDeviceRedirectionOptions)) { collection.Settings.ClientDeviceRedirectionOptions = "None"; } var properties = collection.Settings.GetType().GetProperties(); foreach(var prop in properties) { if (prop.Name.ToLower() != "id" && prop.Name.ToLower() != "rdscollectionid") { var value = prop.GetValue(collection.Settings, null); if (value != null) { cmd.Parameters.Add(prop.Name, value); } } } ExecuteShellCommand(runspace, cmd, false, out errors); if (errors != null) { return errors.Select(e => e.ToString()).ToList(); } return new List<string>(); }
public void EditRdsCollectionSettings(RdsCollection collection) { Runspace runSpace = null; try { runSpace = OpenRunspace(); if (collection.Settings != null) { var errors = EditRdsCollectionSettingsInternal(collection, runSpace); if (errors.Count > 0) { throw new Exception(string.Format("Settings not setted:\r\n{0}", string.Join("r\\n\\", errors.ToArray()))); } } } finally { CloseRunspace(runSpace); } }
public void ImportCollection(string organizationId, RdsCollection collection, string[] users) { this.Invoke("ImportCollection", new object[] { organizationId, collection, users}); }
public ResultObject RemoveRdsServerFromCollection(int itemId, RdsServer rdsServer, RdsCollection rdsCollection) { return RemoteDesktopServicesController.RemoveRdsServerFromCollection(itemId, rdsServer, rdsCollection); }
/// <remarks/> public void ImportCollectionAsync(string organizationId, RdsCollection collection, string[] users) { this.ImportCollectionAsync(organizationId, collection, users, null); }
public ResultObject RemoveRemoteApplicationFromCollection(int itemId, RdsCollection collection, RemoteApplication application) { return RemoteDesktopServicesController.RemoveRemoteApplicationFromCollection(itemId, collection, application); }
/// <remarks/> public System.IAsyncResult BeginCreateCollection(string organizationId, RdsCollection collection, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("CreateCollection", new object[] { organizationId, collection}, callback, asyncState); }
public int AddRdsCollection(int itemId, RdsCollection collection) { return RemoteDesktopServicesController.AddRdsCollection(itemId, collection); }
/// <remarks/> 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, collection}, this.CreateCollectionOperationCompleted, userState); }
public ResultObject EditRdsCollectionSettings(int itemId, RdsCollection collection) { return RemoteDesktopServicesController.EditRdsCollectionSettings(itemId, collection); }
/// <remarks/> public System.IAsyncResult BeginEditRdsCollectionSettings(RdsCollection collection, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("EditRdsCollectionSettings", new object[] { collection}, callback, asyncState); }
public static void UpdateRDSCollection(RdsCollection collection) { UpdateRDSCollection(collection.Id, collection.ItemId, collection.Name, collection.Description, collection.DisplayName); }
/// <remarks/> public void EditRdsCollectionSettingsAsync(RdsCollection collection, object userState) { if ((this.EditRdsCollectionSettingsOperationCompleted == null)) { this.EditRdsCollectionSettingsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnEditRdsCollectionSettingsOperationCompleted); } this.InvokeAsync("EditRdsCollectionSettings", new object[] { collection}, this.EditRdsCollectionSettingsOperationCompleted, userState); }
public static ResultObject RemoveRdsCollection(int itemId, RdsCollection collection) { return RemoveRdsCollectionInternal(itemId, collection); }