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, ldap3 2.9.1 or newer, and Impacket 0.13.1 or newer. 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.1

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.1
File Size Uploaded Provenance
ldap3_ad_auth-0.1.1.tar.gz 12.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 22.8 kB

Release files / ldap3_ad_auth-0.1.1.tar.gz

Download URL ldap3_ad_auth-0.1.1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
db3ebfc40a70af9573e7d14933317d4f75a51727d4fc758da3c4673802d38ce0
BLAKE2b-256 checksum
How to use checksums
b17bfc015dc56b49ca0ced4777ed76c5af20220022b5251f14dd76677ea9e8d7
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.1-py3-none-any.whl

Download URL ldap3_ad_auth-0.1.1-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b900d283328e44157cf29db94c8f35fb71ba1e4a3f7ef47ac326562f539a7e9
BLAKE2b-256 checksum
How to use checksums
dc1789fe01909f3f7f307bb9ec00fc7b180beeb87205d9f5e626982c49853160
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.1

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.1 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