This gem is still under development and is not completed yet, but when it's done it will be a plugin for Authlogic to allow for LDAP authentication.
Authentication against a database before checking LDAP. Create a user in the database, if they exist in LDAP.
script/plugin install git://github.com/pol/authlogic_ldap.git
optionally add ldap user/pass columns to your user model
add ldap configuration options to your user and sessions models
After installing the plugin, I decide I do not wish to add ldap_user and ldap_password columns to my database.
I add the following to my User model:
acts_as_authentic do |config| config.validate_ldap_login false end
This makes it so that there won't be any validations run on the ldap_login column (because I don't have one).
Next, I edit the UserSession model and add some configuration options:
ldap_host 'ldapserver.myschool.edu' ldap_login_format "uid=%s,ou=People,o=ldapserver.myschool.edu,o=cp" find_by_ldap_login_method :find_by_login
These are likely to be different for your particular setup. The last config option is to set the ActiveRecord finder for my user to be “find_by_login” because I don't have an ldap_login column.
And, that should do it. The system expects that your users exist in the local system before they are authenticated to the LDAP server. This will be made more functional in the future (see the Todo.rdoc for more information.)
(The MIT License)
Copyright © 2009 FIX
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.