Dear List People
Someone here could please send me some advice on changin' LDAP passwords? It seems that everything is working nice, except by dovecot: I can send emails using my new LDAP password trought postfix smtp authentication, I can login to my Intranet website and to the Mod-LDAP protected pages on my company. I just can't POP my mail messages, because Dovecot says
"dovecot-auth: ldap(user@company.net): password mismatch".
I guess this is because I'm incorrectly coding the password. Please help me to figure out the right way to crypt the password so Dovecot can read this from the LDAP.
*Extra* *Information:*
I made a simpler and smaller test version of the program that I use to change passwords, its attached to the email. The essentials are there.
*Versions:*
My dovecot is a Debian/Sarge (Stable) 3.1 package. I'm also using Perl, Net::LDAP, Apache with Mod_Perl and OpenLDAP. Everything on linux, of course.
Package Version
dovecot-common 0.99.14-1sarge0 dovecot-imapd 0.99.14-1sarge0 dovecot-pop3d 0.99.14-1sarge0 perl 5.8.4-8sarge4 libnet-ldap-perl 0.3202-3 apache-perl 1.3.33-6sarge2 slapd 2.2.23-8 kernel-image-2.4.2 2.4.27-10sarge1
Any help, suggestion or comment are welcome. Thank you all in advance.
-- Luis Motta Campos Segula Technologies Portugal http://www.segula.pt/
#!/usr/bin/perl use strict; use warnings; use Net::LDAP; use Carp qw( croak );
# Connects to server my $ldap = new Net::LDAP( 'localhost' ) or croak $@; my $message = $ldap->bind( 'uid=user,ou=People,dc=company,dc=com', password => 'secret' ); croak $message->error if $message->is_error;
# Locate user $message = $ldap->search( base => 'ou=People, dc=company, dc=com', filter => 'uid=user', scope => 'one' ); croak $message->error if $message->is_error; my $entry = $message->entry(0); croak 'Nobody found!?!' unless $entry;
# Replace password. $entry->replace( userPassword => '{CRYPT}'. crypt( 'secret', join( '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64] ) ) ); $message = $entry->update( $ldap ); croak $message->error if $message->is_error;
# Report results. print q{User password changed to: "}.$entry->get_value( 'userPassword' ).qq{".\n};