LDAP and Ruby

There is a need for users at my job to create accounts and manage passwords. Since we are bringing online a new Sun One LDAP server for personal use, we have no GUI tools for the end user. Building on our Ruby experience we looked there for help with web tools. There is a method to change userPassword attribute in Ruby (thanks Ollivier Robert):

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
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

Load the Ruby-ldap module and off you go. All there is needed now is an interface for input. Soon we will rule the world…


3 thoughts on “LDAP and Ruby

  1. The rss feed on your root site only loaded once. And now it won’t update new stories. It looks like you had 2 stories. One a welcome and the second the aggregated feeds?

Leave a Reply

Your email address will not be published. Required fields are marked *