Exemplo n.º 1
0
        private static List <RdsCollectionSetting> GetCollectionSettings(this Runspace runspace, string collectionName, string connectionBroker, string primaryDomainController, string param, out object[] errors)
        {
            Command cmd = new Command("Get-RDSessionCollectionConfiguration");

            cmd.Parameters.Add("CollectionName", collectionName);
            cmd.Parameters.Add("ConnectionBroker", connectionBroker);

            if (!string.IsNullOrEmpty(param))
            {
                cmd.Parameters.Add(param, true);
            }

            var psObject = ExecuteShellCommand(runspace, cmd, false, primaryDomainController, out errors).FirstOrDefault();

            var properties         = typeof(RdsCollectionSettings).GetProperties().Select(p => p.Name.ToLower());
            var collectionSettings = new RdsCollectionSettings();
            var result             = new List <RdsCollectionSetting>();

            if (psObject != null)
            {
                foreach (var prop in psObject.Properties)
                {
                    if (prop.Name.ToLower() != "id" && prop.Name.ToLower() != "rdscollectionid")
                    {
                        result.Add(new RdsCollectionSetting
                        {
                            PropertyName  = prop.Name,
                            PropertyValue = prop.Value
                        });
                    }
                }
            }

            return(result);
        }
        private static List<RdsCollectionSetting> GetCollectionSettings(this Runspace runspace, string collectionName, string connectionBroker, string primaryDomainController, string param, out object[] errors)
        {
            Command cmd = new Command("Get-RDSessionCollectionConfiguration");
            cmd.Parameters.Add("CollectionName", collectionName);
            cmd.Parameters.Add("ConnectionBroker", connectionBroker);

            if (!string.IsNullOrEmpty(param))
            {
                cmd.Parameters.Add(param, true);
            }

            var psObject = ExecuteShellCommand(runspace, cmd, false, primaryDomainController, out errors).FirstOrDefault();

            var properties = typeof(RdsCollectionSettings).GetProperties().Select(p => p.Name.ToLower());
            var collectionSettings = new RdsCollectionSettings();
            var result = new List<RdsCollectionSetting>();

            if (psObject != null)
            {
                foreach (var prop in psObject.Properties)
                {                    
                    if (prop.Name.ToLower() != "id" && prop.Name.ToLower() != "rdscollectionid")
                    {
                        result.Add(new RdsCollectionSetting
                        {
                            PropertyName = prop.Name,
                            PropertyValue = prop.Value
                        });
                    }
                }
            }

            return result;
        }
Exemplo n.º 3
0
 public static void UpdateRDSCollectionSettings(RdsCollectionSettings settings)
 {
     UpdateRDSCollectionSettings(settings.Id, settings.RdsCollectionId, settings.DisconnectedSessionLimitMin, settings.ActiveSessionLimitMin, settings.IdleSessionLimitMin, settings.BrokenConnectionAction,
         settings.AutomaticReconnectionEnabled, settings.TemporaryFoldersDeletedOnExit, settings.TemporaryFoldersPerSession, settings.ClientDeviceRedirectionOptions, settings.ClientPrinterRedirected,
         settings.ClientPrinterAsDefault, settings.RDEasyPrintDriverEnabled, settings.MaxRedirectedMonitors);
 }
        private RdsCollectionSettings GetSettings(RdsCollectionSettings settings)
        {
            settings.DisconnectedSessionLimitMin = slDisconnectedSessionLimit.SelectedLimit;
            settings.ActiveSessionLimitMin = slActiveSessionLimit.SelectedLimit;
            settings.IdleSessionLimitMin = slIdleSessionLimit.SelectedLimit;
            settings.AutomaticReconnectionEnabled = chAutomaticReconnection.Checked;

            if (chDisconnect.Checked)
            {
                settings.BrokenConnectionAction = BrokenConnectionActionValues.Disconnect.ToString();
            }
            else
            {
                settings.BrokenConnectionAction = BrokenConnectionActionValues.LogOff.ToString();
            }

            settings.TemporaryFoldersDeletedOnExit = chDeleteOnExit.Checked;
            settings.TemporaryFoldersPerSession = chUseFolders.Checked;
            settings.ClientPrinterRedirected = chPrinterRedirection.Checked;
            settings.ClientPrinterAsDefault = chDefaultDevice.Checked;
            settings.RDEasyPrintDriverEnabled = chEasyPrint.Checked;
            settings.MaxRedirectedMonitors = Convert.ToInt32(tbMonitorsNumber.Text);

            List<string> redirectionOptions = new List<string>();

            if (chAudioVideo.Checked)
            {
                redirectionOptions.Add(ClientDeviceRedirectionOptionValues.AudioVideoPlayBack.ToString());
            }

            if (chAudioRecording.Checked)
            {
                redirectionOptions.Add(ClientDeviceRedirectionOptionValues.AudioRecording.ToString());
            }

            if (chSmartCards.Checked)
            {
                redirectionOptions.Add(ClientDeviceRedirectionOptionValues.SmartCard.ToString());
            }

            if (chPlugPlay.Checked)
            {
                redirectionOptions.Add(ClientDeviceRedirectionOptionValues.PlugAndPlayDevice.ToString());
            }

            if (chDrives.Checked)
            {
                redirectionOptions.Add(ClientDeviceRedirectionOptionValues.Drive.ToString());
            }

            if (chClipboard.Checked)
            {
                redirectionOptions.Add(ClientDeviceRedirectionOptionValues.Clipboard.ToString());
            }

            settings.ClientDeviceRedirectionOptions = string.Join(",", redirectionOptions.ToArray());
            settings.AuthenticateUsingNLA = cbAuthentication.Checked;
            settings.SecurityLayer = ddSecurityLayer.SelectedItem.Value;
            settings.EncryptionLevel = ddEncryptionLevel.SelectedItem.Value;            

            return settings;
        }
Exemplo n.º 5
0
 public RdsCollection()
 {
     Servers  = new List <RdsServer>();
     Settings = new RdsCollectionSettings();
 }
        public static RdsCollectionSettings ParseCollectionSettings(List<RdsCollectionSetting> settings)
        {
            var collectionSettings = new RdsCollectionSettings();
            var properties = typeof(RdsCollectionSettings).GetProperties().Where(p => p.Name.ToLower() != "id" && p.Name.ToLower() != "rdscollectionid");            

            foreach (var prop in properties)
            {
                var values = settings.Where(s => s.PropertyName.Equals(prop.Name, StringComparison.InvariantCultureIgnoreCase));

                if (values.Count() == 1)
                {
                    switch(prop.Name.ToLower())
                    {
                        case "brokenconnectionaction":
                            prop.SetValue(collectionSettings, ((BrokenConnectionActionValues)values.First().PropertyValue).ToString(), null);
                            break;
                        case "clientdeviceredirectionoptions":
                            prop.SetValue(collectionSettings, ((ClientDeviceRedirectionOptionValues)values.First().PropertyValue).ToString(), null);
                            break;
                        case "encryptionlevel":
                            prop.SetValue(collectionSettings, ((EncryptionLevel)values.First().PropertyValue).ToString(), null);
                            break;
                        case "securitylayer":
                            prop.SetValue(collectionSettings, ((SecurityLayerValues)values.First().PropertyValue).ToString(), null);
                            break;
                        default:
                            prop.SetValue(collectionSettings, Convert.ChangeType(values.First().PropertyValue, prop.PropertyType), null);
                            break;
                    }                    
                }
            }

            return collectionSettings;
        }
Exemplo n.º 7
0
 public RdsCollection()
 {
     Servers = new List<RdsServer>();
     Settings = new RdsCollectionSettings();
 }