lib/cratus/group.rb
def member_of
      memrof_attr = Cratus.config.group_memberof_attribute

      # TODO: make this work with more things...
      unless @raw_ldap_data
        STDERR.puts "WARNING: Group '#{@name}' appears to be invalid or beyond the search scope!"
        return []
      end

      # TODO: move the search filter to a configurable param
      if Cratus.config.include_distribution_groups
        raw_groups = @raw_ldap_data[memrof_attr]
      else
        raw_groups = @raw_ldap_data[memrof_attr].reject { |g| g.match(/OU=Distribution Groups/) }
      end
      initial_groups = raw_groups.map do |raw_group|
        Group.new(raw_group.match(/^#{Group.ldap_dn_attribute.to_s.upcase}=([^,]+),/)[1])
      end
      all_the_groups = initial_groups
      initial_groups.each do |group|
        all_the_groups.concat(group.member_of) # recursion!
      end
      all_the_groups.uniq(&:name)
    end
def member_of
      memrof_attr = Cratus.config.group_memberof_attribute

      # TODO: make this work with more things...
      unless @raw_ldap_data
        STDERR.puts "WARNING: Group '#{@name}' appears to be invalid or beyond the search scope!"
        return []
      end

      # TODO: move the search filter to a configurable param
      if Cratus.config.include_distribution_groups
        raw_groups = @raw_ldap_data[memrof_attr]
      else
        raw_groups = @raw_ldap_data[memrof_attr].reject { |g| g.match(/OU=Distribution Groups/) }
      end
      initial_groups = raw_groups.map do |raw_group|
        Group.new(raw_group.match(/^#{Group.ldap_dn_attribute.to_s.upcase}=([^,]+),/)[1])
      end
      all_the_groups = initial_groups
      initial_groups.each do |group|
        all_the_groups.concat(group.member_of) # recursion!
      end
      all_the_groups.uniq(&:name)
    end
Recursively determine group memberships of a group