Catalyst::Plugin::Authentication::LDAP - LDAP Authentication for Catalyst *DEPRECATED, use Store::LDAP instead*


WARNING: This module has been superseded by Catalyst::Plugin::Authentication::Store::LDAP, and is therefore no longer maintained.


    use Catalyst 'Authentication::LDAP';
    __PACKAGE__->config->{authentication} = (
        ldap_server            => 'ldap://',
        default_naming_context => 'dc=mycompany,dc=com',
        user_context           => 'cn=users',
        user_append            => '',
        user_filter            => '(&(objectclass=user)(objectcategory=user)(samaccountname=__USER__*))',
        group_attribute        => 'memberOf',
    $c->login( $user, $password );
    $c->session_login( $user, $password );
    $c->roles(qw/customer admin/);


This plugin allows you to authenticate your web users using an LDAP server. See the Configuration section for more details on how to set it up. This module was designed with Active Directory in mind and has not yet been tested using other LDAP servers. Patches are welcome that enable support for other servers.

Note that this plugin requires a session plugin like Catalyst::Plugin::Session::FastMmap.


This plugin is configured by passing an "authentication" hash reference to your application's config method. The following keys are supported:


Required. Specify the full URI to your LDAP server. Some examples are: ldap://, ldap://pdc:1234, ldaps://

    default_naming_context => 'dc=mycompany,dc=com'

Required. This is the base context for your server. In most cases, this is a string of two or more "dc" values separated by commas.

    user_context => 'cn=users',

Optional. The context to be used when querying a user's details. This value is prefixed to the default_naming_context. The default value should be suitable for Active Directory servers. If you do not intend to use role-based authentication, you can ignore this option.

    user_append = ''

Optional. This string will be appended to a user's login name when authenticating to the server. Active Directory servers require the user to be specified as "".

    user_filter => '(&(objectclass=user)(objectcategory=user)(samaccountname=__USER__*))'

Optional. This filter is used to retrieve the user's account details, specifically the list of groups the user is a member of. For Active Directory servers, the default value should be suitable. The string __USER__ is replaced by the current username. If you do not intend to use role-based authentication, you can ignore this option.

    group_attribute => 'memberOf'

Optional. Specify which attribute contains the list of groups/roles the user is a member of.



Attempt to authenticate a user. Takes username/password as arguments,

    $c->login( $user, $password );

User remains authenticated until end of request.


Log out the user. will not clear the session, so user will still remain logged in at next request unless session_logout is called.


check for permissions. used by the 'roles' function.


Check permissions for roles and return true or false.

    $c->roles(qw/foo bar/);

Returns an arrayref containing the verified roles.

    my @roles = @{ $c->roles };

Persistently login the user. The user will remain logged in until he clears the session himself, or session_logout is called.

    $c->session_login( $user, $password );

Session logout. will delete the user object from the session.



sets $c->request->{user} from session.


sets up $c->config->{authentication}.



Takes an arrayref of roles and checks if user has the supplied roles. Returns 1/0.


Because many LDAP servers require a password to query information, the user's group/role data must be queried and stored at the time they login. This means that group/role data updated on the LDAP server after a user logs in will not be reflected in their session until they logout and log back in.


Catalyst, Catalyst::Plugin::Authentication::CDBI.


Andy Grundman,

Based on Catalyst::Plugin::Authentication::CDBI by: Sebastian Riedel, Marcus Ramberg,


This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.