E-mail : support@tech2now.in

Verify ldap connection in Python

See the below example which can verify your ldap connection.

import ldap3 as ldap

SERVER_NAME = 'ldap://host:389'
DN = 'uid='
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)

GitHub Repository URL