sandbox/ldap_test/main.py
2024-11-02 14:14:15 +03:00

17 lines
373 B
Python

#! /usr/bin/python3
import ldap
import ldap.sasl
HOST = "172.31.142.142"
PORT = 636
user_name = "wscusers\JohnDoe"
pwd = "T1Rules@123"
if __name__ == '__main__':
ldap_conn = ldap.initialize("ldap://[%s]" % (HOST))
ldap_conn.simple_bind_s(user_name, pwd)
try:
print(ldap_conn.whoami_s())
except ldap.INVALID_CREDENTIALS as e:
print(e)