class Auth42::SimpleAuth
Constants
- S_BASE
- S_ENCRYPTION
- S_PORT
- S_URL
Public Class Methods
authenticate(user, password)
click to toggle source
# File lib/auth_42/simple_auth.rb, line 20 def self.authenticate(user, password) c = Net::LDAP.new( :host => S_URL, :port => S_PORT, :base => S_BASE, :encryption => S_ENCRYPTION, :username => user, :password => password ) if c.bind return true else return false end end
new()
click to toggle source
constructor method
# File lib/auth_42/simple_auth.rb, line 12 def initialize @handler = self.getHandler end
Public Instance Methods
handler()
click to toggle source
# File lib/auth_42/simple_auth.rb, line 16 def handler @handler end
search(query: "", filter: "", login: "", password: "")
click to toggle source
# File lib/auth_42/simple_auth.rb, line 36 def search(query: "", filter: "", login: "", password: "") if !login.empty? and !password.empty? @handler = self.getAuthHandler(login, password) end if self.connect q = {} q[:filter] = filter unless filter.empty? q[:attributes] = query unless query.empty? results = @handler.search(q) end end
Protected Instance Methods
connect()
click to toggle source
# File lib/auth_42/simple_auth.rb, line 72 def connect @connected = @handler.bind end
getAuthHandler(user, password)
click to toggle source
# File lib/auth_42/simple_auth.rb, line 60 def getAuthHandler(user, password) c = Net::LDAP.new( :host => S_URL, :port => S_PORT, :base => S_BASE, :encryption => S_ENCRYPTION, :username => user, :password => password ) c end
getHandler()
click to toggle source
# File lib/auth_42/simple_auth.rb, line 50 def getHandler c = Net::LDAP.new( :host => S_URL, :port => S_PORT, :base => S_BASE, :encryption => S_ENCRYPTION ) c end