Skip to content

Commit

Permalink
Fixed #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Seji64 committed Jul 26, 2023
1 parent b4dc005 commit bea9cad
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/Enums/LAPSVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{
public enum LAPSVersion
{
v1,
v2
All = 0,
v1 = 1,
v2 = 2
}
}
1 change: 1 addition & 0 deletions src/LAPS-WebUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="CliWrap" Version="3.6.4" />
<PackageReference Include="CurrieTechnologies.Razor.Clipboard" Version="1.6.0" />
<PackageReference Include="LdapForNet" Version="2.7.15" />
<PackageReference Include="Macross.Json.Extensions" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="7.0.9" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
Expand Down
4 changes: 3 additions & 1 deletion src/Models/LapsOptions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using LAPS_WebUI.Enums;
using System.Text.Json.Serialization;

namespace LAPS_WebUI.Models
{
public class LapsOptions
{
public LAPSVersion? ForceVersion { get; set; }
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public LAPSVersion ForceVersion { get; set; } = LAPSVersion.All;
public bool EncryptionDisabled { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/Pages/LAPS.razor
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
{
<MudTabs Position="Position.Top" Rounded="true" Border="false" ApplyEffectsToContainer="true" @ref="_tabs" PanelClass="pa-4">
<MudTabPanel Icon="@Icons.Material.Outlined.Filter1" ID="@("v1")" Text="v1" Disabled=@(!computer.LAPSInformations!.Any(x => x.Version == Enums.LAPSVersion.v1 && x.IsCurrent))>
<LapsInformationDetail LapsInfo="computer.LAPSInformations!.Single(x => x.Version == Enums.LAPSVersion.v1)" />
<LapsInformationDetail LapsInfo="computer.LAPSInformations!.SingleOrDefault(x => x.Version == Enums.LAPSVersion.v1)" />
</MudTabPanel>
<MudTabPanel Icon="@Icons.Material.Outlined.Filter2" ID="@("v2")" Text="v2" Disabled=@(!computer.LAPSInformations!.Any(x => x.Version == Enums.LAPSVersion.v2 && x.IsCurrent))>
<LapsInformationDetail LapsInfo="computer.LAPSInformations!.Single(x => x.Version == Enums.LAPSVersion.v2 && x.IsCurrent)" />
<LapsInformationDetail LapsInfo="computer.LAPSInformations!.SingleOrDefault(x => x.Version == Enums.LAPSVersion.v2 && x.IsCurrent)" />
</MudTabPanel>
<MudTabPanel Icon="@Icons.Material.Outlined.History" ID="@("history")" Text="History" Disabled=@(!computer.LAPSInformations!.Any(x => x.Version == Enums.LAPSVersion.v2 && !x.IsCurrent))>
<MudSimpleTable Style="overflow-x: auto;" Dense="true" Hover="true" Striped="true">
Expand Down
7 changes: 7 additions & 0 deletions src/Pages/LAPS.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ private async Task FetchComputerDetailsAsync(string computerName)
{
selectedComputer.LAPSInformations = AdComputerObject.LAPSInformations;
selectedComputer.FailedToRetrieveLAPSDetails = AdComputerObject.FailedToRetrieveLAPSDetails;

if (!selectedComputer.FailedToRetrieveLAPSDetails && _tabs != null)
{
await InvokeAsync(StateHasChanged);
_tabs.ActivatePanel(_tabs.Panels.First(x => !x.Disabled));
}

}
}
catch (Exception ex)
Expand Down
3 changes: 2 additions & 1 deletion src/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"LDAP__Server": "ldap.prime.k-sys.io",
"LDAP__Port": "636",
"LDAP__UseSSL": "true",
"LDAP__SearchBase": "OU=Klett IT GmbH,DC=prime,DC=k-sys,DC=io"
"LDAP__SearchBase": "OU=Klett IT GmbH,DC=prime,DC=k-sys,DC=io",
"LAPS__ForceVersion": "All"
},
"applicationUrl": "https://localhost:7213;http://localhost:5213",
"dotnetRunMessages": true
Expand Down
4 changes: 2 additions & 2 deletions src/Services/LDAPService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task<bool> TestCredentialsAsync(LdapCredential ldapCredential)

#region "Try LAPS v1"

if (ldapSearchResult.DirectoryAttributes.Any(x => x.Name == "ms-Mcs-AdmPwd") && (_lapsOptions.Value.ForceVersion is null || _lapsOptions.Value.ForceVersion == Enums.LAPSVersion.v1))
if (ldapSearchResult.DirectoryAttributes.Any(x => x.Name == "ms-Mcs-AdmPwd") && (_lapsOptions.Value.ForceVersion == Enums.LAPSVersion.All || _lapsOptions.Value.ForceVersion == Enums.LAPSVersion.v1))
{
LapsInformation lapsInformationEntry = new()
{
Expand All @@ -125,7 +125,7 @@ public async Task<bool> TestCredentialsAsync(LdapCredential ldapCredential)

string fieldName = (_lapsOptions.Value.EncryptionDisabled ? "msLAPS-Password" : "msLAPS-EncryptedPassword");

if (ldapSearchResult.DirectoryAttributes.Any(x => x.Name == fieldName) && (_lapsOptions.Value.ForceVersion is null || _lapsOptions.Value.ForceVersion == Enums.LAPSVersion.v2))
if (ldapSearchResult.DirectoryAttributes.Any(x => x.Name == fieldName) && (_lapsOptions.Value.ForceVersion == Enums.LAPSVersion.All || _lapsOptions.Value.ForceVersion == Enums.LAPSVersion.v2))
{
MsLAPSPayload? msLAPS_Payload = null;
string ldapValue = string.Empty;
Expand Down
6 changes: 3 additions & 3 deletions src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"SearchBase": "OU=Clients,DC=example,DC=com,"
},
"LAPS": {
"ForceVersion": "v1", # Allowed Values: v1, v2 | Default: null (both versions)
"EncryptionDisabled": false # Allowed Values: true, false | Default: false
}
"ForceVersion": "All", // Allowed Values: All, v1, v2 | Default: All (v1 & v2)
"EncryptionDisabled": false // Allowed Values: true, false | Default: false
},
"AllowedHosts": "*"
}

0 comments on commit bea9cad

Please sign in to comment.