Skip to content

Instantly share code, notes, and snippets.

View paulosantos75's full-sized avatar

Paulo Santos paulosantos75

View GitHub Profile
@anilpai
anilpai / ldap.py
Created March 19, 2018 19:27
Python code to connect to LDAP server and authenticate a user.
import ldap3
class Ldap:
"""Class for LDAP related connections/operations."""
def __init__(self, server_uri, ldap_user, ldap_pass):
self.server = ldap3.Server(server_uri, get_info=ldap3.ALL)
self.conn = ldap3.Connection(self.server, user=ldap_user, password=ldap_pass, auto_bind=True)
def who_am_i(self):