9

I have an LDIF file that contains a bunch of test users.

I would like to change the password for some of these users and was wondering what would be the best way to do so.

Saikat
  • 14,222
  • 20
  • 104
  • 125
Joly
  • 3,218
  • 14
  • 44
  • 70

1 Answers1

12

Use ldapmodify with LDIF, for example:

ldapmodify -h hostname -p port -D dn -w password <<!
dn: uid=user,dc=example,dc=com
changetype: modify
replace: userPassword
userPassword: new-password
!

or specify a filename:

ldapmodify -c -a -f file.ldif -h hostname -p port -D dn -w password

Of course, use the correct attribute names, distinguished names, and so forth. The distinguished name used for the bind of the ldapmodify tool must have access rights to modify the password of the distinguished name specified in the LDIF.

see also

Community
  • 1
  • 1
Terry Gardner
  • 10,957
  • 2
  • 28
  • 38
  • 1
    Should that exclamation point be there at the end of the sample ldapmodify command? – jeremiah Jan 06 '17 at 22:26
  • 2
    Notice that if you specify a password in plain text it will be stored in **plain text** (Base64 encoded). If you are using OpenLDAP consider to use the `slappasswd` command for generating hashed password. – xonya May 12 '17 at 13:01