Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ale1981's avatar

Laravel Nova with LDAP

Before I go ahead and purchase Nova can anybody confirm that Laravel Nova works with LdapRecord https://github.com/DirectoryTree/LdapRecord-Laravel ?

Thanks

0 likes
5 replies
ale1981's avatar
ale1981
OP
Best Answer
Level 3

Just to confirm, it does work with a few slight modifications.

1 like
richardd's avatar

Hey! What were the modifications? I've tried a few different guard configs, no luck. LDAP auth is smooth outside of Nova.

ale1981's avatar

Hi Richard

Here is sections of my auth.php

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'ldap',
    ],

    'api' => [
        'driver' => 'token',
        'provider' => 'users',
        'hash' => false,
    ],
],


'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],

    'ldap' => [
        'driver' => 'ldap',
        'model' => LdapRecord\Models\ActiveDirectory\User::class,
        'rules' => [],
        'database' => [
            'model' => App\Models\User::class,
            'sync_passwords' => true,
            'sync_attributes' => [
                'name' => 'cn',
                'email' => 'mail',
            ],
            'sync_existing' => [
                'email' => 'mail',
            ],                
        ],
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

I also had to override the credentials method in the LoginController class as I wanted to use email rather than username;

protected function credentials (Request $request)
{
    return [
        'mail' => $request->get('email'),
        'password' => $request->get('password'),
    ];        
}

If you decide to use email make sure you also override login.blade.php and amend to pass email instead of username.

2 likes
richardd's avatar

Awesome, thank you! Ended up creating a nova_users guard after seeing your example.

Thanks again!

Please or to participate in this conversation.