Changing LDAP users password

8.9k views Asked by At

I have established a LDAP Connection using admin credentials like as shown below

LDAPConnection connection;
try {
    connection = new LDAPConnection("example.domain.com", 345);  
    BindResult auth = connection.bind("adminUsername","adminPassword");

} catch (LDAPException e) {
    System.out.println(e);
} 

The connection is successfully.

Now the requirement is admin wants to change the users password.

Can anyone please tell me how we can do that

I am using unboundid-ldap-sdk-for-java

2

There are 2 answers

0
Bertold Kolics On BEST ANSWER

Alex,

Here is an example: https://gist.github.com/bertold/002491a2630a98d80733b8228f75b75c

I hope this helps.

1
anacron On

LDAP servers that I have worked with generally have an attribute named userPassword that contains (as you rightly guessed!) the user's password. After you perform a bind using the admin credentials, you will need to lookup the user's profile whose password you want to change and then set the new password to the userPassword attribute. Since you are using the admin ID, you will not need to know the old password.

Hope this helps!