#! /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)    
