lexcilius's avatar

LDAP Authentication

@JeffreyWay I am working on an application that would ideally need LDAP authentication. I am curious if you could do a video showing how you would implement this since LDAP is not a built in authentication method for Laravel. I would greatly appreciate it, and I'm sure there are others out there who could also make use of this.

Thanks,

Mike

0 likes
14 replies
nesl247's avatar

Here is an existing package for LDAP authentication: https://github.com/ccovey/ldap-auth

You will have to use the custom branch from https://github.com/ccovey/ldap-auth/pull/42 though, or fork it and change composer yourself. It's currently hard requiring Laravel 4.1.*.

The thing that is lacking with both this LDAP authentication provider and another one that exists, is that they are both only authentication providers. Meaning the only instance of your User model that will ever have any LDAP attributes is the one provided by Auth::user().

lexcilius's avatar

@nesl247 I am not quite sure what you mean by only authentication providers. I had only planned on authenticating users with LDAP, and then after they had been authenticated, give them permissions manually as necessary by modifying the account that would be created after they have logged in for the first time. Is this still feasible?

nesl247's avatar

It sounds like you just want LDAP authentication, which is all those libraries do at the moment.

I personally don't like having to duplicate data, so if the data exists in LDAP, I don't want the data in an SQL database. This is what I was saying isn't currently possible in those libraries.

lexcilius's avatar

@nesl247 Correct, I am just looking to do authentication only with LDAP. I can agree with the point of not wanting to duplicate data, however this is an internal company website, and they want to use single sign on, but at the same time, they prefer to keep responsibilities in each application separate from the LDAP server. Basically they don't want to add a bunch of extra responsibilities to the LDAP server outside of authentication itself. Which I suppose makes sense, it just means a little extra work on the developer's part. Thanks again for the information, I'll check it out.

lexcilius's avatar

@JeffreyWay The helpful community has helped answer my questions regarding LDAP, which is much appreciated. I was still curious though, if you had any plans for doing any videos on LDAP authentication in the future, or is it not as in demand as I would think? Thanks again for all the help!

1 like
lexcilius's avatar

@rezen You provided the link to your code, however, I am still relatively new to Laravel, and I was wondering if you could provide me with a little better detail on how I would get that working. Additionally, does this create a local user in the database, one that could be used with pivot tables for permissions and roles? Thanks.

rezen's avatar

Each of the gists correspond to a filename - if you search in your Laravel app directory you can find them :) All you need to do is add the code provided to the existing files. The first file you will have to create and add.

The example only authenticates, any additional functionality around the user would have to implemented.

lexcilius's avatar

@rezen Thanks for the tips. Although I do have another question, does this add the user to the users table so that I can access it to add extra roles?

shikharoy's avatar

A newbie question - I am trying to create an LDAP authentication working of of PHP 5.4 with laravel 4.2. I don't think I have php5-ldap installed. I don't want to do it if I don't need to do it. I don't have root permission and am creating a prototype.

I see a lot of laravel drivers like http://packalyst.com/packages/package/wells/l4-ldap-ntlm and https://github.com/ccovey/ldap-auth.

Would they do it without php5-ldap.

Any help appreciated.

Thanks.

lexcilius's avatar

Poxin,

That is ultimately the package I used, and it does an excellent job of making the LDAP auth process a cinch in Laravel 5.2!

1 like

Please or to participate in this conversation.