python3测试AD用户账号密码

from ldap3 import Server,Connection,ALL,NTLM
def ldap_connect(server,user,password):
    AD_server=Server(server,get_info=ALL)
    try:
        conn=Connection(AD_server,user=user,password=password,auto_bind=True,authentication=NTLM)
    except Exception as e:
        print("Login Error ! \f",*(e.args))
    else:
        print("Login Successful !")
        return conn
   
conn=ldap_connect(server='DASHBRANDS.local',user=r'DASHBRANDS\test',password=r'passwd')
需要ldap3库,

传入AD地址,用户名,密码即可

posted @ 2021-10-09 15:21  FengZhe  阅读(232)  评论(0编辑  收藏  举报