Home
Relevant source files
The following files were used as context for generating this wiki page:
flext-target-ldap is a FLEXT-based Target implementation designed for loading data into LDAP directory services. It adheres to the Singer protocol, allowing it to ingest data from various taps and synchronize it with LDAP entries such as Users, Groups, and Organizational Units. The project leverages flext-core patterns to provide a robust, enterprise-grade integration layer with built-in validation, schema enforcement, and connection management.
Sources: README.md:10-12, src/flext_target_ldap/api.py:33-35
System Architecture
The project is structured around a facade pattern where the FlextTargetLdap class serves as the primary entry point. It orchestrates the flow between incoming Singer messages (SCHEMA, RECORD, STATE) and specific Sink implementations that handle the LDAP-specific logic for different object types.
Core Components
| Component | Description |
|---|---|
FlextTargetLdap | The main facade class that manages orchestration, settings validation, and sink dispatching. |
FlextTargetLdapClient | An enterprise LDAP client that wraps flext-ldap for low-level operations like add, modify, and delete. |
Sinks | Specialized handlers (UsersSink, GroupsSink, OUSink) that transform Singer records into LDAP attributes and DNs. |
FlextTargetLdapSettings | Pydantic-based configuration model that handles environment variables and flat-to-nested normalization. |
Sources: src/flext_target_ldap/api.py:33-85, src/flext_target_ldap/_models/sinks.py:65-300, src/flext_target_ldap/settings.py:27-50
Data Processing Flow
The following diagram illustrates how a Singer RECORD message is processed by the target and persisted to the LDAP server.
The target processes messages sequentially. When a RECORD is received, the system determines the distinguished name (DN) and attributes based on the stream type (e.g., users) before attempting an "upsert" operation via the LDAP client.
Sources: src/flext_target_ldap/api.py:165-220, src/flext_target_ldap/_models/sinks.py:163-195
Domain Models
The project uses consolidated domain models to represent LDAP entities and their mapping rules. These models ensure that data remains consistent and valid before reaching the directory server.
LDAP Entry Model
The Entry model represents a complete LDAP object, including its Distinguished Name (DN), object classes, and attributes. It includes business logic to ensure mandatory attributes are present for specific types (e.g., sn and cn for person entries).
Sources: src/flext_target_ldap/models.py:97-150
Attribute Mapping
Mappings define how source fields from the Singer stream transform into LDAP attributes.
- Singer Field: The source field name.
- LDAP Attribute: The target attribute in the directory.
- Transformation: Optional rules like
lowercase,uppercase, ortrim.
Sources: src/flext_target_ldap/models.py:46-85
Configuration and Settings
FlextTargetLdapSettings manages the configuration for the target. It supports a "flat" configuration common in Singer environments and normalizes it into a nested structure for the LDAP client.
| Setting | Type | Default | Description |
|---|---|---|---|
host | String | localhost | LDAP server hostname. |
port | Integer | 389 | Connection port. |
use_ssl | Boolean | False | Whether to use LDAPS. |
base_dn | String | (Required) | The base DN for all operations. |
update_existing_entries | Boolean | True | If True, modifies existing entries on conflict. |
user_rdn_attribute | String | uid | Attribute used for User DN construction. |
Sources: src/flext_target_ldap/settings.py:84-145, src/flext_target_ldap/api.py:141-163
Execution Logic
Sink Implementation
The target uses specialized Sinks to handle the nuances of different LDAP object types. For example, the FlextTargetLdapUsersSink automatically appends necessary object classes like inetOrgPerson and person if they are missing from the input data.
The hierarchy allows shared logic for connection management in the BaseSink while permitting specific attribute mapping in the leaf classes.
Sources: src/flext_target_ldap/_models/sinks.py:18-45, src/flext_target_ldap/api.py:75-95
Client Operations
The FlextTargetLdapClient interacts with the LDAP server using the flext-ldap library. It manages the connection lifecycle (connect/disconnect) for every operation to ensure thread safety and resource management.
Key methods include:
add_entry(dn, attributes, object_classes): Creates a new entry.modify_entry(dn, changes): Updates existing attributes using theREPLACEoperation.delete_entry(dn): Removes an entry, typically triggered by_sdc_deleted_atmarkers in the source data.