Modify passwords in an LDIF file using ldapmodify command
Asked Answered
L

2

11

I have a LDIF file that consists of a set of test users and I would like to change the passwords for these users.

I used the ldapmodify command:

ldapmodify -c -a -f filename.ldif -h localhost -p <port> -D dn -w <pwd> << !

dn: uid=<userid>,dc=<branch>,DC=COM
changetype: modify
replace: userPassword
userPassword: <new pwd>
!

And I get the following error:

ldap_sasl_interactive_bind_s: Can't contact LDAP server (-1)
  1. What does this mean?
  2. The syntax I have used can be used for only one user, I would like to modify the passwords of all the test users in my LDIF file. Is there a way to do so?
Lydia answered 14/6, 2012 at 15:47 Comment(0)
N
14

The given error is an indication that the server specified by the hostname and port could not be contacted, that is, a connection could not be established. Also, the legacy OpenLDAP ldapmodify client defaults to a SASL bind when the -x command line option is not specified.

The LDIF input can contain any number of entries to be modified, not just one:

dn: uid=abc,dc=example,dc=com
changetype: modify
replace: userPassword
userPassword: the-new-password

dn: uid=def,dc=example,dc=com
changetype: modify
replace: userPassword
userPassword: another-new-password

see also

Nesline answered 14/6, 2012 at 17:52 Comment(2)
Thanks a lot Terry. Now I can understand how it works. When I add -x to my command I get the following error, "ldap_result: Can't contact LDAP server (-1)"Lydia
Having gone through "Mastering ldapmodify", this is the command I am using, ldapmodify -x -h localhost -p 4444 -D 'cn=root' -w <pwd> -c -f /tmp.ldif and I get the following error "ldap_result: Can't contact LDAP server (-1)"Lydia
I
1
ldapmodify -p 389 -D "" -w -a -c v -f pwd.ldif

pwd.ldif has below

dn: cn=config
changetype: modify
replace: root-dn-pwd
root-dn-pwd: xxxxxxx
Intake answered 10/12, 2013 at 4:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.