Net::LDAP with imapsync ?
Net::LDAP - Lightweight Directory Access Protocol - search.cpan.org
Another method might involve generating an LDIF file to describe your changes and running ldapmodify against it.
http://tldp.org/HOWTO/LDAP-HOWTO/utilities.html
(If you ldapmodify a password and precede the value with {CRYPT} or {SSHA}, it will not encrypt/hash the value provided.)
If you are comparing passwords, you will need to know what the encrypted/hashed password looks like, for instance:
{CRYPT}103Ld3rC9IOzs == secret123
then you could ldapmodify the password as
dn: uid=someuser....
changetype: modify
replace: userpassword
userpassword: {CRYPT}103Ld3rC9IOzs
When you later search on the directory entry's password, the value returned should look like {CRYPT}103Ld3rC9IOzs
If you did not precede the password with {CRYPT} then the modify would encrypt it again:
dn: uid=someuser....
changetype: modify
replace: userpassword
userpassword: 103Ld3rC9IOzs
Which might end up being:
dn: uid=someuser....
userpassword: {CRYPT}47cA/2SSvmsoo
{CRYPT}47cA/2SSvmsoo == 103Ld3rC9IOzs != secret123
Experiment with ldapmodify to validate your results.
OpenLDAP Faq-O-Matic: Passwords