Например:
from ldap3 import Server, Connection, AUTO_BIND_NO_TLS, SUBTREE, ALL_ATTRIBUTES
def get_ldap_info():
with Connection(Server('127.0.0.1', port=636, use_ssl=True),
auto_bind=AUTO_BIND_NO_TLS,
read_only=True,
check_names=True,
user='DOMAIN\\username', password='password') as c:
c.search(search_base='CN=Computers,DC=example,DC=com',
search_filter='(&(objectClass=computer))',
search_scope=SUBTREE,
attributes=ALL_ATTRIBUTES,
get_operational_attributes=True)
print(c.response_to_json())
print(c.result)
get_ldap_info()