Class: FfcrmLdap::LDAPAccess

Inherits:
Object
  • Object
show all
Defined in:
lib/ffcrm_ldap/ldap_access.rb

Defined Under Namespace

Classes: Config

Class Method Summary collapse

Class Method Details

.authenticate(uid, password) ⇒ Object

Attempts to bind to LDAP using the given username and password returns true if successful, false otherwise.



7
8
9
10
11
12
13
14
# File 'lib/ffcrm_ldap/ldap_access.rb', line 7

def authenticate(uid, password)
  ldap = connect()
  result = ldap.bind_as(
    :base => Config.search_base,
    :filter => sprintf(Config.user_filter, uid),
    :password => password)
  return !!result
end

.get_user_details(uid) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ffcrm_ldap/ldap_access.rb', line 16

def get_user_details(uid)
  ldap = connect()

  results = ldap.search(
    :base => Config.search_base,
    :filter => Config.user_filter % uid )
  if results and results.size > 0
    details = {}
    results[0].each do |name, values|
      details[name] = values[0].dup
    end
    details
  else
    nil
  end
end