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.



128
129
130
# File 'lib/active_directory/rails/user.rb', line 128

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.



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

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.



121
122
123
# File 'lib/active_directory/rails/user.rb', line 121

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.



135
136
137
# File 'lib/active_directory/rails/user.rb', line 135

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