LDAP Client Service
Relevant source files
The following files were used as context for generating this wiki page:
The LDAP Client Service is a stateful integration component designed to bridge LDAP directory data with dbt-based data warehouse transformations. It provides mechanisms for extracting directory entries, validating data quality against defined thresholds, and preparing that data for consumption by dbt models. The service acts as a specialized facade within the FLEXT ecosystem, inheriting capabilities from both flext-ldap for protocol communication and flext-meltano for transformation orchestration.
Sources: src/flext_dbt_ldap/services/client.py:1-20, src/flext_dbt_ldap/api.py:15-25
Architecture and Components
The service is structured as a mixin-based facade, primarily through FlextDbtLdapClientMixin. It encapsulates a private LDAP API client (_ldap_api) which is instantiated using global and project-specific settings.
Component Interaction
The following diagram illustrates how the Client Service interacts with external directory services and internal dbt processes.
The Client Service manages the lifecycle of LDAP extraction and coordinates with the dbt runner to execute models on the extracted data.
Sources: src/flext_dbt_ldap/services/client.py:20-40, src/flext_dbt_ldap/api.py:27-35
Core Extraction Logic
The extraction process utilizes the extract_ldap_entries method, which performs synchronous searches against the LDAP directory. It supports configurable search bases, filters (defaulting to all entries), and attribute selection.
- API Initialization: The
create_ldap_apimethod clones globalFlextLdapSettingsand overrides them with specific credentials (Bind DN and Password) to create aFlextLdapinstance. - Synchronous Search:
_search_entries_syncwraps the lower-levelflext-ldapsearch calls, converting results into a sequence of operation attributes compatible with FLEXT protocols.
Sources: src/flext_dbt_ldap/services/client.py:23-40, src/flext_dbt_ldap/services/client.py:186-215
Attribute Mapping
The service performs internal attribute mapping to align LDAP directory schemas with dbt model requirements using _map_entry_attributes.
| Feature | Description |
|---|---|
| DN Mapping | Automatically ensures the Distinguished Name (DN) is captured as a string. |
| Configured Mapping | Applies custom mappings defined in settings.ldap_attribute_mapping. |
| Schema Matching | Filters entries into categories (Users, Groups, Org Units) based on objectClass. |
Sources: src/flext_dbt_ldap/services/client.py:145-165, src/flext_dbt_ldap/services/client.py:167-184
Data Quality and Validation
Before data is passed to dbt, the service executes a validation pipeline via validate_ldap_data. This ensures that extracted entries meet a "minimum quality threshold" defined in the service settings.
The validation metrics include total entry counts, valid DN counts, and a calculated quality score (valid entries / total entries).
Sources: src/flext_dbt_ldap/services/client.py:112-143, src/flext_dbt_ldap/_models/results.py:16-33
Pipeline Orchestration
The run_full_pipeline method provides a single entry point for the end-to-end flow:
- Extract: Retrieves raw entries from the directory.
- Validate: Ensures data meets quality gates.
- Transform: Prepares data and triggers
run_modelsto execute specific dbt transformations.
DBT Transformation Execution
The service executes dbt models through the canonical runtime, allowing for targeted execution of specific models (e.g., staging vs. marts).
def transform_with_dbt(
self,
entries: t.SequenceOf[t.Ldap.OperationAttributes],
model_names: t.StrSequence | None = None,
) -> p.Result[m.DbtLdap.DbtRunStatus]:
# ... logic to run selected dbt models ...
run_result = self._run_selected_models(model_names)
Sources: src/flext_dbt_ldap/services/client.py:76-110, src/flext_dbt_ldap/protocols.py:38-55
Result Models and Metrics
Operation results are encapsulated in typed Pydantic models to provide clear feedback on pipeline health and performance.
| Model | Field | Description |
|---|---|---|
ValidationMetrics | quality_score | Ratio of entries satisfying all required attributes. |
DbtRunStatus | models_run | Sequence of model names executed during the transformation. |
DbtLdapPipelineResult | extracted_entries | Integer count of records successfully retrieved from LDAP. |
PerformanceAnalysis | execution_time | Total time in seconds for the operation to complete. |
Sources: src/flext_dbt_ldap/_models/results.py:16-80
The LDAP Client Service ensures that LDAP data is not only synchronized but also verified and structured correctly before entering the warehouse environment, leveraging the strict typing and protocol enforcement of the FLEXT framework.