class LdapFluff

Constants

CONFIG

Module constants

Attributes

ldap[RW]

Public Class Methods

new(config=nil) click to toggle source
# File lib/ldap_fluff/ldap_fluff.rb, line 7
def initialize(config=nil)
  config ||= LdapFluff::Config.instance
  type = config.server_type
  if type.respond_to? :to_sym
    if type.to_sym == :posix
      @ldap = Posix.new(config)
    elsif type.to_sym == :active_directory
      @ldap = ActiveDirectory.new(config)
    elsif type.to_sym == :free_ipa
      @ldap = FreeIPA.new(config)
    else
      raise Exception, "Unsupported connection type. Supported types = :active_directory, :posix, :free_ipa"
    end
  end
end

Public Instance Methods

authenticate?(uid, password) click to toggle source

return true if the user password combination authenticates the user, otherwise false

# File lib/ldap_fluff/ldap_fluff.rb, line 25
def authenticate?(uid, password)
  if password.nil? || password.empty?
    # protect against passwordless auth from ldap server
    return false
  else
    @ldap.bind? uid, password
  end
end
group_list(uid) click to toggle source

return a list[] of groups for a given uid

# File lib/ldap_fluff/ldap_fluff.rb, line 35
def group_list(uid)
  @ldap.groups_for_uid(uid)
end
is_in_groups?(uid, grouplist) click to toggle source

return true if a user is in all of the groups in grouplist

# File lib/ldap_fluff/ldap_fluff.rb, line 41
def is_in_groups?(uid, grouplist)
  @ldap.is_in_groups(uid, grouplist, true)
end