如何解决" WILL_NOT_PERFORM" MS AD回复试图更改密码斯卡拉瓦特/ unboundid LDAP SDK的时候?如何解决、斯卡、密码、时候

2023-09-08 12:12:46 作者:Indulge(纵容)

我摔跤与Active Directory,好一会才让我更改密码。我发现吨有用的信息,但我仍然得到一个持续的错误。

I'm wrestling with Active Directory, trying to get it to let me change a password. I've found tons of useful information, but I'm still getting a persistent error.

有些code:

import com.unboundid.ldap.sdk._
import com.unboundid.util.ssl._


def main(args: Array[String]) : Unit = {

var sslUtil = new SSLUtil( new TrustAllTrustManager() )
var con = new LDAPConnection(sslUtil.createSSLSocketFactory())
con.connect("ldap.example.net", 636)
con.bind("ldapadmin", "adminpasswd")
val newPass = "Jfi8ZH8#k".getBytes("UTF-16LE");
val modRequest = new ModifyRequest("dn: cn=Tester Dude,ou=Lab,ou=Org,ou=Provider,DC=example,DC=net",
  "changetype: modify",
  "replace: unicodePwd",
  "unicodePwd: " + '"' + newPass + '"')

println("\nGoing to try to set password to " + newPass + " with: " + modRequest.toString())

try {
  con.modify(modRequest)
} catch {
  case lde:LDAPException => println("failed LDAPException: " + lde.toString())
}

}

所以,我得到这个作为一个运行时错误:

So, I get this as a runtime error:

将尝试设置的密码为[B @ 6dd1627e有:ModifyRequest(DN = CN =计老兄,OU =实验室,OU =组织,OU =供应商,DC =例如,DC =网,MODS = {更换UNI codePWD})

Going to try to set password to [B@6dd1627e with: ModifyRequest(dn='cn=Tester Dude,ou=Lab,ou=Org,ou=Provider,DC=example,DC=net', mods={REPLACE unicodePwd})

失败LDAPException:LDAPException(结果code = 53(不愿意执行)的errorMessage ='0000001F:SvcErr:DSID-031A11E5,问题5003(WILL_NOT_PERFORM),数据0 ',diagnosticMessage ='0000001F:SvcErr:DSID-031A11E5,问题5003(WILL_NOT_PERFORM),数据0 ')

failed LDAPException: LDAPException(resultCode=53 (unwilling to perform), errorMessage='0000001F: SvcErr: DSID-031A11E5, problem 5003 (WILL_NOT_PERFORM), data 0 ', diagnosticMessage='0000001F: SvcErr: DSID-031A11E5, problem 5003 (WILL_NOT_PERFORM), data 0 ')

所以之间的事情,我知道可能会导致这个错误:

So among the things I know can cause this error:

在不连接通过SSL。 (不是这里的情况下,我已经检查100%肯定,我在端口636用netstat) 在传递这违反了Active Directory密码策略的密码。 (我测试过手动设置,准确的密码,它会拒绝短/简单的密码,但它接受一个我用这个code)

我已经尝试过了有和没有周围的密码。

I've tried it both with and without the extra quotes around the password.

的信息最有用的来源thusfar是:

The most useful source of info thusfar was:

的http://www.dirmgr.com/blog/2010/8/26/ldap-password-changes-in-active-directory.html

不过,我已经用尽了所有的建议有(和许多其他地方的)。

But I've exhausted every suggestion there (and a lot of other places).

我也试过其他的一些事情,包括设置密码,这是手动添加不同的有效用户。 (这一次是通过SDK加也。)

I've also tried several other things, including setting the password for a different valid user that was added manually. (This one was added via the sdk also.)

其他的操作都工作正常。我已经删除了不相关的code,但我还是能够搜索,打印属性,添加和删除没有问题的用户;但这种修改请求失败。如果我设置ModifyRequest改变一些其他属性,如相关的电子邮件,也能正常工作。

Other operations are working fine. I've removed the irrelevant code but I was able to search, print attributes, add, and delete a user with no problem; but this modify request fails. If I set the ModifyRequest to change some other attribute, such as the email associated, that also works fine.

推荐答案

事实证明,它必须是UTF-16LE恩codeD,然后再转换为base64。

It turns out that it has to be UTF-16LE encoded, and then converted to base64.

val newPass = javax.xml.bind.DatatypeConverter.printBase64Binary(('"'+"Jfi8ZH8#k"+'"').getBytes("UTF-16LE"))

并获得成功。

Did the trick.