Loading....
Recent Article links:

Article

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

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…

Related Stuff

  • LDAP and me
  • Lone Star Ruby Conference
  • Sun One and eduperson LDIF
  • About the author

    Ruben Ruiz

    I spent most of my professional career working with colleges to discover, teach and deploy technology that is conducive to learning. I am an avid outdoors man, competitor, amateur photographer, and a lover of gadgets, I spend most of my free time with my family exploring the vast trail network that surrounds the greater Austin area.

    Comments (3 comments)

    Are you using the native ruby ldap module? ruby-net-ldap?

    [Reply]


    Manuel / Thursday, June 14th, 2007, 2:49 pm

    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?

    [Reply]


    Manuel / Thursday, June 14th, 2007, 2:50 pm

    no, I am using ruby-ldap:
    http://sourceforge.net/projects/ruby-ldap/

    I am looking at ruby-net-ldap but we are authenticating using ruby-ldap.

    As for the rss feeder from the root site, yes it only updates on a refresh and does not work regularly. I need to fix that.

    [Reply]


    ruben / Thursday, June 14th, 2007, 9:34 pm

    What do you think?

    « Back to text comment

    My Google

    My Communities

    My Cohorts