# How to use LDAP with htaccess file in rails

**URL:** <https://www.ruby-forum.com/t/how-to-use-ldap-with-htaccess-file-in-rails/206872>\
**Category:** Rails\
**Created:** [May 12, 2011, 8:51am UTC](https://www.ruby-forum.com/t/how-to-use-ldap-with-htaccess-file-in-rails/206872 "2011-05-12T08:51:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 12, 2011, 8:51am UTC](https://www.ruby-forum.com/t/how-to-use-ldap-with-htaccess-file-in-rails/206872/1 "2011-05-12T08:51:45Z")

</div>

Can anyone help me set up LDAP using .htaccess method is Ruby on  
Rails. I have been looking on line for hours and there are some  
examples, but know examples explain where to put things in the rails  
directories and what file names to use. I have seen references to  
ruby-net-ldap as well, but the examples incomplete. Any help would be  
appreciated.

thanks in advance.

-Wayne

---

<div class="post-metadata">

**Author:** ![Wayne\_Marquette](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/a87d85/32.png) [@Wayne\_Marquette](https://www.ruby-forum.com/u/Wayne_Marquette)\
**Post date:** [May 12, 2011, 1:14pm UTC](https://www.ruby-forum.com/t/how-to-use-ldap-with-htaccess-file-in-rails/206872/2 "2011-05-12T13:14:56Z")

</div>

Hi!

1. First you configure your apache to read you LDAP server.  
Look into apache documentation:  
[mod\_auth\_ldap - Apache HTTP Server](http://httpd.apache.org/docs/2.0/mod/mod_auth_ldap.html)  
I’m not sure if you can use .htaccess for this one. Try by  
“virtualhost” configuration.

2. After you login to site with HTTP authentication your requests  
should contain user credentials.  
Debug your seesion to see whats inside “request” object.

… or …

You can avoid apache configuration and you write your own devise  
adapter that will connect to LDAP.  
Devise: [GitHub - heartcombo/devise: Flexible authentication solution for Rails with Warden.](https://github.com/plataformatec/devise)  
Devise HTTP Authentication:  
[Home · heartcombo/devise Wiki · GitHub](https://github.com/plataformatec/devise/wiki/How-To:-Use-HTTP-Authentication)

Hope that this helps you 🙂

- Oto
