Python實現AD域認證


 

Python 通過ldap進行ad域賬號的校驗。

首先需要安裝python-ldap的模塊 http://www.python-ldap.org/。 在這里用的是windows系統,當然比較容易,下載地址 http://pypi.python.org/pypi/python-ldap/。

安裝后在python 的交互環境里輸入import ldap 如果沒有問題就說明安裝成功了。

Windows 無法安裝 python-ldap 時,詳見:https://xiexianbin.cn/python/2018/04/23/pip-install-python-ldap

 

 python-ldap   3行集成域認證

import ldap
conn = ldap.initialize('ldap://host')
conn.simple_bind_s('domain\username', 'password')

注意驗證時傳空值驗證也是可以通過的,注意要對password進行檢查。

 

ldap3

from ldap3 import Server,Connection,ALL,NTLM
server = Server('192.168.10.1',get_info=ALL)
conn = Connection(server,user='Domain\\user', password='xxxxxxx',auto_bind=True,authentication='NTLM')

 

 Apache Directory Studio連接Windows AD域控制器

http://www.what21.com/sys/view/ldap_ldap-summary_1473141912625.html

 

參考鏈接:

https://blog.csdn.net/shanliangliuxing/article/details/7710925

傳空值驗證也是可以通過的

https://www.cnblogs.com/linxiyue/p/10250243.html  

Python-LDAP增刪改查

https://blog.csdn.net/shanliangliuxing/article/details/8266267

Python使用LDAP做用戶認證

https://www.cnblogs.com/linxiyue/p/10250243.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM