= ActiveLdap plugin for Ruby on Rails

== Setup

You need to write RAILS_ROOT/config/ldap.yml like the following:

  development:
    host: 127.0.0.1
    port: 389
    base: dc=devel,dc=local,dc=net
    bind_dn: cn=admin,dc=local,dc=net
    password: secret

  test:
    host: 127.0.0.1
    port: 389
    base: dc=test,dc=local,dc=net
    bind_dn: cn=admin,dc=local,dc=net
    password: secret

  production:
    host: 127.0.0.1
    port: 389
    base: dc=production,dc=local,dc=net
    bind_dn: cn=admin,dc=local,dc=net
    password: secret

== Model

Here is some examples.

app/model/member.rb:
  class Member < ActiveLdap::Base
    ldap_mapping :dn_attribute => 'uid',
                 :classes => ['person', 'posixAccount']
    belongs_to :primary_group, :class_name => "Group",
               :foreign_key => "gidNumber", :primary_key => "gidNumber"
    belongs_to :groups, :many => 'memberUid'
  end

app/model/group.rb:
  class Group < ActiveLdap::Base
    ldap_mapping :dn_attribute => "cn", :classes => ['posixGroup']
    has_many :members, :wrap => "memberUid"
    has_many :primary_members,
             :foreign_key => 'gidNumber',
             :primary_key => 'gidNumber'
  end

app/model/ou.rb:
  class Ou < ActiveLdap::Base
    ldap_mapping :prefix => "",
                 :classes => ["top", "organizationalUnit"]
  end
