From: Ollivier Robert Date: 2004-08-03T17:32:32+09:00 Subject: Re: ruby-LDAP and password change? On Mon, 02 Aug 2004 21:54:04 +0900, Dick Davies wrote: > Just a quickie - anyone have a snippet to update a userPassword? > If not I'll knock one up and stick in on rubygarden.. It is like any modification to a given directory: You need to hash the password: ----- e_password = "{SHA}" + encode64(Digest::SHA1.new(password).digest).chomp ----- then generate the modification: ----- # Do the modification # reset = [ LDAP.mod(LDAP::LDAP_MOD_REPLACE, "userPassword", [e_password]), ] conn.bind(USER, PASS) do begin conn.modify("uid=#{login},#{BASE}", reset) rescue LDAP::ResultError => msg puts "Can't change password: " + msg exit 0 rescue LDAP::Error => errcode puts "Can't change password: " + LDAP.err2string(errcode) exit 0 end end -----