private void BindSettings(RdsServerSettings settings)
        {
            var setting = GetServerSetting(settings, RdsServerSettings.LOCK_SCREEN_TIMEOUT);

            if (setting != null)
            {
                ddTimeout.SelectedValue = setting.PropertyValue;
                cbTimeoutAdministrators.Checked = setting.ApplyAdministrators;
                cbTimeoutUsers.Checked = setting.ApplyUsers;
            }

            SetCheckboxes(settings, RdsServerSettings.REMOVE_RUN_COMMAND, cbRunCommandAdministrators, cbRunCommandUsers);
            SetCheckboxes(settings, RdsServerSettings.REMOVE_POWERSHELL_COMMAND, cbPowershellAdministrators, cbPowershellUsers);
            SetCheckboxes(settings, RdsServerSettings.HIDE_C_DRIVE, cbHideCDriveAdministrators, cbHideCDriveUsers);
            SetCheckboxes(settings, RdsServerSettings.REMOVE_SHUTDOWN_RESTART, cbShutdownAdministrators, cbShutdownUsers);
            SetCheckboxes(settings, RdsServerSettings.DISABLE_TASK_MANAGER, cbTaskManagerAdministrators, cbTaskManagerUsers);
            SetCheckboxes(settings, RdsServerSettings.CHANGE_DESKTOP_DISABLED, cbDesktopAdministrators, cbDesktopUsers);
            SetCheckboxes(settings, RdsServerSettings.SCREEN_SAVER_DISABLED, cbScreenSaverAdministrators, cbScreenSaverUsers);
            SetCheckboxes(settings, RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION, cbViewSessionAdministrators, cbViewSessionUsers);
            SetCheckboxes(settings, RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION, cbControlSessionAdministrators, cbControlSessionUsers);
            SetCheckboxes(settings, RdsServerSettings.DISABLE_CMD, cbDisableCmdAdministrators, cbDisableCmdUsers);

            setting = GetServerSetting(settings, RdsServerSettings.DRIVE_SPACE_THRESHOLD);

            if (setting != null)
            {
                ddTreshold.SelectedValue = setting.PropertyValue;
            }
        }
        private void SetCheckboxes(RdsServerSettings settings, string settingName, CheckBox cbAdministrators, CheckBox cbUsers)
        {
            var setting = GetServerSetting(settings, settingName);

            if (setting != null)
            {
                cbAdministrators.Checked = setting.ApplyAdministrators;
                cbUsers.Checked = setting.ApplyUsers;
            }
        }
        public static RdsServerSettings GetDefaultGpoSettings()
        {
            var defaultSettings = UserController.GetUserSettings(SecurityContext.User.UserId, UserSettings.RDS_POLICY);
            var settings = new RdsServerSettings();

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.LOCK_SCREEN_TIMEOUT,
                PropertyValue = defaultSettings[RdsServerSettings.LOCK_SCREEN_TIMEOUT_VALUE],
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.LOCK_SCREEN_TIMEOUT_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.LOCK_SCREEN_TIMEOUT_USERS])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_RUN_COMMAND,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.REMOVE_RUN_COMMAND_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.REMOVE_RUN_COMMAND_USERS])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_POWERSHELL_COMMAND,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.REMOVE_POWERSHELL_COMMAND_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.REMOVE_POWERSHELL_COMMAND_USERS])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.HIDE_C_DRIVE,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.HIDE_C_DRIVE_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.HIDE_C_DRIVE_USERS])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_SHUTDOWN_RESTART,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.REMOVE_SHUTDOWN_RESTART_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.REMOVE_SHUTDOWN_RESTART_USERS])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.DISABLE_TASK_MANAGER,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.DISABLE_TASK_MANAGER_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.DISABLE_TASK_MANAGER_USERS])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.CHANGE_DESKTOP_DISABLED,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.CHANGE_DESKTOP_DISABLED_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.CHANGE_DESKTOP_DISABLED_USERS])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.SCREEN_SAVER_DISABLED,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.SCREEN_SAVER_DISABLED_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.SCREEN_SAVER_DISABLED_USERS])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION_Users])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION_Users])
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.DISABLE_CMD,
                PropertyValue = "",
                ApplyAdministrators = Convert.ToBoolean(defaultSettings[RdsServerSettings.DISABLE_CMD_ADMINISTRATORS]),
                ApplyUsers = Convert.ToBoolean(defaultSettings[RdsServerSettings.DISABLE_CMD_USERS])
            });

            return settings;
        }
        public static string GetSettingsXml(RdsServerSettings settings)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement nodeProps = doc.CreateElement("properties");

            if (settings != null)
            {
                foreach (var setting in settings.Settings)
                {
                    XmlElement nodeProp = doc.CreateElement("property");
                    nodeProp.SetAttribute("name", setting.PropertyName);
                    nodeProp.SetAttribute("value", setting.PropertyValue);
                    nodeProp.SetAttribute("applyUsers", setting.ApplyUsers ? "1" : "0");
                    nodeProp.SetAttribute("applyAdministrators", setting.ApplyAdministrators ? "1" : "0");
                    nodeProps.AppendChild(nodeProp);
                }
            }

            return nodeProps.OuterXml;
        }
        public static RdsServerSettings GetEmptyGpoSettings()
        {
            var defaultSettings = UserController.GetUserSettings(SecurityContext.User.UserId, UserSettings.RDS_POLICY);
            var settings = new RdsServerSettings();

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.LOCK_SCREEN_TIMEOUT,
                PropertyValue = defaultSettings[RdsServerSettings.LOCK_SCREEN_TIMEOUT_VALUE]
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_RUN_COMMAND,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_POWERSHELL_COMMAND,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.HIDE_C_DRIVE,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_SHUTDOWN_RESTART,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.DISABLE_TASK_MANAGER,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.CHANGE_DESKTOP_DISABLED,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.SCREEN_SAVER_DISABLED,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION,
                PropertyValue = ""
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.DISABLE_CMD,
                PropertyValue = ""
            });

            return settings;
        }
