Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demo/Bitai.LDAPHelper.Demo/Bitai.LDAPHelper.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<Copyright>© 2026 BITAI. All rights reserved.</Copyright>
<PackageId>Bitai.Bitai.LDAPHelper.Demo</PackageId>
<PackageIcon>hierarchy_32.png</PackageIcon>
<Version>10.0.1</Version>
<AssemblyVersion>10.0.1</AssemblyVersion>
<FileVersion>10.0.1</FileVersion>
<Version>10.0.2</Version>
<AssemblyVersion>10.0.2</AssemblyVersion>
<FileVersion>10.0.2</FileVersion>
<PackageReleaseNotes>.NET 10 ready</PackageReleaseNotes>
<PackageTags>ldap-ad-identity-auth-openid-oauth-security</PackageTags>
</PropertyGroup>
Expand Down
36 changes: 35 additions & 1 deletion demo/Bitai.LDAPHelper.Demo/DemoContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,29 @@

namespace Bitai.LDAPHelper.Demo;

/// <summary>
/// Holds runtime context and resolved settings for demo execution.
/// </summary>
public class DemoContext
{
/// <summary>
/// Gets or sets which LDAP implementation to use.
/// </summary>
public ImplementationType Implementation { get; set; }

/// <summary>
/// Gets or sets the connection-factory implementation used by demos.
/// </summary>
public ILdapConnectionFactoryAdapter ConnectionFactory { get; set; }

/// <summary>
/// Gets or sets loaded demo configuration.
/// </summary>
public DemoSetup Configuration { get; set; }

/// <summary>
/// Gets or sets the request label used by demo operations.
/// </summary>
public string RequestLabel { get; set; } = "My Demo";

// Connection settings
Expand All @@ -19,6 +37,10 @@ public class DemoContext
public string SelectedDomainAccountPassword { get; set; }
public string SelectedBaseDN { get; set; }

/// <summary>
/// Builds a <see cref="ConnectionInfo"/> instance from selected demo settings.
/// </summary>
/// <returns>Connection settings.</returns>
public ConnectionInfo GetConnectionInfo()
{
return new ConnectionInfo(
Expand All @@ -28,6 +50,10 @@ public ConnectionInfo GetConnectionInfo()
SelectedConnectionTimeout);
}

/// <summary>
/// Builds a domain-account credential from selected demo settings.
/// </summary>
/// <returns>Domain-account credential.</returns>
public LDAPDomainAccountCredential GetDomainAccountCredential()
{
var parts = SelectedDomainAccountName.Split(new char[] { '\\' });
Expand All @@ -37,6 +63,10 @@ public LDAPDomainAccountCredential GetDomainAccountCredential()
SelectedDomainAccountPassword);
}

/// <summary>
/// Builds search limits from selected demo settings.
/// </summary>
/// <returns>Search-limit settings.</returns>
public SearchLimits GetSearchLimits()
{
return new SearchLimits(SelectedBaseDN)
Expand All @@ -46,11 +76,15 @@ public SearchLimits GetSearchLimits()
};
}

/// <summary>
/// Builds a full client configuration from selected demo settings.
/// </summary>
/// <returns>Client configuration for helper classes.</returns>
public ClientConfiguration GetClientConfiguration()
{
return new ClientConfiguration(
GetConnectionInfo(),
GetDomainAccountCredential(),
GetSearchLimits());
}
}
}
34 changes: 33 additions & 1 deletion demo/Bitai.LDAPHelper.Demo/DemoSetup.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
namespace Bitai.LDAPHelper.Demo;
namespace Bitai.LDAPHelper.Demo;

/// <summary>
/// Selects the LDAP implementation used by demo scenarios.
/// </summary>
public enum ImplementationType {
Novell,
Mock
}

/// <summary>
/// Represents configuration values used by demo scenarios.
/// </summary>
public class DemoSetup
{
/// <summary>
/// Gets or sets available LDAP server endpoints for selection.
/// </summary>
public Ldapserver[] LdapServers { get; set; }

/// <summary>
/// Gets or sets available Base DN values for selection.
/// </summary>
public Basedn[] BaseDNs { get; set; }

/// <summary>
/// Gets or sets default LDAP connection timeout in seconds.
/// </summary>
public short ConnectionTimeout { get; set; }

/// <summary>
/// Gets or sets the domain account used as operator account during demo execution.
/// </summary>
public string DomainUserAccountForRunTests { get; set; }

public bool Demo_AccountManager_CreateUserAccount_RunTest { get; set; }
Expand Down Expand Up @@ -57,12 +77,24 @@ public class DemoSetup
public string Demo_GroupMembershipValidator_CheckGroupmembership_Check_GroupName { get; set; }
}

