问题
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