Skip to content

Instantly share code, notes, and snippets.

@miquelangeld
Created October 24, 2022 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miquelangeld/2df7646c47484e937b95e50b5a6931c8 to your computer and use it in GitHub Desktop.
Save miquelangeld/2df7646c47484e937b95e50b5a6931c8 to your computer and use it in GitHub Desktop.
Backpack with LdapRecord
//comment the current 'users' node and add this:
'users' => [
'driver' => 'ldap',
'model' => LdapRecord\Models\ActiveDirectory\User::class,
'rules' => [],
'database' => [
'model' => App\Models\User::class,
'sync_passwords' => false,
'sync_attributes' => [
'name' => 'cn',
'email' => 'mail',
'username' =>'samaccountname'
],
'sync_existing' => [
'email' => 'mail',
],
],
//modify this lines
'authentication_column' => 'samaccountname',
'authentication_column_name' => 'username',
'guard' => null,
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use LdapRecord\Laravel\Auth\LdapAuthenticatable;
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
class User extends Authenticatable implements LdapAuthenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use AuthenticatesWithLdap;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment