簡體   English   中英

Python 3.5,ldap3和Modify_password()

[英]Python 3.5, ldap3 and modify_password()

我一直在努力嘗試通過腳本發送請求以更新我自己的密碼。 這是代碼:

#!/usr/bin/python3.5

from ldap3 import Server, Connection, NTLM, ALL

server = Server('ldap://192.168.0.80', use_ssl=True)

conn = Connection(server, user="local\\dctest", password="Pa55word1", authentication=NTLM, auto_bind=True)

dn = "CN=dctest,CN=Users,DC=home,DC=local"

conn.extend.microsoft.modify_password(dn, new_password="Pa55word2", old_password="Pa55word1")

我得到的錯誤是:

{'dn':``,'type':'modifyResponse','description':'unwillingToPerform','referrals':無,'result':53,'message':'00002077:SvcErr:DSID-03190E44,問題5003(WILL_NOT_PERFORM),數據0 \\ n \\ x00'}

知道我在做什么錯嗎?

我具有DC的完全訪問權限,並且確保密碼正確無誤。我已經閱讀了所有文檔,但無法理解。

任何幫助將是巨大的!

從0.9.4.2版開始的ldap3.modify_password()不適用於Active Directory,因為它使用了AD不支持的密碼修改擴展操作。 看來,MS找到了一種與AD有所不同方法 ldap3作者(cannatag)意識到了這一點,並在不久后添加了ad_modify_password()。 您必須使用ldap3的較新版本。

好,謝謝大家的幫助,也感謝github上的開發人員。

我最終用來完成這項工作的代碼是...

from ldap3 import Server, Connection

server = Server('ldaps://<AD server address>', use_ssl=True)
conn = Connection(server, user="<domain>\\<username>", password="<current password>", auto_bind=True)

dn = 'CN=<username>,OU=Users,DC=<dominaname>'

res = conn.extend.microsoft.modify_password(dn, old_password='<current password>', new_password='<new password>')
print(res)

以為我會發布有效的解決方案,因為互聯網上似乎沒有任何內容!! 上帝加速我的同胞們。

嘗試使用ldaps://而不是ldap://。 或者根本不使用該方案,並在服務器定義中傳遞use_ssl = True。 AD連接必須使用ssl修改密碼。

您正在使用哪個版本的ldap3? 從ldap3版本2.2的源代碼中,在我看來該函數應以類似的方式使用:

#!/usr/bin/python3.5
from ldap3 import Server, Connection, NTLM, ALL
server = Server('ldap://192.168.0.80', use_ssl=True)
conn = Connection(server, user="local\\dctest", password="Pa55word1", authentication=NTLM, auto_bind=True)
res = ldap3.extend.microsoft.modifyPassword(conn, user, "new_Pa55word2", "old_Pa55word1")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM