0

I'm trying to modify a lot of users logins without a certain pattern in LDAP from a text file but I'm getting errors:

This is my try:

#!/bin/bash
for i in `cat users.txt`; do ldapmodify -h 10.X.X.X -p 389 -x -D "cn=admin" -w password; done << EOF
dn: cn=$i,ou=Userstomodify,o=wkd
changetype:modify
replace:telexnumber
telexnumber:19900101
EOF

ldapmodify is working OK in a terminal manually but not in this script.

1

Your code is broken!

You want to modify the LDAP entries for every user in users.txt, not just the first, right ?

Try this:

#!/bin/bash
echo -n Password: 
read -s password

for i in `cat users.txt`; do ldapmodify -h 10.X.X.X -p 389 -x -D "cn=admin" -w $password << EOF
dn: cn=$i,ou=Userstomodify,o=wkd
changetype:modify
replace:telexnumber
telexnumber:19900101
EOF
done
  • That's not working. I'm getting error in line 12 – Gallo Jul 13 '17 at 9:13
  • Yeah, sorry, I had not tested my latest change ... was attempting to hide the password ... thanks for letting me know and, next time, I will test every change I make to code! – thecarpy Jul 13 '17 at 10:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.