Ejemplo n.º 6
0
        private void SetRdsSessionHostPermissions(Runspace runspace, RdsServerSettings settings, string usersGpo, string administratorsGpo)
        {
            var viewSetting = settings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION));
            var controlSetting = settings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION));

            if (viewSetting == null || controlSetting == null)
            {
                return;
            }

            if (controlSetting.ApplyUsers)
            {
                SetRegistryValue(runspace, RDSSessionGpoKey, usersGpo, "2", RDSSessionGpoValueName, "DWord");
            }
            else if (viewSetting.ApplyUsers)
            {
                SetRegistryValue(runspace, RDSSessionGpoKey, usersGpo, "4", RDSSessionGpoValueName, "DWord");
            }
            else
            {
                SetRegistryValue(runspace, RDSSessionGpoKey, usersGpo, "3", RDSSessionGpoValueName, "DWord");
            }

            if (controlSetting.ApplyAdministrators)
            {
                SetRegistryValue(runspace, RDSSessionGpoKey, administratorsGpo, "2", RDSSessionGpoValueName, "DWord");
            }
            else if (viewSetting.ApplyAdministrators)
            {
                SetRegistryValue(runspace, RDSSessionGpoKey, administratorsGpo, "4", RDSSessionGpoValueName, "DWord");
            }
            else
            {
                SetRegistryValue(runspace, RDSSessionGpoKey, administratorsGpo, "3", RDSSessionGpoValueName, "DWord");
            }
        }
 /// <remarks/>
 public System.IAsyncResult BeginUpdateRdsServerSettings(int serverId, string settingsName, RdsServerSettings settings, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("UpdateRdsServerSettings", new object[] {
                 serverId,
                 settingsName,
                 settings}, callback, asyncState);
 }
 /// <remarks/>
 public void ApplyGPOAsync(string organizationId, string collectionName, RdsServerSettings serverSettings) {
     this.ApplyGPOAsync(organizationId, collectionName, serverSettings, null);
 }
 public void ApplyGPO(string organizationId, string collectionName, RdsServerSettings serverSettings) {
     this.Invoke("ApplyGPO", new object[] {
                 organizationId,
                 collectionName,
                 serverSettings});
 }
        private static RdsServerSettings GetRdsServerSettingsInternal(int serverId, string settingsName)
        {
            IDataReader reader = DataProvider.GetRdsServerSettings(serverId, settingsName);

            var settings = new RdsServerSettings();
            settings.ServerId = serverId;
            settings.SettingsName = settingsName;

            while (reader.Read())
            {
                settings.Settings.Add(new RdsServerSetting
                {
                    PropertyName = (string)reader["PropertyName"],
                    PropertyValue = (string)reader["PropertyValue"],
                    ApplyAdministrators = Convert.ToBoolean(reader["ApplyAdministrators"]),
                    ApplyUsers = Convert.ToBoolean(reader["ApplyUsers"])
                });                
            }

            reader.Close();

            return settings;
        }  
        private static int UpdateRdsServerSettingsInternal(int serverId, string settingsName, RdsServerSettings settings)
        {
            TaskManager.StartTask("REMOTE_DESKTOP_SERVICES", "UPDATE_SETTINGS");

            try
            {                
                var collection = ObjectUtils.FillObjectFromDataReader<RdsCollection>(DataProvider.GetRDSCollectionById(serverId));
                var rds = RemoteDesktopServicesHelpers.GetRemoteDesktopServices(GetRdsServiceId(collection.ItemId));
                Organization org = OrganizationController.GetOrganization(collection.ItemId);
                rds.ApplyGPO(org.OrganizationId, collection.Name, settings);
                string xml = RemoteDesktopServicesHelpers.GetSettingsXml(settings);

                DataProvider.UpdateRdsServerSettings(serverId, settingsName, xml);

                return 0;
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }
 public static int UpdateRdsServerSettings(int serverId, string settingsName, RdsServerSettings settings)
 {
     return UpdateRdsServerSettingsInternal(serverId, settingsName, settings);
 }
 /// <remarks/>
 public void UpdateRdsServerSettingsAsync(int serverId, string settingsName, RdsServerSettings settings, object userState) {
     if ((this.UpdateRdsServerSettingsOperationCompleted == null)) {
         this.UpdateRdsServerSettingsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateRdsServerSettingsOperationCompleted);
     }
     this.InvokeAsync("UpdateRdsServerSettings", new object[] {
                 serverId,
                 settingsName,
                 settings}, this.UpdateRdsServerSettingsOperationCompleted, userState);
 }
 /// <remarks/>
 public void UpdateRdsServerSettingsAsync(int serverId, string settingsName, RdsServerSettings settings) {
     this.UpdateRdsServerSettingsAsync(serverId, settingsName, settings, null);
 }
 public int UpdateRdsServerSettings(int serverId, string settingsName, RdsServerSettings settings)
 {
     return RemoteDesktopServicesController.UpdateRdsServerSettings(serverId, settingsName, settings);
 }
 private RdsServerSetting GetServerSetting(RdsServerSettings settings, string propertyName)
 {
     return settings.Settings.FirstOrDefault(s => s.PropertyName.Equals(propertyName));
 }
 public void ApplyGPO(string organizationId, string collectionName, RdsServerSettings serverSettings)
 {
     try
     {
         Log.WriteStart("'{0}' ApplyGPO", ProviderSettings.ProviderName);
         RDSProvider.ApplyGPO(organizationId, collectionName, serverSettings);
         Log.WriteEnd("'{0}' ApplyGPO", ProviderSettings.ProviderName);
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' ApplyGPO", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
        private RdsServerSettings GetSettings()
        {                                                                                               
            var settings = new RdsServerSettings();

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.LOCK_SCREEN_TIMEOUT,
                PropertyValue = ddTimeout.SelectedValue,
                ApplyAdministrators = cbTimeoutAdministrators.Checked,
                ApplyUsers = cbTimeoutUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_RUN_COMMAND,
                PropertyValue = "",
                ApplyAdministrators = cbRunCommandAdministrators.Checked,
                ApplyUsers = cbRunCommandUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_POWERSHELL_COMMAND,
                PropertyValue = "",
                ApplyAdministrators = cbPowershellAdministrators.Checked,
                ApplyUsers = cbPowershellUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.HIDE_C_DRIVE,
                PropertyValue = "",
                ApplyAdministrators = cbHideCDriveAdministrators.Checked,
                ApplyUsers = cbHideCDriveUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.REMOVE_SHUTDOWN_RESTART,
                PropertyValue = "",
                ApplyAdministrators = cbShutdownAdministrators.Checked,
                ApplyUsers = cbShutdownUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.DISABLE_TASK_MANAGER,
                PropertyValue = "",
                ApplyAdministrators = cbTaskManagerAdministrators.Checked,
                ApplyUsers = cbTaskManagerUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.CHANGE_DESKTOP_DISABLED,
                PropertyValue = "",
                ApplyAdministrators = cbDesktopAdministrators.Checked,
                ApplyUsers = cbDesktopUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.SCREEN_SAVER_DISABLED,
                PropertyValue = "",
                ApplyAdministrators = cbScreenSaverAdministrators.Checked,
                ApplyUsers = cbScreenSaverUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.DRIVE_SPACE_THRESHOLD,
                PropertyValue = ddTreshold.SelectedValue,
                ApplyAdministrators = true,
                ApplyUsers = true
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.RDS_VIEW_WITHOUT_PERMISSION,
                PropertyValue = "",
                ApplyAdministrators = cbViewSessionAdministrators.Checked,
                ApplyUsers = cbViewSessionUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.RDS_CONTROL_WITHOUT_PERMISSION,
                PropertyValue = "",
                ApplyAdministrators = cbControlSessionAdministrators.Checked,
                ApplyUsers = cbControlSessionUsers.Checked
            });

            settings.Settings.Add(new RdsServerSetting
            {
                PropertyName = RdsServerSettings.DISABLE_CMD,
                PropertyValue = "",
                ApplyAdministrators = cbDisableCmdAdministrators.Checked,
                ApplyUsers = cbDisableCmdUsers.Checked
            });

            return settings;
        }        
 /// <remarks/>
 public System.IAsyncResult BeginApplyGPO(string organizationId, string collectionName, RdsServerSettings serverSettings, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("ApplyGPO", new object[] {
                 organizationId,
                 collectionName,
                 serverSettings}, callback, asyncState);
 }
