Change user password in LDAP using unboundid

不打扰是莪最后的温柔 提交于 2019-12-25 14:22:35

问题


I'm trying to change the user password in LDAP, using the code below, I'm not the admin of the LDAP, so I make the connection with a user that have ou=systemusers, it can create users, and add the users to a group. I know the old password for the use that will do the change

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();

but I always get this result.

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

How can I change the user password Knowing the old password?


回答1:


You have to login either as a user with sufficient privileges to perform the operation, or, more usually as the user himself, using the old password, of course, which is an extra sanity check. Or else the LDAP server is misconfigured.



来源:https://stackoverflow.com/questions/32435841/change-user-password-in-ldap-using-unboundid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!