使用unboundid更改LDAP中的用户密码

时间:2015-09-07 09:57:46

标签: java ldap unboundid-ldap-sdk

我正在尝试使用下面的代码更改LDAP中的用户密码,我不是LDAP的管理员,因此我与具有ou = systemusers的用户建立连接,它可以创建用户,以及将用户添加到组。我知道将要进行更改的旧密码

PasswordModifyExtendedRequest passwordModifyRequest =
      new PasswordModifyExtendedRequest(
           "uid=test.user,ou=People,dc=example,dc=com", // The user to update
           (String) null, // The current password for the user.
           (String) null); // The new password.  null = server will generate

 PasswordModifyExtendedResult passwordModifyResult;
 try
 {
   passwordModifyResult = (PasswordModifyExtendedResult)
        connection.processExtendedOperation(passwordModifyRequest);
   // This doesn't necessarily mean that the operation was successful, since
   // some kinds of extended operations return non-success results under
   // normal conditions.
 }
 catch (LDAPException le)
 {
   // For an extended operation, this generally means that a problem was
   // encountered while trying to send the request or read the result.
   passwordModifyResult = new PasswordModifyExtendedResult(
        new ExtendedResult(le));
 }

 LDAPTestUtils.assertResultCodeEquals(passwordModifyResult,
      ResultCode.SUCCESS);
 String serverGeneratedNewPassword =
      passwordModifyResult.getGeneratedPassword();

但我总是得到这个结果。

PasswordModifyExtendedResult(resultCode=50 (insufficient access rights), messageID=4, diagnosticMessage='You do not have sufficient privileges to perform password reset operations') 

如何更改用户密码了解旧密码?

1 个答案:

答案 0 :(得分:2)

您必须以具有足够权限执行操作的用户身份登录,或者更常见的是以用户身份登录,使用旧密码,当然,这是一项额外的健全性检查。否则LDAP服务器配置错误。