Topic: Active Directory Authentication

I have been tasked at work to authenticate my "rails 3 app" with our Active Directory(Windows 2003), before accessing certain pages.

I decided to use "devise_ldap_authenticatable", but can't seem to get it to work properly.

I keep getting redirected to the login page with the following error message showing in the logs.

"Completed 401 Unauthorized in 3ms"

Do I have to change the devise email field to a user-name in order for it to connect successfully?

Has anyone got a working config I could can look at?

My ldap.yml consists of the following:
  host: myip
  port: 389
  attribute: sAMAccountName
  base: cn=Users,dc="mydomain",dc=uk,dc=com 
  admin_user: user
  admin_password: password
  ssl: false

my devise.rb consists of the following:
config.ldap_logger = true
config.ldap_config = "#{Rails.root}/config/ldap.yml"
config.ldap_use_admin_to_bind = true
config.ldap_ad_group_check = false
require 'devise/orm/active_record'
config.authentication_keys = [ :email ]
config.case_insensitive_keys = [ :email ]
config.strip_whitespace_keys = [ :email ]
config.skip_session_storage = [:http_auth]
config.stretches = Rails.env.test? ? 1 : 10
config.reconfirmable = true

my routes.rb consists of the following:

resources :posts devise_for :users root :to => 'posts#index' match ':controller(/:action(/:id))(.:format)'

Any help would be much appreciated!


Last edited by imdev (2012-10-08 09:22:52)