Sha256: 6bd7ac3325bdc26fe697cb01ab2eebe86adb7b174dbdfb99b5ffee56a309474a

Contents?: true

Size: 715 Bytes

Versions: 7

Compression:

Stored size: 715 Bytes

Contents

require 'objects/group'

class User < ActiveLdap::Base
  ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=People',
               :classes => ['person', 'posixAccount']
  belongs_to :primary_group, :class => "Group",
             :foreign_key => "gidNumber", :primary_key => "gidNumber"
  belongs_to :groups, :many => 'memberUid'

  # An example of using the old "return_objects" API with the
  # new ActiveRecord-style API.
  alias groups_mapping groups
  def groups(return_objects=true)
    return groups_mapping if return_objects
    attr = 'cn'
    Group.search(:attribute => 'memberUid',
                 :value => id,
                 :attributes => [attr]).map {|dn, attrs| attrs[attr]}.flatten
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
activeldap-0.10.0 examples/objects/user.rb
activeldap-1.0.0 examples/objects/user.rb
activeldap-0.9.0 examples/objects/user.rb
activeldap-1.0.2 examples/objects/user.rb
activeldap-1.0.1 examples/objects/user.rb
ruby-activeldap-0.8.2 examples/objects/user.rb
ruby-activeldap-0.8.3.1 examples/objects/user.rb