PHPackages                             fschwaiger/laravel-ldap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. fschwaiger/laravel-ldap

AbandonedArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

fschwaiger/laravel-ldap
=======================

Simple LDAP integration for Laravel 5. Comes with file based ACL.

v1.0.3(9y ago)161MITPHP

Since Dec 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/fschwaiger/laravel-ldap)[ Packagist](https://packagist.org/packages/fschwaiger/laravel-ldap)[ RSS](/packages/fschwaiger-laravel-ldap/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (2)Versions (5)Used By (0)

Simple LDAP Integration for Laravel 5
=====================================

[](#simple-ldap-integration-for-laravel-5)

This module provides a simple user provider for Laravel's auth system that connects to an LDAP server, imports users and groups and then maps the group identifiers to privilege roles in a config file.

This extension is originally written for use in a couple of webservices for Fachschaft Maschinenbau e.V., but is generic enough to be used in a variety of other projects as well. My focus here is to really keep the logic as simple as possible, this is why I stripped all unnecessary properties and methods.

Installation
------------

[](#installation)

First, import the package into your laravel project via composer:

```
composer require fschwaiger/laravel-ldap
```

Second, copy and paste this line to add its service provider to `config/app.php`:

```
Fschwaiger\Ldap\LdapServiceProvider::class,
```

Last, publish the config files and migrations to your project with `php artisan vendor:publish`. This will create the following files:

```
config/ldap.php
config/privileges.php
database/migrations/2016_12_17_000000_extend_users_table.php
database/migrations/2016_12_17_100000_create_groups_table.php
database/migrations/2016_12_17_200000_create_group_user_table.php
```

Integration
-----------

[](#integration)

To tell Laravel to use this module for providing users, go to `config/auth.php`and replace the user provider driver `eloquent` for `ldap`:

```
'providers' => [
    'users' => [
        'driver' => 'ldap',
        'model' => App\User::class,
    ],
],
```

Your `App\User` class should then inherit from `Fschwaiger\Ldap\User`. The same goes for your group model, should you choose to extend it. It is up to you to add the `Notifiable` trait.

```
namespace App;

use Fschwaiger\Ldap\User as LdapUser;

class User extends LdapUser;
{
    ...
}
```

To connect to your directory server, edit the file `config/ldap.php` to match your setup. Simply follow the instructions present in the config file.

Finally, edit your `.env` file to include:

```
LDAP_USERNAME=binduser
LDAP_PASSWORD=bindpass
```

If you did not modify the default migration for the `users` table, migration should work out of the box. Else make sure you review the migration changes first.

```
php artisan migrate
```

Once the setup is complete, the following command should import all your user groups.

```
php artisan ldap:import-groups
```

Importing Users and Groups
--------------------------

[](#importing-users-and-groups)

With above setup, login should now use the LDAP server instead of the local database to authenticate users. This imports unknown users on their first successful login on-the-fly. Note that importing users **does NOT import groups automatically!**This means that you need to run `ldap:import-users` every time your groups change.

**Option A:** Import manually after changes with `php artisan ldap:import-groups`. This is good enough for mostly static directory structures. If your groups change more often, check out Option B.

**Option B:** Schedule the import in `app/Console/Kernel.php`:

```
/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
    $schedule->command('ldap:import-groups')->daily();
}
```

Authorize Actions with Group Privileges
---------------------------------------

[](#authorize-actions-with-group-privileges)

The privileges you define in `config/privileges.php` are automatically mapped to the authorization gate, so that you can check for them in all parts of your application.

In code:

```
Gate::authorize('privilege')
// or
$allowed = $user->can('privilege')
```

Using middleware:

```
$this->middleware('can:privilege')
// or
Route::get('action', ['middleware' => 'can:privilege', 'uses' => 'MyController@action'])
```

In Blade files:

```
@can('privilege')
    ...
@endcan
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~24 days

Total

4

Last Release

3353d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9b491203baa4e5ff5e4ca81e18b0b07276572aa312f64bea74c46b4b40b4179?d=identicon)[fschwaiger](/maintainers/fschwaiger)

---

Top Contributors

[![fschwaiger](https://avatars.githubusercontent.com/u/1839759?v=4)](https://github.com/fschwaiger "fschwaiger (13 commits)")

---

Tags

laravelldap

### Embed Badge

![Health badge](/badges/fschwaiger-laravel-ldap/health.svg)

```
[![Health](https://phpackages.com/badges/fschwaiger-laravel-ldap/health.svg)](https://phpackages.com/packages/fschwaiger-laravel-ldap)
```

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
