Class: AD::Authentication
- Inherits:
-
Object
- Object
- AD::Authentication
- Defined in:
- lib/ad/authentication.rb
Instance Attribute Summary collapse
-
#bind_user ⇒ Object
readonly
Returns the value of attribute bind_user.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #authenticate(username, password) ⇒ Object
-
#initialize(connection = AD::ConnectionFactory.service_user_connection) ⇒ Authentication
constructor
A new instance of Authentication.
Constructor Details
#initialize(connection = AD::ConnectionFactory.service_user_connection) ⇒ Authentication
Returns a new instance of Authentication.
5 6 7 |
# File 'lib/ad/authentication.rb', line 5 def initialize(connection = AD::ConnectionFactory.service_user_connection) @connection = connection end |
Instance Attribute Details
#bind_user ⇒ Object (readonly)
Returns the value of attribute bind_user.
9 10 11 |
# File 'lib/ad/authentication.rb', line 9 def bind_user @bind_user end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
9 10 11 |
# File 'lib/ad/authentication.rb', line 9 def connection @connection end |
Instance Method Details
#authenticate(username, password) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ad/authentication.rb', line 11 def authenticate(username, password) @bind_user = nil return false if username.blank? || password.blank? result = @connection.bind_as( base: AD.base_dn, filter: Net::LDAP::DN.new(AD.unique_id_attr, username.strip).to_s, password: password.to_s ) @bind_user = result[0] if result @bind_user ? true : false end |