0

We have a double problem here

We've developed a percent of our app Customer has changed requirement about login. So we need to authentica via ldap againsta an active directory

We'd like so to use both Backpack For Laravel and LdapRecord For Laravel

Do you know if is it possible at all?

Actually, we 'are using database integration

Our user class it's this

<?php

namespace App\Models;

use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Permission\Traits\HasRoles;
use LdapRecord\Laravel\Auth\LdapAuthenticatable;
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;

class User extends Authenticatable implements LdapAuthenticatable
{
    use HasFactory, Notifiable;
    use HasRoles;
    use CrudTrait;
    use AuthenticatesWithLdap;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

We have set config.backpack.base.user_model_fqn as App\Models\User::class

And config.auth.providers is configure as follow:

    'providers' => [

        // https://ldaprecord.com/docs/laravel/v2/auth/database/configuration#introduction
        'users' => [
            'driver' => 'ldap',
            'model' => LdapRecord\Models\ActiveDirectory\User::class,
            'rules' => [],
            'database' => [
                'model' => App\User::class,
                'sync_passwords' => false,
                'sync_attributes' => [
                    'name' => 'cn',
                    'email' => 'mail',
                ],
                'sync_existing' => [
                    'email' => 'mail',
                ],
            ],
        ],
    ],

I got every time the error: "These credentials do not match our records."

I'm sure of username because I've choosen it in the AD domain controller

enter image description here

realtebo
  • 23,922
  • 37
  • 112
  • 189
  • 1
    Hmm it’s possible that you also need to change the guard in Backpack’s config file - https://github.com/Laravel-Backpack/CRUD/blob/master/src/config/backpack/base.php – tabacitu Mar 03 '21 at 11:49

1 Answers1

1

We succesfully integrated LdapRecord with Backpack.

I can confirm what suggested in the comment by @tabacity: I simply changed the guard in backpack config to 'null' (or to 'web').

realtebo
  • 23,922
  • 37
  • 112
  • 189