2

I am new to ldap and i have been searching for a considerable time and i could not find the steps to proceed. I have stated my requirement

I want to allow user to login using ldap credentials and after successfull login i want to save the user in the user model and redirect to next page and that page will contain items that are specific to user.

If the user is already present in the user model then it should be updated. How can i do this?

Any help is greatly appreciated.

2 Answers 2

2

Devise is a great gem for managing user authentication and there is an LDAP plugin called Devise LDAP Authenticable which might do what you need. Here is a nice screencast that demonstrates how to setup simple user sign in against an LDAP server:

http://corrupt.net/2010/07/05/LDAP-Authentication-With-Devise/

The screencast was posted a few years ago so be sure to read the full documentation for both Devise and the LDAP plugin.

When using Devise, you can control where users get redirected to after sign in by overriding the after_sign_in_path_for in the ApplicationController and having it return the path of the page you want the user to see

def after_sign_in_path_for(resource)
  some_other_path
end
Sign up to request clarification or add additional context in comments.

4 Comments

I want to use ldap without devise.
I'm curious, why don't you want to use Devise? It's well tested, saves you from boilerplate of rolling your own auth, and has some conveniences like the after_sign_in_path_for example. If you're rolling your own auth then you'll probably need to leverage the net-ldap library (github.com/ruby-ldap/ruby-net-ldap) to connect to your back-end LDAP server.
I have tried using devise and in that too i found problems as i have stated in the question stackoverflow.com/questions/16037732/…
Devise requires that a User table exists (you can choose any name you want). Some LDAP apps won't have a User table so Devise isn't suitable.
0

Use devise gem for authentication. It will take care of you requirements. for more reference refer this

https://github.com/plataformatec/devise

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.