http://qs321.pair.com?node_id=658194

cerror has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I'm working on a portal page which will allow users to change their own password, which is kept in LDAP, however, I'm having trouble getting my sub to actually update the password. I'm using Net::LDAP. Assuming we're connected to LDAP correctly, can you guys/gals spot any problems with this code?

sub updateLDAPpass { my ($user, $pass) = @_; my $mesg = $ldap->bind( "cn=Manager,dc=domain,dc=net", password => 'password' ); my $dn = "cn=$user,dc=domain,dc=net"; my $cryptPword = cryptPass($pass); $cryptPword = "{crypt}". $cryptPword; $mesg = $ldap->modify("$dn", changes => [ replace => [ userPassword => "$cryptPword" +]] ); }

Thanks!

- cerror

Replies are listed 'Best First'.
Re: Problem with LDAP modification
by naChoZ (Curate) on Dec 20, 2007 at 22:00 UTC

    Your $mesg variable is a Net::LDAP::Message object has a variety of error methods associated with it. I'd start there.

    And I'm not 100% certain, but I think the {CRYPT} string needs to be all uppercase.

    --
    naChoZ

    Therapy is expensive. Popping bubble wrap is cheap. You choose.

      On some servers, you cannot update a userPassword string directly(I believe you need to use exop) on yet others, there is password history checking, and a mod will work for one user and not for the next. I'd recommend checking with a command line client to prevent wasting much time.