[PTRun][Enterprise]GPO for plugin enabled state (#27468)

* try code for gpo with pluginID param

* fix typo

* fixes

* update admx

* Add second policy to admx

* spelling fixes

* admx clean up

* add gpo code

* small fixes

* fixes

* fix cast

* update settings code

* bug fixes

* fix plugins disabled warning

* Info bar in settings

* settings ui fixes

* code clean up

* fix spelling

* fix spelling

* code optimization

* changes

* fix code

* switch to char*

* update comments

* validate plugin ID

* spell fixes

* spell fixes

* fix IPlugin interface

* Update Directory.Packages.props

hopefully fixes unit tests

* revert change of nuget pkg

* fixes

* fix spell check

* add todo comment

* improve gpo.h

* improve gpo.h

* update gpo.h

* clean up code in gpo.h

* fix build

* try to fix build

* xaml fix

* Fix getting string value from the registry

* communicate policy state suing settings.json

* various changes and gpo docs

* spell fixes

* PT Run: Policy handling

* spell fix

* fix logging

* fix admx revision

* revision fix 2

* review feedback 1

* review feedback 2

* dev docs update

* fix typo
This commit is contained in:
Heiko
2023-10-11 16:37:15 +02:00
committed by GitHub
parent 19827d0093
commit 602a3ff090
39 changed files with 377 additions and 15 deletions

View File

@@ -11,6 +11,8 @@ using System.IO.Abstractions;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using global::PowerToys.GPOWrapper;
using ManagedCommon;
using PowerLauncher.Properties;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
@@ -140,6 +142,25 @@ namespace PowerLauncher.Plugin
var failedPlugins = new ConcurrentQueue<PluginPair>();
Parallel.ForEach(AllPlugins, pair =>
{
// Check policy state for the plugin and update metadata
var enabledPolicyState = GPOWrapper.GetRunPluginEnabledValue(pair.Metadata.ID);
if (enabledPolicyState == GpoRuleConfigured.Enabled)
{
pair.Metadata.Disabled = false;
pair.Metadata.IsEnabledPolicyConfigured = true;
Log.Info($"The plugin <{pair.Metadata.Name}> is enabled by policy.", typeof(PluginManager));
}
else if (enabledPolicyState == GpoRuleConfigured.Disabled)
{
pair.Metadata.Disabled = true;
pair.Metadata.IsEnabledPolicyConfigured = true;
Log.Info($"The plugin <{pair.Metadata.Name}> is disabled by policy.", typeof(PluginManager));
}
else if (enabledPolicyState == GpoRuleConfigured.WrongValue)
{
Log.Warn($"Wrong policy value for enabled policy for plugin <{pair.Metadata.Name}>.", typeof(PluginManager));
}
if (pair.Metadata.Disabled)
{
return;

View File

@@ -9,6 +9,7 @@ using System.Linq;
using System.Threading;
using System.Windows.Input;
using Common.UI;
using global::PowerToys.GPOWrapper;
using Microsoft.PowerToys.Settings.UI.Library;
using PowerLauncher.Helper;
using PowerLauncher.Plugin;
@@ -242,6 +243,7 @@ namespace PowerLauncher
IconPathDark = GetIcon(x.Metadata, x.Metadata.IcoPathDark),
IconPathLight = GetIcon(x.Metadata, x.Metadata.IcoPathLight),
AdditionalOptions = x.Plugin is ISettingProvider ? (x.Plugin as ISettingProvider).AdditionalOptions : new List<PluginAdditionalOption>(),
EnabledPolicyUiState = (int)GpoRuleConfigured.NotConfigured,
});
}
@@ -256,11 +258,13 @@ namespace PowerLauncher
if (defaultPlugins.ContainsKey(plugin.Id))
{
var additionalOptions = CombineAdditionalOptions(defaultPlugins[plugin.Id].AdditionalOptions, plugin.AdditionalOptions);
var enabledPolicyState = GPOWrapper.GetRunPluginEnabledValue(plugin.Id);
plugin.Name = defaultPlugins[plugin.Id].Name;
plugin.Description = defaultPlugins[plugin.Id].Description;
plugin.Author = defaultPlugins[plugin.Id].Author;
plugin.IconPathDark = defaultPlugins[plugin.Id].IconPathDark;
plugin.IconPathLight = defaultPlugins[plugin.Id].IconPathLight;
plugin.EnabledPolicyUiState = (int)enabledPolicyState;
defaultPlugins[plugin.Id] = plugin;
defaultPlugins[plugin.Id].AdditionalOptions = additionalOptions;
}