Skip to main content

ldap3-ad-auth

ldap3-ad-auth adds protected Active Directory binds to synchronous ldap3 connections. It uses Impacket for Kerberos and NTLM authentication and leaves LDAP queries, entries, controls, and binary values with ldap3. It does not require a native GSSAPI library or an ldap3 fork.

On plain LDAP, it negotiates signing and sealing and protects every LDAP message after the bind. On LDAPS, it supplies a tls-server-end-point channel binding token derived from the current TLS peer certificate. The caller's TLS certificate validation settings are preserved.

Installation

The package requires Python 3.9 or newer and uses ldap3 2.9.1 and Impacket 0.13.1. Install it with:

python -m pip install ldap3-ad-auth

Usage

from ldap3 import ALL, BASE, Connection, Server
from ldap3_ad_auth import bind_ntlm

server = Server('dc.example.com', get_info=ALL)
connection = Connection(server, user=r'EXAMPLE\alice', password='...',
                        auto_referrals=False)
bind_ntlm(connection)
connection.search('', '(objectClass=*)', search_scope=BASE,
                  attributes=['defaultNamingContext'])

For Kerberos, create the same unbound connection and call bind_kerberos(connection, hostname='dc.example.com', domain='example.com', username='alice', password='...'). The Kerberos binder also accepts hashes, AES keys, a TGT, or a TGS. bind_ntlm accepts an NT hash or a LM:NT string as well as a password.

Both binders return the original connection. They require ldap3's synchronous strategy and auto_referrals=False. Rebinding, reopening, and StartTLS on the same protected connection are refused; create a new connection for a new bind. An invalid protected message closes the socket and raises ProtectionError.

Attribution

The Kerberos bind and TLS channel binding construction adapt MIT-licensed code from BloodHound.py and krbrelayx. The plain LDAP signing and sealing approach builds on BloodHound.py PR #254 (Kerberos by Pebl3; NTLM by Ahmad Alawneh) and PR #259 (Kerberos by Danila Domoroshchenov). The protected transport and incoming signature verification were rewritten for this package. The original projects' copyright notices are retained in LICENSE.

Tests

After installing from source, run python -m unittest discover -s tests.

Metadata

Release files for ldap3-ad-auth 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ldap3-ad-auth 0.1.0
File Size Uploaded Provenance
ldap3_ad_auth-0.1.0.tar.gz 12.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ldap3-ad-auth 0.1.0
File Interpreter ABI Platform
ldap3_ad_auth-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / ldap3_ad_auth-0.1.0.tar.gz

Download URL ldap3_ad_auth-0.1.0.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2d91f8213e3524a0b937baeed3d0b3e3be6fd197be454a4e8fb5f8c30bf7069b
BLAKE2b-256 checksum
How to use checksums
0ad2138a6560b8d90af63afb7d2e6d595f8362e821dd05b44f3f31f5f0a90eec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / ldap3_ad_auth-0.1.0-py3-none-any.whl

Download URL ldap3_ad_auth-0.1.0-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8eeeefe9bf4b80210c089c4f4e27f27eff80f000143ea0dde5ae0f49983879db
BLAKE2b-256 checksum
How to use checksums
92214e2ff0f6527f5cc0ada686883523901a84cb4b67ed0f42bd1b2638242ebe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for ldap3-ad-auth 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page