Skip to content

Commit

Permalink
Fixes an issue where the schema status in the UI did not update after…
Browse files Browse the repository at this point in the history
… schema changes were deployed

Fixes an issue where UI trace events could not be logged
Fixes an issue where the JIT mode indicator did not update correctly when the AD PAM feature was enabled
  • Loading branch information
ryannewington committed Nov 29, 2020
1 parent 94953b7 commit a735d9f
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DOCUMENT Type="Advanced Installer" CreateVersion="17.3" version="17.6" Modules="professional" RootPath="." Language="en" Id="{6231D1B4-23AF-4C6E-998C-070D74534FAD}">
<DOCUMENT Type="Advanced Installer" CreateVersion="17.3" version="17.7" Modules="professional" RootPath="." Language="en" Id="{6231D1B4-23AF-4C6E-998C-070D74534FAD}">
<COMPONENT cid="caphyon.advinst.msicomp.MsiPropsComponent">
<ROW Property="AI_BITMAP_DISPLAY_MODE" Value="0"/>
<ROW Property="AI_PREDEF_LCONDS_PROPS" Value="AI_DETECTED_DOTNET_VERSION"/>
Expand All @@ -9,10 +9,10 @@
<ROW Property="ARPCOMMENTS" Value="This installer database contains the logic and data required to install [|ProductName]." ValueLocId="*"/>
<ROW Property="ARPPRODUCTICON" Value="accessmanager.exe" Type="8"/>
<ROW Property="Manufacturer" Value="Lithnet"/>
<ROW Property="ProductCode" Value="1033:{E13CC38C-FE60-467C-8922-5D8292FDFD21} " Type="16"/>
<ROW Property="ProductCode" Value="1033:{3D8F454D-7DBE-4304-B69B-8E779C8D12AE} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="Lithnet Access Manager Agent"/>
<ROW Property="ProductVersion" Value="1.0.7840.0" Type="32" TargetFile="Lithnet.AccessManager.Agent.exe"/>
<ROW Property="ProductVersion" Value="1.0.7846.0" Type="32" TargetFile="Lithnet.AccessManager.Agent.exe"/>
<ROW Property="SETUPEXEDIR" Value="1"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
<ROW Property="UpgradeCode" Value="{EEDECF4C-BABB-4AE0-9CB9-DC051FF1AE75}"/>
Expand Down Expand Up @@ -192,7 +192,7 @@
<ROW Path="&lt;AI_DICTS&gt;ui_en.ail"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.DigCertStoreComponent">
<ROW TimeStampUrl="http://timestamp.digicert.com" SignerDescription="[|ProductName]" SignOptions="7" SignTool="0" UseSha256="1" Thumbprint="578375f6d4d431d4049ce754ed0affdffe3a51a9 Subject: Lithnet&#10;Issuer: DigiCert SHA2 Assured ID Code Signing CA&#10;Valid from 09/12/2019 to 12/23/2020&#10;User\MY" Subject="CN=Lithnet, O=Lithnet, L=Chadstone, S=Victoria, C=AU"/>
<ROW TimeStampUrl="http://timestamp.digicert.com" SignerDescription="[|ProductName]" SignOptions="7" SignTool="0" UseSha256="1" Thumbprint="963b96e04c888e01267f46abbd2134c9eae9717b Subject: Lithnet&#10;Issuer: DigiCert SHA2 Assured ID Code Signing CA&#10;Valid from 10/26/2020 to 01/23/2024&#10;User\MY" Subject="CN=Lithnet, O=Lithnet, L=Chadstone, S=Victoria, C=AU"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.FragmentComponent">
<ROW Fragment="CommonUI.aip" Path="&lt;AI_FRAGS&gt;CommonUI.aip"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DOCUMENT Type="Advanced Installer" CreateVersion="17.3" version="17.6" Modules="professional" RootPath="." Language="en" Id="{6231D1B4-23AF-4C6E-998C-070D74534FAD}">
<DOCUMENT Type="Advanced Installer" CreateVersion="17.3" version="17.7" Modules="professional" RootPath="." Language="en" Id="{6231D1B4-23AF-4C6E-998C-070D74534FAD}">
<COMPONENT cid="caphyon.advinst.msicomp.MsiPropsComponent">
<ROW Property="AI_BITMAP_DISPLAY_MODE" Value="0"/>
<ROW Property="AI_PREDEF_LCONDS_PROPS" Value="AI_DETECTED_DOTNET_VERSION"/>
Expand All @@ -9,10 +9,10 @@
<ROW Property="ARPCOMMENTS" Value="This installer database contains the logic and data required to install [|ProductName]." ValueLocId="*"/>
<ROW Property="ARPPRODUCTICON" Value="accessmanager.exe" Type="8"/>
<ROW Property="Manufacturer" Value="Lithnet"/>
<ROW Property="ProductCode" Value="1033:{9384B7BC-D126-40E1-BADD-77205C8F764B} " Type="16"/>
<ROW Property="ProductCode" Value="1033:{E225E6ED-F53E-43F9-8448-4856FEEF9165} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="Lithnet Access Manager Agent"/>
<ROW Property="ProductVersion" Value="1.0.7840.0" Type="32" TargetFile="Lithnet.AccessManager.Agent.exe"/>
<ROW Property="ProductVersion" Value="1.0.7846.0" Type="32" TargetFile="Lithnet.AccessManager.Agent.exe"/>
<ROW Property="SETUPEXEDIR" Value="1"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
<ROW Property="UpgradeCode" Value="{EEDECF4C-BABB-4AE0-9CB9-DC051FF1AE75}"/>
Expand Down Expand Up @@ -191,7 +191,7 @@
<ROW Path="&lt;AI_DICTS&gt;ui_en.ail"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.DigCertStoreComponent">
<ROW TimeStampUrl="http://timestamp.digicert.com" SignerDescription="[|ProductName]" SignOptions="7" SignTool="0" UseSha256="1" Thumbprint="578375f6d4d431d4049ce754ed0affdffe3a51a9 Subject: Lithnet&#10;Issuer: DigiCert SHA2 Assured ID Code Signing CA&#10;Valid from 09/12/2019 to 12/23/2020&#10;User\MY" Subject="CN=Lithnet, O=Lithnet, L=Chadstone, S=Victoria, C=AU"/>
<ROW TimeStampUrl="http://timestamp.digicert.com" SignerDescription="[|ProductName]" SignOptions="7" SignTool="0" UseSha256="1" Thumbprint="963b96e04c888e01267f46abbd2134c9eae9717b Subject: Lithnet&#10;Issuer: DigiCert SHA2 Assured ID Code Signing CA&#10;Valid from 10/26/2020 to 01/23/2024&#10;User\MY" Subject="CN=Lithnet, O=Lithnet, L=Chadstone, S=Victoria, C=AU"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.FragmentComponent">
<ROW Fragment="CommonUI.aip" Path="&lt;AI_FRAGS&gt;CommonUI.aip"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ private List<SecurityDescriptorTarget> ConvertToTargets(OUPrincipalMapping entry

private void PopulateTargets(OUPrincipalMapping entry, List<SecurityDescriptorTarget> targets)
{
this.logger.LogTrace("Processing OU {ou}", entry.AdsPath);

bool doNotConsolidate = settings.DoNotConsolidate || (settings.DoNotConsolidateOnError && entry.HasDescendantsWithErrors);

if (!doNotConsolidate)
Expand Down Expand Up @@ -70,6 +72,8 @@ private void PopulateTargets(OUPrincipalMapping entry, List<SecurityDescriptorTa

private SecurityDescriptorTarget ConvertToTarget(ComputerPrincipalMapping computer, HashSet<SecurityIdentifier> admins)
{
this.logger.LogTrace("Converting computer {computer} to target with {admins} admins", computer.PrincipalName, admins.Count);

SecurityDescriptorTarget target = new SecurityDescriptorTarget()
{
AuthorizationMode = AuthorizationMode.SecurityDescriptor,
Expand Down Expand Up @@ -111,6 +115,8 @@ private SecurityDescriptorTarget ConvertToTarget(ComputerPrincipalMapping comput

private SecurityDescriptorTarget ConvertToTarget(OUPrincipalMapping entry)
{
this.logger.LogTrace("Converting OU {ou} to target with {admins} admins", entry.AdsPath, entry.UniquePrincipals.Count);

SecurityDescriptorTarget target = new SecurityDescriptorTarget()
{
AuthorizationMode = AuthorizationMode.SecurityDescriptor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ public class Bootstrapper : Bootstrapper<MainWindowViewModel>

private IApplicationConfig appconfig;

private static void SetupNLog()
{
RegistryProvider provider = new RegistryProvider(false);
private UiRegistryProvider registryProvider;

private void SetupNLog()
{
var configuration = new NLog.Config.LoggingConfiguration();

var uiLog = new NLog.Targets.FileTarget("access-manager-ui")
{
FileName = Path.Combine(provider.LogPath, "access-manager-ui.log"),
FileName = Path.Combine(registryProvider.LogPath, "access-manager-ui.log"),
ArchiveEvery = NLog.Targets.FileArchivePeriod.Day,
ArchiveNumbering = NLog.Targets.ArchiveNumberingMode.Date,
MaxArchiveFiles = provider.RetentionDays,
MaxArchiveFiles = registryProvider.RetentionDays,
Layout = "${longdate}|${level:uppercase=true:padding=5}|${logger}|${message}${onexception:inner=${newline}${exception:format=ToString}}"
};

Expand All @@ -51,18 +51,20 @@ private static void SetupNLog()

public Bootstrapper()
{
this.registryProvider = new UiRegistryProvider();

SetupNLog();

loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddNLog();
builder.SetMinimumLevel(LogLevel.Information);
builder.SetMinimumLevel(this.registryProvider.UiLogLevel);
builder.AddDebug();
builder.AddEventLog(new EventLogSettings()
{
SourceName = Constants.EventSourceName,
LogName = Constants.EventLogName,
Filter = (x, y) => y >= LogLevel.Warning
Filter = (x, y) => y >= this.registryProvider.UiEventLogLevel
});
});

Expand All @@ -86,9 +88,9 @@ protected override void OnExit(ExitEventArgs e)

base.OnExit(e);
}

protected override void ConfigureIoC(IStyletIoCBuilder builder)
{
RegistryProvider registryProvider = new RegistryProvider(true);
IAppPathProvider pathProvider = new AppPathProvider(registryProvider);

try
Expand All @@ -113,13 +115,13 @@ protected override void ConfigureIoC(IStyletIoCBuilder builder)

if (!File.Exists(pathProvider.ConfigFile))
{
this.logger.LogError(EventIDs.UIGenericError, "Config file was not found at path {path}", pathProvider.ConfigFile);
this.logger.LogCritical(EventIDs.UIGenericError, "Config file was not found at path {path}", pathProvider.ConfigFile);
throw new MissingConfigurationException($"The appsettings.config file could not be found at path {pathProvider.ConfigFile}. Please resolve the issue and restart the application");
}

if (!File.Exists(pathProvider.HostingConfigFile))
{
this.logger.LogError(EventIDs.UIGenericError, "Apphost file was not found at path {path}", pathProvider.HostingConfigFile);
this.logger.LogCritical(EventIDs.UIGenericError, "Apphost file was not found at path {path}", pathProvider.HostingConfigFile);
throw new MissingConfigurationException($"The apphost.config file could not be found at path {pathProvider.HostingConfigFile}. Please resolve the issue and restart the application");
}

Expand Down Expand Up @@ -210,12 +212,12 @@ protected override void ConfigureIoC(IStyletIoCBuilder builder)
}
catch (ApplicationInitializationException ex)
{
this.logger.LogError(EventIDs.UIInitializationError, ex, "Initialization error");
this.logger.LogCritical(EventIDs.UIInitializationError, ex, "Initialization error");
throw;
}
catch (Exception ex)
{
this.logger.LogError(EventIDs.UIInitializationError, ex, "Initialization error");
this.logger.LogCritical(EventIDs.UIInitializationError, ex, "Initialization error");
throw new ApplicationInitializationException("The application failed to initialize", ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;

namespace Lithnet.AccessManager.Server.UI.Providers
{
internal class UiRegistryProvider : RegistryProvider
{
public UiRegistryProvider() : base(true)
{
}

public LogLevel UiLogLevel => (LogLevel)(baseKey?.GetValue("UiLogLevel", 0) as int? ?? (int)LogLevel.Information);

public LogLevel UiEventLogLevel => (LogLevel)(baseKey?.GetValue("UiEventLogLevel", 0) as int? ?? (int)LogLevel.Critical);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void PopulateLithnetSchemaStatus()
this.IsLithnetSchemaPresent = false;
this.IsNotLithnetSchemaPresent = false;

if (this.discoveryServices.DoesSchemaAttributeExist(this.Forest.Name, "lithnetAdminPassword"))
if (this.discoveryServices.DoesSchemaAttributeExist(this.Forest.Name, "lithnetAdminPassword", true))
{
this.IsLithnetSchemaPresent = true;
this.LithnetAccessManagerSchemaPresentText = "Present";
Expand Down Expand Up @@ -102,7 +102,7 @@ private void PopulateMsLapsSchemaStatus()
this.IsMsLapsSchemaPresent = false;
this.IsNotMsLapsSchemaPresent = false;

if (this.discoveryServices.DoesSchemaAttributeExist(this.Forest.Name, "ms-Mcs-AdmPwd"))
if (this.discoveryServices.DoesSchemaAttributeExist(this.Forest.Name, "ms-Mcs-AdmPwd", true))
{
this.IsMsLapsSchemaPresent = true;
this.MsLapsSchemaPresentText = "Present";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ await Task.Run(() =>
{
this.IsPamNotSupported = false;
this.IsPamEnabled = false;
this.IsPamEnabled = false;
this.IsPamSupported = false;
#if DEBUG
if (Mapping?.OverrideMode == 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ public SecurityIdentifierViewModel(string sidString, IDirectory directory)

public SecurityIdentifierViewModel(SecurityIdentifier sid, IDirectory directory)
{
this.directory = directory;

this.SecurityIdentifier = sid;
this.DisplayName = this.GetSidDisplayName(sid);
this.Sid = sid.ToString();
this.directory = directory;
}

public SecurityIdentifier SecurityIdentifier { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public interface IRegistryProvider

string BasePath { get; }

string ServiceKeyThumbprint { get; set; }
int CacheMode { get; set; }

bool DeleteLocalDbInstance { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using Microsoft.Win32;
using System;
using System.IO;
using System.Text;
using Microsoft.Win32;

namespace Lithnet.AccessManager.Server
{
Expand All @@ -12,8 +10,8 @@ public class RegistryProvider : IRegistryProvider

public const string ParametersKey = "Software\\Lithnet\\Access Manager Service\\Parameters";

private readonly RegistryKey baseKey;
private readonly RegistryKey paramsKey;
protected readonly RegistryKey baseKey;
protected readonly RegistryKey paramsKey;

public RegistryProvider(bool writable)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DOCUMENT Type="Advanced Installer" CreateVersion="17.1.2" version="17.6" Modules="enterprise" RootPath="." Language="en" Id="{8ADA5C46-1F9D-45B3-A39D-37B0D337D0DD}">
<DOCUMENT Type="Advanced Installer" CreateVersion="17.1.2" version="17.7" Modules="enterprise" RootPath="." Language="en" Id="{8ADA5C46-1F9D-45B3-A39D-37B0D337D0DD}">
<COMPONENT cid="caphyon.advinst.msicomp.ProjectOptionsComponent">
<ROW Name="MigrationUninstallCode" Value="{D17AC68C-2F91-4344-A3BF-B13404566A40}"/>
</COMPONENT>
Expand All @@ -18,10 +18,10 @@
<ROW Property="IAgree" Value="No" Type="4" MsiKey="IAgree"/>
<ROW Property="Manufacturer" Value="Lithnet"/>
<ROW Property="NO_USER_CHECK" Comments="Skips checking username"/>
<ROW Property="ProductCode" Value="1033:{FCB09ABF-EB7A-43CA-B1CA-EEEC669EF95F} " Type="16"/>
<ROW Property="ProductCode" Value="1033:{442F6404-8087-4E76-B9C3-542DDDAE189E} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="Lithnet Access Manager Service"/>
<ROW Property="ProductVersion" Value="1.0.7840.0" Type="32" TargetFile="Lithnet.AccessManager.Service.exe"/>
<ROW Property="ProductVersion" Value="1.0.7846.0" Type="32" TargetFile="Lithnet.AccessManager.Service.exe"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
<ROW Property="UpgradeCode" Value="{D17AC68C-2F91-4344-A3BF-B13404566A40}"/>
<ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>
Expand Down Expand Up @@ -1037,7 +1037,7 @@
<ROW Path="&lt;AI_DICTS&gt;ui_en.ail"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.DigCertStoreComponent">
<ROW TimeStampUrl="http://timestamp.digicert.com" SignerDescription="[|ProductName]" SignOptions="7" SignTool="0" UseSha256="1" Thumbprint="578375f6d4d431d4049ce754ed0affdffe3a51a9 Subject: Lithnet&#10;Issuer: DigiCert SHA2 Assured ID Code Signing CA&#10;Valid from 09/12/2019 to 12/23/2020&#10;User\MY" Subject="CN=Lithnet, O=Lithnet, L=Chadstone, S=Victoria, C=AU"/>
<ROW TimeStampUrl="http://timestamp.digicert.com" SignerDescription="[|ProductName]" SignOptions="7" SignTool="0" UseSha256="1" Thumbprint="963b96e04c888e01267f46abbd2134c9eae9717b Subject: Lithnet&#10;Issuer: DigiCert SHA2 Assured ID Code Signing CA&#10;Valid from 10/26/2020 to 01/23/2024&#10;User\MY" Subject="CN=Lithnet, O=Lithnet, L=Chadstone, S=Victoria, C=AU"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.FragmentComponent">
<ROW Fragment="CommonUI.aip" Path="&lt;AI_FRAGS&gt;CommonUI.aip"/>
Expand Down
Loading

0 comments on commit a735d9f

Please sign in to comment.