Last active
January 30, 2025 00:59
-
-
Save ChuckWoodraska/892cf21f4e3d9c0dab466125192f7e3d to your computer and use it in GitHub Desktop.
LDAP authentication test with Python 3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ldap3 as ldap | |
SERVER_NAME = 'ldap.example.com' | |
DN = 'EXAMPLEDOMAIN' | |
USERNAME = 'user' | |
PASSWORD = 'password' | |
server = ldap.Server(SERVER_NAME) | |
connection = ldap.Connection(server, user='{}\\{}'.format(DN, USERNAME), password=PASSWORD) | |
connection.open() | |
if connection.bind(): | |
print('Authenticated!') | |
else: | |
print('Not Authenticated') | |
print(connection.result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment