Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Problem with LDAP modification

by cerror (Scribe)
on Dec 20, 2007 at 18:03 UTC ( #658194=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://658194]
Approved by holli
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-11-29 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?