LDAP Client Connection
Relevant source files
The following files were used as context for generating this wiki page:
The LDAP Client Connection module provides a robust infrastructure for connecting to and interacting with LDAP directory services. It acts as a consolidated wrapper around the flext-ldap library, offering both high-level abstractions for Singer tap operations and testing convenience wrappers. The module handles server URI construction, connection lifecycle management, health checks, and specialized support for Oracle-specific LDAP extensions.
At its core, the system utilizes the FlextTapLdapClient class to manage connections and the FlextTapLdapUtilitiesClientSupport for normalizing LDAP payloads into JSON formats compatible with Singer streams. This architecture ensures a clear separation between the raw directory interaction and the data transformation logic required for ETL processes.
Sources: src/flext_tap_ldap/client.py:1-20, src/flext_tap_ldap/_utilities/client_support.py:1-12
Core Client Architecture
The client infrastructure is organized around the FlextTapLdapClient container, which encapsulates the LDAPClient inner class. This client supports both the Parameter Object Pattern (using m.Ldap.ConnectionConfig) and a keyword-argument-based initialization for testing convenience.
Client Initialization Flow
The following diagram illustrates how the client initializes its internal state and the underlying FlextLdap API.
Sources: src/flext_tap_ldap/client.py:32-75
Key Components
| Component | Description | Location |
|---|---|---|
LDAPClient | The primary wrapper for LDAP operations, providing search and health check capabilities. | client.py:27 |
ClientSupport | Utility class for URI building, scope normalization, and entry mapping. | client_support.py:16 |
ConnectionConfig | Pydantic model for validating LDAP connection parameters. | client.py:38 |
FlextLdap | The underlying core library utilized for actual directory communication. | client.py:107 |
Connection Management and Search Logic
The client manages connections by delegating to the FlextLdap API while providing synchronous search wrappers that return Singer-compatible list-of-dictionary results.
Search Execution Process
When a search is initiated, the client first normalizes the LDAP scope and search options before executing the query through the internal API. The results are then processed via the ClientSupport utilities to ensure valid JSON mapping.
Search Configuration Defaults
- Default Scope:
SUBTREE(Sources: client_support.py:37) - Default Page Size: 1000 (Sources: client.py:30)
- Default Timeout: 30 seconds (Sources: client.py:157)
Oracle OID Support
The client includes specialized logic for Oracle Internet Directory (OID) environments. This involves extending requested attributes to include Oracle-specific password fields and normalizing entries that use orclContainer to include standard organizationalUnit object classes.
Oracle Normalization Flow
Oracle Search Implementation
Oracle searches are executed in a dedicated event loop because FlextLdap core operations are typically asynchronous. The LDAPClient manages the creation and cleanup of this temporary loop to provide a synchronous interface to the tap.
def _execute_oracle_search_in_new_loop(
self,
base_dn: str,
search_filter: str,
attributes: t.StrSequence | None,
*,
oracle_oid_mode: bool,
) -> t.SequenceOf[t.JsonMapping]:
loop = new_event_loop()
set_event_loop(loop)
try:
search_result = self.search(base_dn, search_filter, attributes)
return u.TapLdap.ClientSupport.process_oracle_search_results(
search_result, oracle_oid_mode=oracle_oid_mode
)
finally:
loop.close()
set_event_loop(None)
Sources: src/flext_tap_ldap/client.py:177-198
Health and Connectivity Validation
The system provides a health_check method that returns a detailed status of the connection, including response time in milliseconds.
Connectivity Features
- Health Status: Returns
healthyorunhealthybased on a minimal search test (base_dn="dc=test",limit=1). - Response Time: Measures the duration between starting the connection test and receiving the result.
- Server URI: Dynamically constructs the canonical URI (e.g.,
ldaps://host:636vsldap://host:389).
Sources: src/flext_tap_ldap/client.py:86-102, src/flext_tap_ldap/client.py:154-169
Tap and Stream Integration
The LDAPBaseStream class in the streams module serves as the primary consumer of the LDAPClient. It extracts connection parameters from the tap's global configuration and instantiates the client during stream initialization.
Summary
The LDAP Client Connection module provides a unified interface for directory access, abstracting the complexities of protocol management, Oracle-specific quirks, and data normalization. By centralizing these concerns in the LDAPClient and ClientSupport utilities, the project ensures consistent data extraction across all LDAP-based Singer streams.