class UcbGroups::LdapConn

Public Class Methods

authenticate(username, password, host=nil) click to toggle source
# File lib/ucb_groups/ldap_conn.rb, line 11
def self.authenticate(username, password, host=nil)
  @username = username
  @password = password
  @host = host || 'nds.berkeley.edu'
end
authenticate_from_config(config_file) click to toggle source
# File lib/ucb_groups/ldap_conn.rb, line 17
def self.authenticate_from_config(config_file)
  conf = YAML.load_file(config_file)
  self.authenticate(conf['username'], conf['password'], conf['host'])
end
conn() click to toggle source
# File lib/ucb_groups/ldap_conn.rb, line 3
def self.conn
  net_ldap = ::Net::LDAP.new(auth_info)
  net_ldap.bind || raise(BindFailedException)
  net_ldap
rescue ::Net::LDAP::LdapError
  raise(LdapBindFailedException)
end

Private Class Methods

auth_info() click to toggle source
# File lib/ucb_groups/ldap_conn.rb, line 24
def self.auth_info
  @auth_info ||= {
      host: @host,
      auth: {
          method: :simple,
          username: @username,
          password: @password,
      },
      port: 636,
      encryption: { method: :simple_tls }
  }
end