-
Notifications
You must be signed in to change notification settings - Fork 184
Model binding is always null #692
Comments
Thanks @benjivm! I'm able to reproduce this in v6.0. Patch is coming shortly. |
Dang you're fast, thanks @stevebauman |
Thanks @benjivm! I try, as I use Adldap2-Laravel in over 10 production applications internally. Release is being created now, thanks again for bringing this up! My current tests didn't cover the |
Hmm, I am still having issues with this. The property works as expected on the I am also no longer seeing the correct error messages for failed logins, what used to be the "password is required" message, for example, is now just showing |
Hi @benjivm,
The property is only set on the currently authenticated users model. Calling a If you'd like to query for users in your directory, call the root use Adldap\Laravel\Facades\Adldap;
$users = Adldap::search()->users()->get(); For further example: // This works:
var_dump(Auth::user()->ldap); // Returns instance of Adldap\Models\User
// This will not:
$user = User::where('username', '=', 'jdoe')->first();
var_dump($user->ldap); // Returns NULL For your second issue:
This doesn't seem to be related to the above issue, it seems you may have modified your validation rules for your login request? Let me know if you would like further explanation or if you still need any help, thanks! |
Ahh, thanks for clearing up the The validation messages were busted because I accidentally deleted the |
No problem @benjivm! 😄 |
Laravel Version: 5.8.16 Hi, model binding it's not working in my project, am I doing something wrong? Model User.php use Adldap\Laravel\Traits\HasLdapUser;
class User extends Authenticatable
{
use HasLdapUser, [...]; Controller use Illuminate\Support\Facades\Auth;
class ProfileController extends Controller
{
public function index()
{
$profile = Auth::user();
// dd($profile); WORK return only DB data
dd($profile->ldap); // DON'T WORK - return null
} |
Hi @viniciusraupp, Are you logging in with the EDIT: Also:
|
Hi, thank you for your attention. Config: auth.php 'providers' => [
'users' => [
'driver' => 'ldap',
'model' => App\User::class,
], Migration file: 2014_10_12_000000_create_users_table.php public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('objectguid')->nullable();
$table->string('name');
$table->string('samaccountname');
$table->string('username')->unique();
$table->string('userprincipalname');
$table->string('email');
[...] config('ldap') [
"logging" => false,
"connections" => [
"default" => [
"auto_connect" => true,
"connection" => "Adldap\Connections\Ldap",
"settings" => [
"schema" => "App\Ldap\Schemas\LdapSchema",
"account_prefix" => "",
"account_suffix" => "",
"hosts" => [
"IP",
],
"port" => "636",
"timeout" => 5,
"base_dn" => "dc=domain,dc=com",
"username" => "DOMAIN\admin",
"password" => "pwd",
"follow_referrals" => false,
"use_ssl" => true,
"use_tls" => false,
"custom_options" => [
24582 => 0,
],
],
],
],
] config('ldap_auth') [
"connection" => "default",
"provider" => "Adldap\Laravel\Auth\DatabaseUserProvider",
"model" => "App\User",
"rules" => [
"Adldap\Laravel\Validation\Rules\DenyTrashed",
],
"scopes" => [],
"identifiers" => [
"ldap" => [
"locate_users_by" => "samaccountname",
"bind_users_by" => "distinguishedname",
],
"database" => [
"guid_column" => "objectguid",
"username_column" => "username",
],
"windows" => [
"locate_users_by" => "samaccountname",
"server_key" => "AUTH_USER",
],
],
"passwords" => [
"sync" => true,
"column" => "password",
],
"login_fallback" => false,
"sync_attributes" => [
"App\Handlers\LdapAttributeHandler",
],
"logging" => [
"enabled" => true,
"events" => [
...
],
],
] Own LDAP User model: namespace App\Ldap\Models;
use Adldap\Models\User as Model;
use Illuminate\Foundation\Auth\Access\Authorizable;
class User extends Model
{
} Own LDAP Schema: namespace App\Ldap\Schemas;
use Adldap\Schemas\ActiveDirectory;
use App\Ldap\Models\User;
class LdapSchema extends ActiveDirectory
{
public function userModel()
{
return User::class;
}
} |
Hello, had anyone solved this issue? @stevebauman this issue is closed with some solution? |
Description:
Model Binding always returns null. All other functionality works as expected: logging in, data synchronization, etc. Here is my
User.php
:From reading the documentation I should now be able to access the LdapUser model via
$user->ldap
, however this always returns null.The text was updated successfully, but these errors were encountered: