Update to .NET 8 and VSCode build
This commit is contained in:
0
LDIFTools.sln
Executable file → Normal file
0
LDIFTools.sln
Executable file → Normal file
9
LDIFTools/LDIFTools.csproj
Executable file → Normal file
9
LDIFTools/LDIFTools.csproj
Executable file → Normal file
@@ -1,15 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="input.ldif">
|
<None Update="input.ldif">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
49
LDIFTools/Program.cs
Executable file → Normal file
49
LDIFTools/Program.cs
Executable file → Normal file
@@ -1,5 +1,4 @@
|
|||||||
using System.Net.NetworkInformation;
|
using System.Text;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace LDIFTools
|
namespace LDIFTools
|
||||||
{
|
{
|
||||||
@@ -8,16 +7,16 @@ namespace LDIFTools
|
|||||||
static string? InputFilename = null;
|
static string? InputFilename = null;
|
||||||
static string? OutputFilename = null;
|
static string? OutputFilename = null;
|
||||||
|
|
||||||
static List<string> FileStart = new();
|
static readonly List<string> FileStart = [];
|
||||||
static SortedList<string, List<string>> SortedDNs = new();
|
static readonly SortedList<string, List<string>> SortedDNs = [];
|
||||||
static List<List<string>> NotSortedDNs = new();
|
static readonly List<List<string>> NotSortedDNs = [];
|
||||||
static bool SortDNs = false;
|
static bool SortDNs = false;
|
||||||
static bool RemoveComments = false;
|
static bool RemoveComments = false;
|
||||||
static List<string> KeepStrings = new();
|
static readonly List<string> KeepStrings = [];
|
||||||
static List<string> RemoveStrings = new();
|
static readonly List<string> RemoveStrings = [];
|
||||||
static bool UseLongLines = false;
|
static bool UseLongLines = false;
|
||||||
static List<string> AttrsToRemove = new();
|
static readonly List<string> AttrsToRemove = [];
|
||||||
static string DefaultAttrsToRemove = "showInAdvancedViewOnly,objectGUID,instanceType,dsCorePropagationData,distinguishedName,whenCreated,whenChanged,uSNCreated,uSNChanged,name,objectCategory";
|
static readonly string DefaultAttrsToRemove = "showInAdvancedViewOnly,objectGUID,instanceType,dsCorePropagationData,distinguishedName,whenCreated,whenChanged,uSNCreated,uSNChanged,name,objectCategory";
|
||||||
static bool SortVISConfigItems = false;
|
static bool SortVISConfigItems = false;
|
||||||
static bool UppercaseVISConfigItems = false;
|
static bool UppercaseVISConfigItems = false;
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ namespace LDIFTools
|
|||||||
ConsoleKeyInfo key = Console.ReadKey();
|
ConsoleKeyInfo key = Console.ReadKey();
|
||||||
Console.WriteLine("\n");
|
Console.WriteLine("\n");
|
||||||
|
|
||||||
if (key.KeyChar.ToString().ToLower() != "y")
|
if (!key.KeyChar.ToString().Equals("y", StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
Console.WriteLine("No changes made");
|
Console.WriteLine("No changes made");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -280,12 +279,12 @@ namespace LDIFTools
|
|||||||
static void ReadInputFile(string inputFilename)
|
static void ReadInputFile(string inputFilename)
|
||||||
{
|
{
|
||||||
bool startOfFile = true;
|
bool startOfFile = true;
|
||||||
List<string> currentBlock = new();
|
List<string> currentBlock = [];
|
||||||
string currentDN = "";
|
string currentDN = "";
|
||||||
|
|
||||||
foreach (string line in File.ReadLines(inputFilename))
|
foreach (string line in File.ReadLines(inputFilename))
|
||||||
{
|
{
|
||||||
if (line.ToLower().StartsWith("dn:") && line.Trim().Length > 4)
|
if (line.StartsWith("dn:", StringComparison.InvariantCultureIgnoreCase) && line.Trim().Length > 4)
|
||||||
{
|
{
|
||||||
//We have a new dn block to read
|
//We have a new dn block to read
|
||||||
|
|
||||||
@@ -303,10 +302,10 @@ namespace LDIFTools
|
|||||||
|
|
||||||
//Start building a new block of lines
|
//Start building a new block of lines
|
||||||
currentDN = ReverseDN(line.Trim().Replace("dn:", "").Trim().ToLower());
|
currentDN = ReverseDN(line.Trim().Replace("dn:", "").Trim().ToLower());
|
||||||
currentBlock = new()
|
currentBlock =
|
||||||
{
|
[
|
||||||
line
|
line
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
else if (startOfFile)
|
else if (startOfFile)
|
||||||
{
|
{
|
||||||
@@ -314,9 +313,9 @@ namespace LDIFTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!(RemoveComments && line.Trim().StartsWith("#")))
|
if (!(RemoveComments && line.Trim().StartsWith('#')))
|
||||||
{
|
{
|
||||||
if (UseLongLines && line.StartsWith(" "))
|
if (UseLongLines && line.StartsWith(' '))
|
||||||
{
|
{
|
||||||
//append line (without starting space) to last line read from file
|
//append line (without starting space) to last line read from file
|
||||||
currentBlock[^1] += line[1..];
|
currentBlock[^1] += line[1..];
|
||||||
@@ -339,13 +338,13 @@ namespace LDIFTools
|
|||||||
|
|
||||||
static List<string> FilterAttrs(List<string> dnBlock)
|
static List<string> FilterAttrs(List<string> dnBlock)
|
||||||
{
|
{
|
||||||
List<string> result = new();
|
List<string> result = [];
|
||||||
foreach (string line in dnBlock)
|
foreach (string line in dnBlock)
|
||||||
{
|
{
|
||||||
bool save = true;
|
bool save = true;
|
||||||
foreach (string attr in AttrsToRemove)
|
foreach (string attr in AttrsToRemove)
|
||||||
{
|
{
|
||||||
if (line.ToLower().StartsWith(attr.ToLower() + ":"))
|
if (line.StartsWith(attr + ":", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
save = false;
|
save = false;
|
||||||
break;
|
break;
|
||||||
@@ -361,8 +360,8 @@ namespace LDIFTools
|
|||||||
|
|
||||||
static List<string> CleanupVISConfigItems(List<string> dnBlock)
|
static List<string> CleanupVISConfigItems(List<string> dnBlock)
|
||||||
{
|
{
|
||||||
List<string> result = new();
|
List<string> result = [];
|
||||||
SortedList<string, string> configItems = new();
|
SortedList<string, string> configItems = [];
|
||||||
int startsAt = -1;
|
int startsAt = -1;
|
||||||
|
|
||||||
if (!SortVISConfigItems) return dnBlock;
|
if (!SortVISConfigItems) return dnBlock;
|
||||||
@@ -370,13 +369,13 @@ namespace LDIFTools
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
foreach (string line in dnBlock)
|
foreach (string line in dnBlock)
|
||||||
{
|
{
|
||||||
if (line.ToLower().StartsWith("vis-configurationitem:"))
|
if (line.StartsWith("vis-configurationitem:", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
if (startsAt == -1) startsAt = counter;
|
if (startsAt == -1) startsAt = counter;
|
||||||
|
|
||||||
string lineToClean;
|
string lineToClean;
|
||||||
bool base64 = false;
|
bool base64 = false;
|
||||||
if (line.ToLower().StartsWith("vis-configurationitem::"))
|
if (line.StartsWith("vis-configurationitem::", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
//Base64 encoded attribute
|
//Base64 encoded attribute
|
||||||
base64 = true;
|
base64 = true;
|
||||||
@@ -436,7 +435,7 @@ namespace LDIFTools
|
|||||||
{
|
{
|
||||||
foreach (string keepString in KeepStrings)
|
foreach (string keepString in KeepStrings)
|
||||||
{
|
{
|
||||||
if (dnLine.ToLower().Contains(keepString.ToLower()))
|
if (dnLine.Contains(keepString, StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
keep = true;
|
keep = true;
|
||||||
break;
|
break;
|
||||||
@@ -452,7 +451,7 @@ namespace LDIFTools
|
|||||||
{
|
{
|
||||||
foreach (string removeString in RemoveStrings)
|
foreach (string removeString in RemoveStrings)
|
||||||
{
|
{
|
||||||
if (dnLine.ToLower().Contains(removeString.ToLower()))
|
if (dnLine.Contains(removeString, StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
remove = true;
|
remove = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
|
||||||
-->
|
|
||||||
<Project>
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Any CPU</Platform>
|
|
||||||
<PublishDir>bin\Release\net7.0\publish\osx-arm64\</PublishDir>
|
|
||||||
<PublishProtocol>FileSystem</PublishProtocol>
|
|
||||||
<_TargetId>Folder</_TargetId>
|
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
|
||||||
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
|
|
||||||
<SelfContained>true</SelfContained>
|
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
|
||||||
<PublishTrimmed>true</PublishTrimmed>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
|
||||||
-->
|
|
||||||
<Project>
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Any CPU</Platform>
|
|
||||||
<PublishDir>bin\Release\net7.0\publish\win-x64\</PublishDir>
|
|
||||||
<PublishProtocol>FileSystem</PublishProtocol>
|
|
||||||
<_TargetId>Folder</_TargetId>
|
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
|
||||||
<SelfContained>true</SelfContained>
|
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
|
||||||
<PublishReadyToRun>true</PublishReadyToRun>
|
|
||||||
<PublishTrimmed>true</PublishTrimmed>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
0
LDIFTools/input.ldif
Executable file → Normal file
0
LDIFTools/input.ldif
Executable file → Normal file
2
publish.cmd
Executable file
2
publish.cmd
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
dotnet publish --configuration Release --runtime osx-x64
|
||||||
|
dotnet publish --configuration Release --runtime win-x64
|
||||||
Reference in New Issue
Block a user