我想更改AD用戶的userAccountControl和密碼。用戶已在AD中創建。用戶使用AD中的python-ldap模塊創建,並處於「已禁用」狀態且沒有密碼。如何設置鎖定Active Directory用戶的時間和密碼
AD託管在win2k8R2上。
當我改變它拋出以下錯誤pythion-LDAP腳本的UAC和密碼:
ldap://192.168.254.1:389
(97, [])
Traceback (most recent call last):
File "C:\workspace\utils\src\u.py", line 16, in <module>
l.modify_s(dn, mod_attrs)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 336, in modify_s
return self.result(msgid,all=1,timeout=self.timeout)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 436, in result
res_type,res_data,res_msgid = self.result2(msgid,all,timeout)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 440, in result2
res_type, res_data, res_msgid, srv_ctrls = self.result3(msgid,all,timeout)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 446, in result3
ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 96, in _ldap_call
result = func(*args,**kwargs)
ldap.UNWILLING_TO_PERFORM: {'info': '00002077: SvcErr: DSID-031903A4, problem 5003 (WILL_NOT_PERFORM), data 0\n', 'desc': 'Server is unwilling to perform'}
import ldap
host = "192.168.254.1"
ip = "ldap://%s:%d"%(host, 389)
l = ldap.initialize(ip)
newUser = "vishalworld"
dn = "cn=%s,%s"%(newUser, "cn=Users,DC=example,DC=com")
print l.simple_bind_s("administrator",password)
pwd = '"abcdefgh"'.encode("utf-16-le")
mod_attrs = [
(ldap.MOD_REPLACE, "lockoutTime", 0),
(ldap.MOD_REPLACE, "unicodePwd", pwd),
]
l.modify_s(dn, mod_attrs)
有人可以看看嗎? –
Upvote並接受您認爲有用的答案。它會爲你和幫助你的人提供聲望點。給出這樣的觀點會鼓勵人們迴應你。 *碰撞*你自己的問題並不如你從其他未解答的問題中看到的那樣。 – ixe013