Skip to content

Instantly share code, notes, and snippets.

@timoteoramos
Created April 4, 2017 20:58
Show Gist options
  • Save timoteoramos/d6cdbcedc6d7014d4e9d55bafca82f03 to your computer and use it in GitHub Desktop.
Save timoteoramos/d6cdbcedc6d7014d4e9d55bafca82f03 to your computer and use it in GitHub Desktop.
LDAP3 Simple authentication
from ldap3 import Connection, Server
import getpass
SERVER = '127.0.0.1'
SEARCH = 'cn=%s,cn=Users,dc=example,dc=com' % input('Username: ')
PASSWD = getpass.getpass()
with Connection(Server(SERVER, use_ssl=True), SEARCH, PASSWD, auto_bind=True) as conn:
print(conn)
conn.unbind()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment