Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally was able to manage to integrate AD in ActiveAdmin.<p> Here's what I did, in case someone is interested:</p> <ul> <li>Include gem 'adauth' in your gems<p></li> <li>Execute bundle install <p></li> <li><p>Execute rails g adauth:config<p></p></li> <li><p>Configure the config/initializers/adauth.rb for your AD connection. For example, if your domain is example.com, you must include:<p></p> <pre><code>c.domain = "example.com" c.server = "IP address of your domain controller" c.base = "dc=example, dc=com" </code></pre></li> <li><p>Execute rails g adauth:sessions<p></p></li> <li><p>Modify your application_controller.rb. Mine was:<p></p> <pre><code>class ApplicationController&lt; ActionController::Base protect_from_forgery helper_method :current_user def current_user @current_user ||= User.find(session[:user_id]) if session[:user_id] end def authenticate_user! if current_user.nil? redirect_to '/sessions/new', :error =&gt; "Invalid Login" end end end </code></pre></li> <li><p>Execute rails g adauth:user_model user install_adauth. This creates the migration install_adauth, but for some reason it was empty. I had to fill it myself with:<p></p> <pre><code>class InstallAdauth &lt; ActiveRecord::Migration def up create_table :users do |u| u.string 'login' u.text 'group_strings' u.string 'name' u.string 'ou_strings' end end def down drop_table :users end end </code></pre></li> <li><p>Execute rake db:migrate</p></li> <li><p>Modify your sessions_controller.rb. Mine was:</p> <pre><code>class SessionsController &lt; ApplicationController def new redirect_to '/admin' if current_user end def create ldap_user = Adauth.authenticate(params[:username], params[:password]) if ldap_user user = User.return_and_create_with_adauth(ldap_user) session[:user_id] = user.id redirect_to '/admin' else redirect_to '/sessions/new', :error =&gt; "Invalid Login" end end def destroy session[:user_id] = nil redirect_to '/sessions/new' end end </code></pre></li> <li><p>So far the validation through ActiveAdmin still works. To switch to ActiveDirectory we must change the file initializers/active_admin.rb</p> <pre><code># config.authentication_method = :authenticate_admin_user! config.authentication_method = :authenticate_user! #config.current_user_method = :current_admin_user config.current_user_method = :current_user </code></pre></li> <li><p>In my case, I needed to restart Apache too.</p></li> </ul> <p>If anytime we want to switch back to ActiveAdmin, we just need to undo the last change</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload