# LDAP authentication

**URL:** <https://www.ruby-forum.com/t/ldap-authentication/162237>\
**Category:** Ruby\
**Created:** [March 7, 2009, 9:12am UTC](https://www.ruby-forum.com/t/ldap-authentication/162237 "2009-03-07T09:12:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![palani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@palani](https://www.ruby-forum.com/u/palani)\
**Post date:** [March 7, 2009, 9:12am UTC](https://www.ruby-forum.com/t/ldap-authentication/162237/1 "2009-03-07T09:12:37Z")

</div>

Hi  
Can anyone please help how can i implement the LDAP  
authentication in Ruby on Rails .i am unaware of this .I need to  
implement the login by using LDAP authentication. please anyone tell me  
the complete step by step details how we can implement. what should i  
do. please help me.

---

<div class="post-metadata">

**Author:** ![palani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@palani](https://www.ruby-forum.com/u/palani)\
**Post date:** [March 7, 2009, 2:05pm UTC](https://www.ruby-forum.com/t/ldap-authentication/162237/2 "2009-03-07T14:05:37Z")

</div>

Palani K. wrote:

> ```
> Can anyone please help how can i implement the LDAP
> 
> ```
> 
> authentication in Ruby on Rails .i am unaware of this .I need to  
> implement the login by using LDAP authentication. please anyone tell me  
> the complete step by step details how we can implement. what should i  
> do. please help me.

Suggested approach.

1. Enter “rails LDAP authentication” into Google. Read the results.

2. If that doesn’t help, ask the question on a Rails mailing list.

---

<div class="post-metadata">

**Author:** ![palani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@palani](https://www.ruby-forum.com/u/palani)\
**Post date:** [March 7, 2009, 2:53pm UTC](https://www.ruby-forum.com/t/ldap-authentication/162237/3 "2009-03-07T14:53:59Z")

</div>

Palani K. wrote:

> Hi  
> Can anyone please help how can i implement the LDAP  
> authentication in Ruby on Rails .i am unaware of this .I need to  
> implement the login by using LDAP authentication. please anyone tell me  
> the complete step by step details how we can implement. what should i  
> do. please help me.

The same question was questioned by me few months ago on this forums and  
you can search here for more informations.

This is my solution:

gem install ruby-net-ldap

add require ‘net/ldap’ =\> environment.rb

```
  ldap = Net::LDAP.new
  ldap.host = 'mydc.mydomain.com'
  ldap.port = 389
  ldap.auth "#{params[:usr]}@mydomain.com", params[:pass]
  unless ldap.bind
    flash[:error] = "Password or user incorect!"
    return false
  end

```

Works with Windows 2003 DC.

by  
TheR
