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')
传入AD地址,用户名,密码即可