/// <summary>
/// Represents an LDAP server option in demo configuration.
/// </summary>
public class Ldapserver
{
/// <summary>
/// Gets or sets the LDAP server address.
/// </summary>
public string Address { get; set; }
}

/// <summary>
/// Represents a Base DN option in demo configuration.
/// </summary>
public class Basedn
{
/// <summary>
/// Gets or sets the base distinguished name.
/// </summary>
public string DN { get; set; }
}
14 changes: 13 additions & 1 deletion demo/Bitai.LDAPHelper.Demo/DemoSummary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

namespace Bitai.LDAPHelper.Demo;

/// <summary>
/// Collects and prints summary information for executed demo scenarios.
/// </summary>
public class DemoSummary
{
private readonly Dictionary<string, bool> _demoResults = new Dictionary<string, bool>();
private readonly List<string> _errors = new List<string>();

/// <summary>
/// Records the result of one demo scenario.
/// </summary>
/// <param name="demoName">Scenario name.</param>
/// <param name="success">Whether the scenario succeeded.</param>
/// <param name="error">Optional error associated with failure.</param>
public void RecordDemoResult(string demoName, bool success, Exception error = null)
{
_demoResults[demoName] = success;
Expand All @@ -18,6 +27,9 @@ public void RecordDemoResult(string demoName, bool success, Exception error = nu
}
}

/// <summary>
/// Prints an aggregated summary for all recorded demo results.
/// </summary>
public void PrintSummary()
{
Console.WriteLine();
Expand Down Expand Up @@ -60,4 +72,4 @@ public void PrintSummary()

Console.WriteLine("================================================");
}
}
}
6 changes: 3 additions & 3 deletions src/Bitai.LDAPHelper.DTO/Bitai.LDAPHelper.DTO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<AssemblyVersion>10.0.0</AssemblyVersion>
<FileVersion>10.0.0</FileVersion>
<Version>10.0.0</Version>
<AssemblyVersion>10.0.1</AssemblyVersion>
<FileVersion>10.0.1</FileVersion>
<Version>10.0.1</Version>
<AssemblyName>Bitai.LDAPHelper.DTO</AssemblyName>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Viko Bastidas (BITAI)</Authors>
Expand Down
8 changes: 7 additions & 1 deletion src/Bitai.LDAPHelper.DTO/Enums.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;

namespace Bitai.LDAPHelper.DTO
{
/// <summary>
/// LDAP entry attributes that can be loaded or filtered.
/// </summary>
public enum EntryAttribute
{
/// <summary>
Expand Down Expand Up @@ -41,6 +44,9 @@ public enum EntryAttribute
userAccountControl
}

/// <summary>
/// Predefined attribute sets used by search operations.
/// </summary>
public enum RequiredEntryAttributes
{
Minimun,
Expand Down
10 changes: 9 additions & 1 deletion src/Bitai.LDAPHelper.DTO/ISecureCloningCredential.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bitai.LDAPHelper.DTO
{
/// <summary>
/// Defines secure cloning behavior used to remove or mask sensitive credential values.
/// </summary>
/// <typeparam name="T">Credential type returned by the secure clone operation.</typeparam>
internal interface ISecureCloningCredential<T>
{
/// <summary>
/// Creates a secure clone suitable for logging or transport without exposing secrets.
/// </summary>
/// <returns>A cloned credential with sensitive data removed or masked.</returns>
T SecureClone();
}
}
21 changes: 20 additions & 1 deletion src/Bitai.LDAPHelper.DTO/LDAPCreateMsADUserAccountResult.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bitai.LDAPHelper.DTO
{
/// <summary>
/// Represents the result of an MS Active Directory user-account creation operation.
/// </summary>
public class LDAPCreateMsADUserAccountResult : LDAPOperationResult
{
/// <summary>
/// Gets or sets the created user account payload.
/// </summary>
public LDAPMsADUserAccount UserAccount { get; set; }


Expand All @@ -21,6 +27,13 @@ public LDAPCreateMsADUserAccountResult()
//Do not remove this constructor, it is required to deserialize data.
}

/// <summary>
/// Initializes a result for user-account creation.
/// </summary>
/// <param name="newUserAccount">Created user account data.</param>
/// <param name="requestLabel">Optional request label.</param>
/// <param name="operationMessage">Operation message.</param>
/// <param name="isSuccessfulOperation">Whether the operation is marked successful.</param>
public LDAPCreateMsADUserAccountResult(LDAPMsADUserAccount newUserAccount, string requestLabel = null, string operationMessage = "Operation completed", bool isSuccessfulOperation = true) : base(requestLabel, isSuccessfulOperation)
{
if (newUserAccount == null)
Expand All @@ -30,6 +43,12 @@ public LDAPCreateMsADUserAccountResult(LDAPMsADUserAccount newUserAccount, strin
OperationMessage = operationMessage;
}

/// <summary>
/// Initializes an unsuccessful creation result from an exception.
/// </summary>
/// <param name="operationMessage">Operation message.</param>
/// <param name="exception">Underlying error.</param>
/// <param name="requestLabel">Optional request label.</param>
public LDAPCreateMsADUserAccountResult(string operationMessage, Exception exception, string requestLabel = null) : base(operationMessage, exception, requestLabel)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bitai.LDAPHelper.DTO
{
/// <summary>
/// Represents the result of a user-account disable operation.
/// </summary>
public class LDAPDisableUserAccountOperationResult : LDAPOperationResult
{
/// <summary>
Expand All @@ -16,10 +19,21 @@ public LDAPDisableUserAccountOperationResult()
//Do not remove this constructor, it is required to deserialize data.
}

/// <summary>
/// Initializes a result for a disable operation.
/// </summary>
/// <param name="requestLabel">Optional request label.</param>
/// <param name="isSuccessfulOperation">Whether the operation is marked successful.</param>
public LDAPDisableUserAccountOperationResult(string requestLabel = null, bool isSuccessfulOperation = true) : base(requestLabel, isSuccessfulOperation)
{
}

/// <summary>
/// Initializes an unsuccessful disable-operation result from an exception.
/// </summary>
/// <param name="operationMessage">Operation message.</param>
/// <param name="exception">Underlying error.</param>
/// <param name="requestLabel">Optional request label.</param>
public LDAPDisableUserAccountOperationResult(string operationMessage, Exception exception, string requestLabel = null) : base(operationMessage, exception, requestLabel)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net;
using System.Net;
using System;

namespace Bitai.LDAPHelper.DTO;
Expand All @@ -9,6 +9,9 @@ namespace Bitai.LDAPHelper.DTO;
/// </summary>
public class LDAPDistinguishedNameAuthenticationResult: LDAPOperationResult
{
/// <summary>
/// Gets or sets the credential associated with this authentication attempt.
/// </summary>
public LDAPDistinguishedNameCredential Credential { get; set; }

/// <summary>
Expand All @@ -28,15 +31,29 @@ public LDAPDistinguishedNameAuthenticationResult()
//Do not remove this constructor, it is required to deserialize data.
}

/// <summary>
/// Initializes an authentication result.
/// </summary>
/// <param name="credential">Credential associated with the authentication attempt.</param>
/// <param name="isAuthenticated">Authentication status.</param>
/// <param name="requestLabel">Optional request label.</param>
/// <param name="isSuccessfulOperation">Whether the operation is marked successful.</param>
public LDAPDistinguishedNameAuthenticationResult(LDAPDistinguishedNameCredential credential, bool isAuthenticated = true, string requestLabel = null, bool isSuccessfulOperation = true) : base(requestLabel, isSuccessfulOperation)
{
Credential = credential;
IsAuthenticated = isAuthenticated;
}

/// <summary>
/// Initializes an unsuccessful authentication result from an exception.
/// </summary>
/// <param name="credential">Credential associated with the authentication attempt.</param>
/// <param name="operationMessage">Operation message.</param>
/// <param name="exception">Underlying error.</param>
/// <param name="requestLabel">Optional request label.</param>
public LDAPDistinguishedNameAuthenticationResult(LDAPDistinguishedNameCredential credential, string operationMessage, Exception exception, string requestLabel = null) : base(operationMessage, exception, requestLabel)
{
Credential = credential;
IsAuthenticated = false;
}
}
}
Loading
Loading