Module: ActiveDirectory::Rails::User::ClassMethods

Defined in:
lib/active_directory/rails/user.rb

Instance Method Summary collapse

Instance Method Details

#activeObject

Retrieves all Person objects that are currently active, meaning they have not been disabled by PeopleSynchronizer.



105
106
107
# File 'lib/active_directory/rails/user.rb', line 105

def active
	find(:all, :conditions => 'username != ""')
end

#authenticate(username, password) ⇒ Object

Attempt to authenticate someone with a username and password. This method properly handles both local store users and AD users.

If the username is valid, and the password matches the username, the Person object corresponding to the username is return.

Otherwise, nil is returned, to indicate an authentication failure.



87
88
89
90
91
# File 'lib/active_directory/rails/user.rb', line 87

def authenticate(username, password)
	person = find_by_username(username)
	return person if (person and person.authenticates?(password))
	nil
end

#in_active_directoryObject

Retrieves all of the Person objects that have corresponding Active Directory accounts. This method does not contact the AD servers to retrieve the AD objects – that is left up to the caller.



98
99
100
# File 'lib/active_directory/rails/user.rb', line 98

def in_active_directory
	find(:all, :conditions => 'guid IS NOT NULL AND guid != ""')
end

#inactiveObject

Retrieves all Person objects that are currently inactive, meaning they have been disabled by PeopleSynchronizer.



112
113
114
# File 'lib/active_directory/rails/user.rb', line 112

def inactive
	find(:all, :conditions => 'username = ""')
end