Class: SimpleAD::User
- Inherits:
-
Object
- Object
- SimpleAD::User
- Defined in:
- lib/simple_ad.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.authenticate(username, password, ad_options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_ad.rb', line 8 def self.authenticate(username, password, ) return nil if username.empty? or password.empty? # Nothing to see here. No username / password supplied. # Open a new LDAP connection with the specified options conn = Net::LDAP.new host: [:server], port: [:port] || 389, base: [:base], auth: { :username => "#{username}@#{ad_options[:domain]}", :password => password, :method => :simple } # If we can authenticate successfully and find ourselves, we're in. if conn.bind and user = conn.search(:filter => "sAMAccountName=#{username}").first return self.new(user) else # Failed authentication return nil end rescue Net::LDAP::LdapError => e return nil end |
Instance Method Details
#member_of?(group) ⇒ Boolean
31 32 33 34 |
# File 'lib/simple_ad.rb', line 31 def member_of?(group) # TODO: Implement the member_of function to test against AD group membership raise NotImplementedError end |