![](/img/trans.png)
[英]Unable to authenticate ,enable the user in active Directory ,the user account created by using python ldap
[英]Enable Active Directory user account using ldap python
我在 python 中使用 ldap 模塊將用戶添加到 Microsoft 2012 Active Directory。 由於我能夠成功地將用戶添加到 AD,用戶將在下次登錄和帳戶時添加為禁用選項。 我嘗試了很多選項來啟用該帳戶,但無法這樣做。 嘗試在創建用戶時啟用帳戶的選項,但這也不起作用。 嘗試修改功能,但仍然沒有運氣。 任何人都可以為上述問題建議繞道而行嗎? 提前致謝
您需要在創建條目並設置userAccountControl
屬性后對其進行修改。
userAccountControl
屬性是一個位標志。
可以設置幾種不同的enabled
狀態。
512
- 是默認啟用的帳戶67048
- 是密碼不會過期的已啟用帳戶在啟用 Active Directory 帳戶之前檢查以下項目:
userPrincipleName
屬性,與電子郵件相同!userAccountControl=544
而不是userAccountControl=512
或userAccountControl=67048
來啟用用戶。然后您可以使用以下示例代碼來啟用用戶:
from ldap3 import Server, Connection, MODIFY_REPLACE
server = Server('ldap://hostname', 389, use_ssl=False)
connection = Connection(server, user='DOMAIN/Administrator', password='AdminPass', auto_bind=True)
connection.modify(distinguishedName, {'userAccountControl': (MODIFY_REPLACE, [544])})
connection.modify(distinguishedName, {'userAccountControl': (MODIFY_REPLACE, [512])}) # for users' who have password.
connection.unbind()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.