Skip to content

a bundle for Symfony2 that provides authentication with directory services via LDAP

License

Notifications You must be signed in to change notification settings

mindcruzer/symfony2-ldap-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Symfony2 LDAP Authentication Provider

NOTE: This is for Symfony >= 2.1.x. There is a 2.0.x branch if you need it.

This bundle contains a custom authentication provider for authenticating users with directory services (ex. Active Directory) via LDAP. It will connect to directory services and attempt a bind operation with the provided username and password. This bundle will not act as an authorization provider or a user provider. It will only provide authentication. The rest is up to you.

Prerequisites

Configuration

Getting this up and running should only steal a minute of your life.

Step #1

Clone and then copy the LDAP directory from this repo to src/.

Step #2

Install the bundle by adding a reference in your app/AppKernel.php file like so:

class AppKernel extends Kernel
{
   public function registerBundles()
   {
        $bundles = array(
            ...
            new LDAP\LDAPAuthBundle\LDAPAuthBundle(),
            ...
        );
    );
    ...
}
Step #3

Set up your security firewall.

For example:

// app/config/security.yml

security:
    firewalls:
        ...
        secured_area:
            ldap_login: 
                login_path: /login
                check_path: /login_check
            pattern: ^/admin
            logout:
                path:   /logout
                target: /login
        ...
Step #4

You'll need to go to src/LDAP/LDAPAuthBundle/Security/Authentication/Provider/LDAPAuthenticationProvider.php and enter your server's domain name in this line $ldap_conn = ldap_connect(/*'your.server.here'*/);. This is clearly an undesirable place to do this, but I never got around to moving this setting to security.yml, and I don't use Symfony anymore. However, if you check out the Symfony docs I believe it shows you how.

You're done.

Extending

If you want to do a little more than a bind operation to authenticate the user, you can add some custom code to src/LDAP/LDAPAuthBundle/Security/Authentication/Provider/LDAPAuthenticationProvider.php.

About

a bundle for Symfony2 that provides authentication with directory services via LDAP

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages