Skip to content
Olivier edited this page Sep 28, 2016 · 2 revisions

Adauth::Rails::ModelBridge provides a link between any Adauth Model and any Rails Model.

# Usage

If you had a user model which looked like this:

class User < ActiveRecord::Model
    attr_accessor :username
end

And you wanted to link it to users in AD you would change it to look like this:

class User < ActiveRecord::Model
    include Adauth::Rails::ModelBridge
    
    attr_accessor :username

    AdauthMappings = {
        :username => :login
    }

    AdauthSearchField = [:login, :username]
end

This includes Adauth::Rails::ModelBridge and defines the constants it requires.

AdauthMappings

These tell ModelBridge which Adauth fields to use to populate the specified Rails field.

You can have as many fields here as you want.

The format for each line is:

:rails_field => :adauth_field

AdauthSearchField

This tells ModelBridge which field to use as the "key", normally wants to be set to username or something similar.

The format for this is:

[:adauth_field, :rails_field]