The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Switched to pure ruby ldap library

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Matt Parrish

Posts: 12
Nickname: mparrish
Registered: Jun, 2007

Matt Parrish is founder and lead developer of Pearware LLC, a Ruby on Rails web development company
Switched to pure ruby ldap library Posted: Jun 1, 2007 3:50 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Matt Parrish.
Original Post: Switched to pure ruby ldap library
Feed Title: pearware blog - agile web development
Feed URL: http://blog.pearware.org/feed/atom.xml
Feed Description: Agile web development using Ruby on Rails (and sometimes Java)
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Matt Parrish
Latest Posts From pearware blog - agile web development

Advertisement

I wrote an article awhile back about using the Ruby/LDAP library to handle LDAP authentication in Ruby on Rails. I just finished swapping out the LDAP client library in that application from Ruby/LDAP to ruby-net-ldap. The problems with Ruby/LDAP are that it isn’t a GEM, so installation is a bit more difficult, and it relies on a common LDAP library, like OpenLDAP, to already be installed on the system. The ruby-net-ldap library is written in pure Ruby, so no other library needs to be installed on the system.

Here is the new code that performs the authentication:

require "net/ldap" 

class User < ActiveRecord::Base
  def self.authenticate(login, password, host, port)
    if login.to_s.length > 0 and password.to_s.length > 0
      ldap = Net::LDAP.new
      ldap.host = host
      ldap.port = port
      ldap.auth = "cn=#{login},cn=users,o=xyz...", password
      if ldap.bin
        return find(:first, :conditions => ['username=?', login])
      else
        return false
      end
    end
  end
end

Read: Switched to pure ruby ldap library

Topic: Installing MySQL For Ruby On Rails Previous Topic   Next Topic Topic: New Version of the Cruise Control Configuration Tool

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use