每当我尝试通过ldap3库更改某人的密码时,我都会收到以下错误:
{'type': 'modifyResponse', 'result': 53, 'message': '0000001F: SvcErr: DSID-031A12D2, problem 5003 (WILL_NOT_PERFORM), data 0\n\x00', 'referrals': None, 'description': 'unwillingToPerform', 'dn': ''}
由于以下两个条件,通常会发生此错误:用户尝试通过未加密的连接修改密码,或者使用不正确的编码发送密码。我的SSL连接很好(至少看起来似乎是这样):
print(connection)
>>> ldaps://DC1.DOMAIN.LOCAL:636 - ssl - user: DOMAIN\admin - not lazy - bound - open - <local: 172.16.10.2:49230 - remote: 172.16.10.254:636> - tls not started - listening - SyncStrategy - internal decoder
我尝试对我尝试发送到LDAP服务器的字符串进行编码,但.encode(&#39; utf-16le&#39;)没有做到这一点。还有其他解决方法吗?
我有一个测试域环境,Windows Server 2012 R2作为域控制器,我尝试更改密码的代码如下所示。
import ssl
from ldap3 import *
tls_configuration = Tls(validate=ssl.CERT_REQUIRED, version=ssl.PROTOCOL_TLSv1_2)
s = Server('DC1.domain.local', get_info=ALL, use_ssl=True, tls=tls_configuration)
password = 'mypasswordhere'
c = Connection(s, user="DOMAIN\\admin", password=password)
c.open()
c.bind()
user = "CN=Dummy Dumass,OU=Automatically Generated,OU=Staff,OU=RU,DC=DOMAIN,DC=LOCAL"
c.modify(user, {
'unicodePwd': [(MODIFY_REPLACE, ['New12345'])]
})
print(c.result)
c.unbind()
答案 0 :(得分:6)
ldap3包含更改AD密码的特定方法,请使用以下代码而不是c.modify()
:
c.extend.microsoft.modify_password(user, new_password)
答案 1 :(得分:0)
此代码适用于Windows 2012 R2 AD:
pip install ldap
boolean stopSequence = false;
for (int i = 0; i < Array1.length; i++){
for (int a = 0; a < Array2.length && !stopSequence;){
if (Array1[i] != Array2[a]){
Array1[i] = 0;
a++;
}
if (Array1[i] == Array2[a]){
Array1[i] = 0;
stopSequence = true;
}
}
stopSequence = false;
}
[1]: https://stackoverflow.com/questions/26998156/java-remove-duplicates-from-array-using-loops
[2]: https://stackoverflow.com/questions/2435156/java-removing-duplicates-in-an-arraylist
[3]: http://javarevisited.blogspot.com.es/2015/06/3-ways-to-find-duplicate-elements-in-array-java.html
[4]: https://stackoverflo
答案 2 :(得分:0)
上面提到的代码对我有用,但是只有在使用ssl时才能更改密码。更改服务器定义行,如下所示:
ldap_server = ldap3.Server(SERVER, get_info=ldap3.ALL, use_ssl=True)