tessl install tessl/pypi-ldap3@1.4.0A 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%
Manage a directory service session that can authenticate automatically when configured, expose bound state, and close cleanly when finished.
AuthenticationFailure and leaves the session unbound. @test@generates
from dataclasses import dataclass
from typing import Optional, Any, ContextManager
class AuthenticationFailure(Exception):
"""Raised when credentials are rejected."""
@dataclass
class ConnectionConfig:
uri: str
user_dn: Optional[str] = None
password: Optional[str] = None
use_tls: bool = False
auto_connect: bool = False
class DirectoryConnection(ContextManager["DirectoryConnection"]):
config: ConnectionConfig
client: Any
last_error: Optional[str]
def __init__(self, config: ConnectionConfig):
...
def bind(self) -> bool:
"""Open the connection if needed and authenticate with current credentials."""
def rebind(self, user_dn: str, password: str) -> bool:
"""Switch credentials and authenticate without creating a new session."""
def unbind(self) -> None:
"""Close the session and clear bound state."""
def is_bound(self) -> bool:
"""Return True when the underlying session is authenticated."""
@property
def bound_user(self) -> Optional[str]:
"""Active distinguished name for the current bound user."""
def __enter__(self) -> "DirectoryConnection":
"""Enter a managed block and ensure the session is ready for use."""
def __exit__(self, exc_type, exc, tb) -> None:
"""Always close the session when leaving the managed block."""Provides LDAP client primitives for creating, binding, rebinding, and closing directory connections with optional automatic bind support. @satisfied-by