Skip to content

Instantly share code, notes, and snippets.

@ChuckWoodraska
Last active July 13, 2017 13:38
Show Gist options
  • Save ChuckWoodraska/892cf21f4e3d9c0dab466125192f7e3d to your computer and use it in GitHub Desktop.
Save ChuckWoodraska/892cf21f4e3d9c0dab466125192f7e3d to your computer and use it in GitHub Desktop.
LDAP authentication test with Python 3.
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