diff --git a/src/Bitai.LDAPHelper.LdapAdapters/Bitai.LDAPHelper.LdapAdapters.csproj b/src/Bitai.LDAPHelper.LdapAdapters/Bitai.LDAPHelper.LdapAdapters.csproj deleted file mode 100644 index 7396c7a..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/Bitai.LDAPHelper.LdapAdapters.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - net10.0 - enable - enable - Bitai.LDAPHelper.LdapAdapters - 10.0.0 - Victor Bastidas (BITAI) - BITAI - LDAP Services Wrappers - Library to wrap an LDAP Service functionality. - © 2026 BITAI. MIT License. - https://github.com/bitai-cs/LDAPHelper - https://github.com/bitai-cs/LDAPHelper.git - ldap;authentication;authorization;directory;helper;oauth;openid;ad;security;identity - True - LICENSE.md - README.md - - - - - True - \ - - - True - \ - - - - diff --git a/src/Bitai.LDAPHelper.LdapAdapters/Enums.cs b/src/Bitai.LDAPHelper.LdapAdapters/Enums.cs deleted file mode 100644 index 69f71f5..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/Enums.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// LDAP modification operation types -/// -public enum LdapModificationType -{ - /// - /// Adds an attribute value. - /// - Add = 0, - - /// - /// Deletes an attribute value. - /// - Delete = 1, - - /// - /// Replaces an attribute value. - /// - Replace = 2 -} - -/// -/// LDAP search scope values -/// -public enum LdapSearchScope -{ - /// - /// Search only the base object. - /// - ScopeBase = 0, - - /// - /// Search one level below the base object. - /// - ScopeOne = 1, - - /// - /// Search the entire subtree below the base object. - /// - ScopeSub = 2 -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/IConnectionInfo.cs b/src/Bitai.LDAPHelper.LdapAdapters/IConnectionInfo.cs deleted file mode 100644 index cfceba1..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/IConnectionInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines LDAP server connection settings required to open an LDAP connection. -/// -public interface IConnectionInfo -{ - /// - /// Gets the connection timeout in seconds. - /// - short ConnectionTimeout { get; } - - /// - /// Gets the LDAP server host name or IP address. - /// - string Server { get; } - - /// - /// Gets the LDAP server port. - /// - int ServerPort { get; } - - /// - /// Gets a value indicating whether SSL must be used. - /// - bool UseSSL { get; } -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapAttributeAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapAttributeAdapter.cs deleted file mode 100644 index 221721b..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapAttributeAdapter.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines read access to LDAP attribute values in multiple representations. -/// -public interface ILdapAttributeAdapter -{ - /// - /// Gets the first binary value of the attribute. - /// - byte[] ByteValue { get; } - - /// - /// Gets the first string value of the attribute. - /// - string StringValue { get; } - - /// - /// Gets all string values of the attribute. - /// - string[] StringValueArray { get; } - - /// - /// Gets all binary values of the attribute. - /// - byte[][] ByteValueArray { get; } -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapAttributeSetAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapAttributeSetAdapter.cs deleted file mode 100644 index 2180fc6..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapAttributeSetAdapter.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines operations for building and reading LDAP attribute sets. -/// -public interface ILdapAttributeSetAdapter -{ - /// - /// Adds a single string value to an attribute. - /// - /// Attribute name. - /// Attribute value. - void AddAttribute(string name, string value); - - /// - /// Adds multiple string values to an attribute. - /// - /// Attribute name. - /// Attribute values. - void AddAttribute(string name, string[] values); - - /// - /// Adds a binary value to an attribute. - /// - /// Attribute name. - /// Binary attribute value. - void AddAttribute(string name, byte[] value); - - /// - /// Determines whether an attribute exists in the set. - /// - /// Attribute name to look up. - /// if found; otherwise . - bool ContainsKey(string attributeName); - - /// - /// Gets an attribute by name. - /// - /// Attribute name. - /// The attribute adapter when found; otherwise . - ILdapAttributeAdapter GetAttribute(string attributeName); -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapConnectionAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapConnectionAdapter.cs deleted file mode 100644 index ea0e4d0..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapConnectionAdapter.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines the operations required to manage and use an LDAP connection. -/// -public interface ILdapConnectionAdapter : IDisposable -{ - /// - /// Gets or sets the connection timeout in milliseconds. - /// - int ConnectionTimeout { get; set; } - - /// - /// Gets or sets a value indicating whether SSL is enabled. - /// - bool SecureSocketLayer { get; set; } - - /// - /// Gets a value indicating whether the connection is authenticated (bound). - /// - bool IsBound { get; } - - /// - /// Bypasses server certificate validation. - /// - /// Use only in controlled environments. - void ServerCertificateValidationByPass(); - - /// - /// Connects to the LDAP server. - /// - /// Server host name or IP address. - /// Server port. - /// A task that completes when the connection is established. - Task ConnectAsync(string host, int port); - - /// - /// Authenticates the connection. - /// - /// User distinguished name or account identifier. - /// Account password. - /// A task that completes when bind finishes. - Task BindAsync(string userDN, string password); - - /// - /// Executes an LDAP search. - /// - /// Search boundaries and limits. - /// LDAP filter expression. - /// Attributes to return. - /// Whether only attribute names should be returned. - /// A queue adapter with server responses. - Task SearchAsync(ISearchLimits searchLimits, string searchFilter, string[] attributeNames, bool typesOnly); - - /// - /// Creates an empty attribute set for add/update operations. - /// - /// An attribute set adapter. - ILdapAttributeSetAdapter CreateAttributeSet(); - - /// - /// Adds an entry to the directory. - /// - /// Distinguished name for the new entry. - /// Attribute set for the new entry. - /// A task that completes when the entry is created. - Task AddEntryAsync(string distinguishedName, ILdapAttributeSetAdapter attributes); - - /// - /// Creates a modification descriptor. - /// - /// Modification type. - /// Attribute name to modify. - /// New attribute value. - /// A modification adapter. - ILdapModificationAdapter CreateModification(LdapModificationType type, string attributeName, object value); - - /// - /// Applies modifications to an existing entry. - /// - /// Target entry distinguished name. - /// Modifications to apply. - /// A task that completes when the update finishes. - Task ModifyEntryAsync(string distinguishedName, IEnumerable modifications); - - /// - /// Deletes an entry from the directory. - /// - /// Target entry distinguished name. - /// A task that completes when deletion finishes. - Task DeleteEntryAsync(string distinguishedName); - - /// - /// Disconnects the connection from the server. - /// - void Disconnect(); -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapConnectionFactoryAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapConnectionFactoryAdapter.cs deleted file mode 100644 index f774df8..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapConnectionFactoryAdapter.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines a factory for creating initialized LDAP connections. -/// -public interface ILdapConnectionFactoryAdapter -{ - /// - /// Creates a new LDAP connection and optionally binds it with credentials. - /// - /// Server connection settings. - /// Account identifier used for bind. - /// Account password used for bind. - /// - /// to fail when bind cannot be completed; otherwise . - /// - /// A task with an initialized LDAP connection adapter. - Task CreateConnectionAsync( - IConnectionInfo connectionInfo, - string userAccount, - string password, - bool bindRequired = true); -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapEntryAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapEntryAdapter.cs deleted file mode 100644 index 6a721c7..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapEntryAdapter.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines read access to an LDAP entry and its attribute set. -/// -public interface ILdapEntryAdapter -{ - /// - /// Gets the distinguished name of the entry. - /// - string DistinguishedName { get; } - - /// - /// Gets the attribute set associated with the entry. - /// - /// An attribute set adapter. - ILdapAttributeSetAdapter GetAttributeSet(); -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapMessageAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapMessageAdapter.cs deleted file mode 100644 index d801c69..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapMessageAdapter.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines accessors for LDAP protocol messages returned by search operations. -/// -public interface ILdapMessageAdapter -{ - /// - /// Gets the LDAP entry when the message represents a search result; otherwise . - /// - ILdapEntryAdapter Entry { get; } - - /// - /// Gets a value indicating whether this message is a search-result message. - /// - bool IsSearchResult { get; } - - /// - /// Gets a value indicating whether this message signals end-of-search. - /// - bool IsSearchDone { get; } -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapModificationAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapModificationAdapter.cs deleted file mode 100644 index 5abf8df..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapModificationAdapter.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines access to a single LDAP modification operation. -/// -public interface ILdapModificationAdapter -{ - /// - /// Gets the modification operation type. - /// - LdapModificationType ModificationType { get; } - - /// - /// Gets the attribute associated with the modification. - /// - ILdapAttributeAdapter Attribute { get; } -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapSearchConstraintsAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapSearchConstraintsAdapter.cs deleted file mode 100644 index 22cdc4b..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapSearchConstraintsAdapter.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines LDAP server-side search constraints. -/// -public interface ILdapSearchConstraintsAdapter -{ - /// - /// Gets or sets the server-side time limit in seconds. - /// - int ServerTimeLimit { get; set; } - - /// - /// Gets or sets the maximum number of entries returned by the server. - /// - int MaxResults { get; set; } -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ILdapSearchQueueAdapter.cs b/src/Bitai.LDAPHelper.LdapAdapters/ILdapSearchQueueAdapter.cs deleted file mode 100644 index bc77109..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ILdapSearchQueueAdapter.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines access to queued LDAP search responses. -/// -public interface ILdapSearchQueueAdapter -{ - /// - /// Gets the next response from the queue. - /// - /// The next message adapter; or when no more responses are available. - ILdapMessageAdapter GetResponse(); -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/ISearchLimits.cs b/src/Bitai.LDAPHelper.LdapAdapters/ISearchLimits.cs deleted file mode 100644 index df33418..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/ISearchLimits.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Bitai.LDAPHelper.LdapAdapters; - -/// -/// Defines LDAP search boundaries and limits. -/// -public interface ISearchLimits -{ - /// - /// Gets or sets the base distinguished name from which the search starts. - /// - string BaseDN { get; set; } - - /// - /// Gets or sets the LDAP search scope. - /// - LdapSearchScope LdapSearchScope { get; set; } - - /// - /// Gets or sets the maximum number of entries to return. - /// - int MaxSearchResults { get; set; } - - /// - /// Gets or sets the maximum server processing time in seconds. - /// - int MaxSearchTimeout { get; set; } -} diff --git a/src/Bitai.LDAPHelper.LdapAdapters/LICENSE.md b/src/Bitai.LDAPHelper.LdapAdapters/LICENSE.md deleted file mode 100644 index e263634..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -# MIT License - -Copyright (c) 2026 BITAI - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/Bitai.LDAPHelper.LdapAdapters/README.md b/src/Bitai.LDAPHelper.LdapAdapters/README.md deleted file mode 100644 index ee1b0f4..0000000 --- a/src/Bitai.LDAPHelper.LdapAdapters/README.md +++ /dev/null @@ -1,110 +0,0 @@ -# Bitai.LDAPHelper.LdapAdapters - -`Bitai.LDAPHelper.LdapAdapters` defines the LDAP adapter contracts used by the Bitai LDAP Helper libraries. It is a small abstraction layer that keeps the core helper logic independent from any specific LDAP client implementation, such as `Novell.Directory.Ldap.NETStandard`. - -This package contains interfaces and enums only. It does not open LDAP connections by itself and does not include a concrete LDAP provider. - -## Purpose - -Use this project when you need to: - -- Implement a concrete LDAP provider for `Bitai.LDAPHelper`. -- Test LDAP-dependent code without binding directly to a real directory server. -- Isolate application logic from vendor-specific LDAP client APIs. -- Standardize LDAP operations such as bind, search, add, modify, delete, and attribute access. - -## Target Framework - -- .NET 10.0 -- Nullable reference types enabled -- Implicit global usings enabled - -## Package Metadata - -- Package ID: `Bitai.LDAPHelper.LdapAdapters` -- Version: `10.0.0` -- Repository: `https://github.com/bitai-cs/LDAPHelper` -- License: MIT - -## Main Contracts - -### Connection and Factory - -- `ILdapConnectionFactoryAdapter` creates configured LDAP connections from `IConnectionInfo` and credentials. -- `ILdapConnectionAdapter` represents a connected LDAP session and exposes bind, search, add, modify, delete, disconnect, and dispose operations. -- `IConnectionInfo` describes LDAP server address, port, SSL usage, and timeout settings. - -### Search - -- `ISearchLimits` describes base DN, search scope, result limits, and timeout limits. -- `ILdapSearchQueueAdapter` abstracts queued LDAP search responses. -- `ILdapMessageAdapter` distinguishes search result entries from search completion messages. - -### Entries and Attributes - -- `ILdapEntryAdapter` exposes an LDAP entry distinguished name and its attribute set. -- `ILdapAttributeSetAdapter` creates and retrieves LDAP attributes by name. -- `ILdapAttributeAdapter` exposes attribute values as string, string array, byte array, or byte array collection. - -### Modifications - -- `ILdapModificationAdapter` describes an LDAP attribute modification. -- `LdapModificationType` supports add, delete, and replace operations. -- `LdapSearchScope` supports base, one-level, and subtree LDAP searches. - -## Implementing an Adapter - -A concrete provider typically implements `ILdapConnectionFactoryAdapter` and `ILdapConnectionAdapter`, then maps the Bitai contracts to the provider-specific LDAP client. - -```csharp -using Bitai.LDAPHelper.LdapAdapters; - -public sealed class CustomLdapConnectionFactoryAdapter : ILdapConnectionFactoryAdapter -{ - public async Task CreateConnectionAsync( - IConnectionInfo connectionInfo, - string userAccount, - string password, - bool bindRequired = true) - { - var connection = new CustomLdapConnectionAdapter(); - connection.ConnectionTimeout = connectionInfo.ConnectionTimeout; - connection.SecureSocketLayer = connectionInfo.UseSSL; - - await connection.ConnectAsync(connectionInfo.Server, connectionInfo.ServerPort); - - if (bindRequired) - { - await connection.BindAsync(userAccount, password); - } - - return connection; - } -} -``` - -The adapter is then passed into higher-level `Bitai.LDAPHelper` services such as authentication, search, account management, and group membership validation. - -## Design Notes - -- The package intentionally contains no dependency on a specific LDAP SDK. -- Adapter implementations should preserve provider exceptions only when callers can handle them meaningfully; otherwise, translate them into domain-level exceptions used by the consuming library. -- `ILdapConnectionAdapter` implements `IDisposable`; concrete implementations should release network resources and provider-specific handles consistently. -- `ServerCertificateValidationByPass` exists for compatibility with provider adapters. Use it only in controlled development or test environments. - -## Build - -From the repository root: - -```powershell -dotnet build src/Bitai.LDAPHelper.LdapAdapters/Bitai.LDAPHelper.LdapAdapters.csproj -``` - -## Related Projects - -- `Bitai.LDAPHelper`: Core LDAP helper services that consume these contracts. -- `Bitai.LDAPHelper.Tests.Mocks`: In-memory mock implementations for tests and demos. - -## License - -This project is licensed under the MIT License. See [LICENSE.md](LICENSE.md).