Ejemplo n.º 20
0
        public void ApplyGPO(string organizationId, string collectionName, RdsServerSettings serverSettings)
        {
            string administratorsGpo = string.Format("{0}-administrators", collectionName);
            string usersGpo = string.Format("{0}-users", collectionName);
            Runspace runspace = null;            

            try
            {
                runspace = OpenRunspace();                
                string collectionComputersPath = GetComputerGroupPath(organizationId, collectionName);

                CreatePolicy(runspace, organizationId, string.Format("{0}-administrators", collectionName),
                    new DirectoryEntry(GetGroupPath(organizationId, collectionName, GetLocalAdminsGroupName(collectionName))), new DirectoryEntry(collectionComputersPath), collectionName);
                CreateUsersPolicy(runspace, organizationId, string.Format("{0}-users", collectionName),
                    new DirectoryEntry(GetUsersGroupPath(organizationId, collectionName)), new DirectoryEntry(collectionComputersPath), collectionName);
                CreateHelpDeskPolicy(runspace, new DirectoryEntry(GetHelpDeskGroupPath(RDSHelpDeskGroup)), new DirectoryEntry(collectionComputersPath), organizationId, collectionName);                
                RemoveRegistryValue(runspace, ScreenSaverGpoKey, administratorsGpo);
                RemoveRegistryValue(runspace, ScreenSaverGpoKey, usersGpo);                
                RemoveRegistryValue(runspace, RemoveRestartGpoKey, administratorsGpo);
                RemoveRegistryValue(runspace, RemoveRestartGpoKey, usersGpo);
                RemoveRegistryValue(runspace, DisableTaskManagerGpoKey, administratorsGpo);
                RemoveRegistryValue(runspace, DisableTaskManagerGpoKey, usersGpo);
                RemoveRegistryValue(runspace, DisableCmdGpoKey, usersGpo);
                RemoveRegistryValue(runspace, DisableCmdGpoKey, administratorsGpo);
                RemoveRegistryValue(runspace, DisallowRunKey, usersGpo);
                RemoveRegistryValue(runspace, DisallowRunParentKey, usersGpo);
                RemoveRegistryValue(runspace, DisallowRunKey, administratorsGpo);
                RemoveRegistryValue(runspace, DisallowRunParentKey, administratorsGpo);

                var setting = serverSettings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.SCREEN_SAVER_DISABLED));
                SetRegistryValue(setting, runspace, ScreenSaverGpoKey, administratorsGpo, usersGpo, ScreenSaverValueName, "0", "string");

                setting = serverSettings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.REMOVE_SHUTDOWN_RESTART));
                SetRegistryValue(setting, runspace, RemoveRestartGpoKey, administratorsGpo, usersGpo, RemoveRestartGpoValueName, "1", "DWord");

                setting = serverSettings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.REMOVE_RUN_COMMAND));
                SetRegistryValue(setting, runspace, RemoveRunGpoKey, administratorsGpo, usersGpo, RemoveRunGpoValueName, "1", "DWord");

                setting = serverSettings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.DISABLE_TASK_MANAGER));
                SetRegistryValue(setting, runspace, DisableTaskManagerGpoKey, administratorsGpo, usersGpo, DisableTaskManagerGpoValueName, "1", "DWord");

                setting = serverSettings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.HIDE_C_DRIVE));
                SetRegistryValue(setting, runspace, HideCDriveGpoKey, administratorsGpo, usersGpo, HideCDriveGpoValueName, "4", "DWord");

                setting = serverSettings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.DISABLE_CMD));
                SetRegistryValue(setting, runspace, DisableCmdGpoKey, administratorsGpo, usersGpo, DisableCmdGpoValueName, "1", "DWord");

                setting = serverSettings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.LOCK_SCREEN_TIMEOUT));
                double result;

                if (setting != null && !string.IsNullOrEmpty(setting.PropertyValue) && double.TryParse(setting.PropertyValue, out result))
                {                    
                    SetRegistryValue(setting, runspace, ScreenSaverTimeoutGpoKey, administratorsGpo, usersGpo, ScreenSaverTimeoutValueName, setting.PropertyValue, "string");                                    
                }

                SetRdsSessionHostPermissions(runspace, serverSettings, usersGpo, administratorsGpo);
                SetPowershellPermissions(runspace, serverSettings.Settings.FirstOrDefault(s => s.PropertyName.Equals(RdsServerSettings.REMOVE_POWERSHELL_COMMAND)), usersGpo, administratorsGpo);
            }
            finally
            {
                CloseRunspace(runspace);
            }
        }
 /// <remarks/>
 public void ApplyGPOAsync(string organizationId, string collectionName, RdsServerSettings serverSettings, object userState) {
     if ((this.ApplyGPOOperationCompleted == null)) {
         this.ApplyGPOOperationCompleted = new System.Threading.SendOrPostCallback(this.OnApplyGPOOperationCompleted);
     }
     this.InvokeAsync("ApplyGPO", new object[] {
                 organizationId,
                 collectionName,
                 serverSettings}, this.ApplyGPOOperationCompleted, userState);
 }
 public int UpdateRdsServerSettings(int serverId, string settingsName, RdsServerSettings settings) {
     object[] results = this.Invoke("UpdateRdsServerSettings", new object[] {
                 serverId,
                 settingsName,
                 settings});
     return ((int)(results[0]));
 }