CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-ldap3

tessl install tessl/pypi-ldap3@1.4.0

A strictly RFC 4510 conforming LDAP V3 pure Python client library

Agent Success

Agent success rate when using this tile

81%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.08x

Baseline

Agent success rate without this tile

75%

task.mdevals/scenario-6/

Secure LDAP TLS Client

A module that establishes a mutually authenticated TLS connection to an LDAP directory and exposes a minimal surface for authenticated queries.

Capabilities

Establishes TLS session with mutual authentication

  • With valid host, port, CA certificate, client certificate, and client key, establishing a session succeeds and reports that TLS is active @test
  • When the CA certificate cannot validate the server, establishing a session raises a certificate validation error @test

Performs certificate-based bind

  • After establishing TLS, performs a certificate-based bind that reports the authenticated identity without requiring a password @test
  • When the client key is missing or unreadable, certificate-based bind fails with a clear error @test

Executes search after secure bind

  • After a successful certificate-based bind, running a subtree search under a given base DN returns entries containing only requested attributes @test

Implementation

@generates

API

from typing import Any, Dict, List, Optional, Protocol


class TLSConfig(Protocol):
    host: str
    port: int
    use_ssl: bool
    ca_cert_file: str
    client_cert_file: str
    client_key_file: str
    require_hostname_check: bool


def establish_session(config: TLSConfig, timeout: Optional[float] = None) -> Any:
    """
    Opens a TLS-secured LDAP session using the provided CA/client materials and returns a session handle
    that exposes whether TLS is active.
    Raises on TLS verification issues or bind failures.
    """


def certificate_bind(session: Any, authz_id: Optional[str] = None) -> str:
    """
    Performs a certificate-based bind on the existing TLS session without using a password.
    Optionally allows specifying an authorization identity to assert.
    Returns the bound identity string and raises if TLS is missing or client credentials are unusable.
    """


def search_entries(session: Any, base_dn: str, filter_expression: str, attributes: List[str]) -> List[Dict[str, Any]]:
    """
    Executes a subtree search using the authenticated session and returns entries with only requested attributes,
    formatted as dictionaries keyed by DN and attribute names.
    Raises if the search fails or when called on an unbound session.
    """

Dependencies { .dependencies }

ldap3 { .dependency }

Provides LDAP client capabilities with TLS support and certificate-based authentication.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/ldap3@1.4.x
tile.json