Class: Adauth::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/adauth/group.rb

Overview

Active Directory Group object

Called as:

Adauth::Group.find(name)

Returns an instance of Adauth::Group for the group specified in the find method

Constant Summary collapse

ATTR_SV =

Single vales where the method maps directly to one Active Directory attribute

{
    :name => :name,
    :dn => :distinguishedname
}
ATTR_MV =

Multi values were the method needs to return an array for values.

{
    :ous => [ :distinguishedname,
                   Proc.new {|g| g.sub(/.*?OU=(.*?),.*/, '\1')} ]
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(name) ⇒ Object

Finds the group specified

Called as:

Adauth::Group.find(name)

Returns an instance of Adauth::Group for the group specified in the find method



29
30
31
32
33
34
35
36
# File 'lib/adauth/group.rb', line 29

def self.find(name)
    @conn = Adauth::AdminConnection.bind
    if group = @conn.search(:filter => Net::LDAP::Filter.eq('name', name)).first
        return self.new(group)
    else
        return nil
    end
end

Instance Method Details

#membersObject

Returns the members of the group

Called as:

Adauth::Group.members

Returns an array of Adauth::Users for the group



44
45
46
47
48
49
50
51
52
53
# File 'lib/adauth/group.rb', line 44

def members
    filters = Net::LDAP::Filter.eq("memberof","CN=#{name},#{dn}")
    members_ldap = @conn.search(:filter => filters)
    members = []
    members_ldap.each do |member|
        user = Adauth::User.(member.samaccountname.first)
        members.push(user)
    end
    return members
end