join(RAILS_ROOT,"config","ldap.yml")
LDAP_CONFIG = YAML.load(File.read(ldap_path))[RAILS_ENV]
def self.authenticate username, password
begin
ActiveLDAP::Base.establish_connection(config.merge(
:bind_format => "uid=#{username},cn=users,dc=mycompany,dc=com",
:password => password,
:allow_anonymous => false
))
ActiveLDAP::Base.close
return true
* http://wiki.rubyonrails.org/rails/pages/HowtoAuthenticateViaLdap
126 | Chapter 4: Database
rescue ActiveLDAP::AuthenticationError
return false
end
end
end
Authentication is then very simple:
LdapUser.authenticate "my_username", "password" # => true or false
Further Reading
Chris Date??™s Database in Depth (O??™Reilly) is a very accessible introduction to relational
theory aimed at software developers who are experienced in the use of relational
databases. It reintroduces readers into the technical foundations behind the relational
model.
Theo Schlossnagle??™s Scalable Internet Architectures (Sams) is a short but comprehensive
treatment of ways to accomplish scalability (both high availability and load balancing
are covered); it covers ground from the smallest two-server failover cluster up
to global server load balancing.
Both the MySQL manual (http://dev.mysql.com/doc/) and the PostgreSQL manual
(http://www.postgresql.org/docs/) have a wealth of information about general database
topics, as well as specific information pertaining to the use of those DBMSs.
Pages:
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198