Once I need to reset login shell for all users. Here is easy solution, one simple loop
Of course, you can put instead of loginShell any other parameters. Don't forget, to change multiply parameters put '-' separator:
*****
echo "replace: userPassword" >> $LDIF_FILE
echo "userPassword: $PASSWD_SSHA" >> $LDIF_FILE
echo "-" >> $LDIF_FILE
echo "replace: sambaNTPassword" >> $LDIF_FILE
echo "sambaNTPassword: $sambaNTPassword" >> $LDIF_FILE
SAVEIFS=$IFS; IFS=$(echo -en "\n\b"); for i in $(ldapsearch -h localhost -p 389 -D "cn=Manager,dc=<yourdomain>,dc=com" -w "<Manager's passwd>" -s sub -b "ou=Users,dc=<yourdomain>,dc=com" | grep -v root | grep "dn:") do LDIF_FILE=/tmp/loginShell.ldif; echo "${i}" > $LDIF_FILE; echo "changetype: modify" >> $LDIF_FILE; echo "replace: loginShell" >> $LDIF_FILE; echo "loginShell: /usr/sbin/user_shell" >> $LDIF_FILE; /usr/bin/ldapmodify -h localhost -p 389 -D "cn=Manager,dc=<yourdomain>,dc=com" -w "<Manager's passwd>" -f $LDIF_FILE; done; IFS=$SAVEIFS;
Of course, you can put instead of loginShell any other parameters. Don't forget, to change multiply parameters put '-' separator:
*****
echo "replace: userPassword" >> $LDIF_FILE
echo "userPassword: $PASSWD_SSHA" >> $LDIF_FILE
echo "-" >> $LDIF_FILE
echo "replace: sambaNTPassword" >> $LDIF_FILE
echo "sambaNTPassword: $sambaNTPassword" >> $LDIF_FILE
No comments:
Post a Comment