Module: LdapRails

Defined in:
lib/ldap-rails/config.rb,
lib/ldap-rails/version.rb,
lib/ldap-rails/ldap_user.rb,
lib/ldap-rails/helper_extensions.rb,
lib/ldap-rails/controller_extensions.rb

Defined Under Namespace

Modules: ControllerExtensions, HelperExtensions Classes: InvalidConfigurationError, LdapUser, NoConfigurationError

Constant Summary collapse

VERSION =
"0.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/ldap-rails/config.rb', line 5

def config
  @config
end

.ldapObject (readonly)

Returns the value of attribute ldap.



6
7
8
# File 'lib/ldap-rails/config.rb', line 6

def ldap
  @ldap
end

Class Method Details

.configure(config) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ldap-rails/config.rb', line 8

def configure config
  # config[:host] is required
  unless config[:host]
    raise InvalidConfigurationError.new("Must provide :host to LdapRails.configure")
  end

  # store and autocomplete the config
  @config = config
  autocomplete_config

  # create a Net::LDAP
  opts = {:host => config[:host], :port => config[:port]}

  if config[:ssl]
    opts[:encryption] = :simple_tls
  end

  @ldap = Net::LDAP.new opts
end