Rails and Windows Active Directory Authentication?


#1

Hello All, I know there is a component for integrating LDAP with Rails
but
is anyone doing any Windows Active Directory Authentication to a Rails
app?

I am rebuilding a site that was constructed out of asp and I would like
to
rebuild/improve it via rails. On the requirements side I will need to
communicate with Active Directory and I will be required to use MSSQL
for
the database. Can anyone point me towards some tutorials, examples etc.
where I can see how others are tackling issues with bringing Rails into
an
MS dominant enterprise. I may be able to convince the managers to allow
me
to bring in a server that’s configured with Linux, Lighty and FCGI or
SCGI
but I will still need to contend with AD Authentication and legacy data
stored on several MSSQL servers. Any guidance will be much appreciated.

I need to log in via AD and then set various session variables that
will/can be used throughout a users session. Any examples?

Thank you!


#2

On the requirements side I will need to
communicate with Active Directory and I will be required to use MSSQL for
the database. Can anyone point me towards some tutorials, examples etc.
where I can see how others are tackling issues with bringing Rails into an
MS dominant enterprise.

For MS AD authentication I am currently using:

  • Installed ruby-ldap

  • Installed login_generator gem and let the generator build its basic
    setup

  • Modified the generated user model:
    require ‘ldap’
    require ‘ldap/control’

    class User
      def self.authenticate(username, password)
        return false if username.to_s.size == 0
        return false if password.to_s.size == 0
    
        conn = LDAP::Conn.new("<AD SERVER NAME>", 389)
    
        conn.set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, 3 )
    
        begin
          conn.simple_bind(username, password)
        rescue
          return false
        end
    
        return conn.bound?
      end
    end
    

For access to MSSQL (from rails on Linux), I did use:

  • Installed and configured ODBC on the Linux box to connect to MS SQL
  • Used an adapted ActiveRecord connection adapter:
    # odbc_adapter.rb – ActiveRecord adapter for ODBC
    #
    # adapted from:
    # sqlserver_adapter.rb – ActiveRecord adapter for Microsoft
    SQL Server
    #
    # Author: Joey G. removed_email_address@domain.invalid
    # Date: 10/14/2004
    #
    # Modifications: DeLynn B. removed_email_address@domain.invalid
    # Date: 3/22/2005

#3

On 2/21/06, removed_email_address@domain.invalid removed_email_address@domain.invalid wrote:

On the requirements side I will need to
communicate with Active Directory and I will be required to use MSSQL for
the database. Can anyone point me towards some tutorials, examples etc.
where I can see how others are tackling issues with bringing Rails into an
MS dominant enterprise.

For MS AD authentication I am currently using:

  • Installed ruby-ldap
  • Installed login_generator gem and let the generator build its basic setup

You’re doing this from Linux, right? To my knowledge, Ruby/LDAP still
doesn’t work on Windows. With the help of the maintainer, I finally
managed to make it build, but it instantly segfaults the interpreter
when you touch it in any way.


#4

For MS AD authentication I am currently using:

  • Installed ruby-ldap
  • Installed login_generator gem and let the generator build its basic setup

You’re doing this from Linux, right? To my knowledge, Ruby/LDAP still
doesn’t work on Windows. With the help of the maintainer, I finally
managed to make it build, but it instantly segfaults the interpreter
when you touch it in any way.

Yes, Linux.