DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
501 stars 53 forks source link

[Bug] Call to undefined method LdapRecord\Query\Model\ActiveDirectoryBuilder::getKeyType() #422

Closed juhotaipale closed 2 years ago

juhotaipale commented 2 years ago

Environment:

Describe the bug:

Application is throwing following exception when running fresh migration with Laravel Nova (v4) installed.

PS C:\code\demo> php artisan migrate                                                                   
Migrating: 2018_01_01_000000_create_action_events_table

   BadMethodCallException 

  Call to undefined method LdapRecord\Query\Model\ActiveDirectoryBuilder::getKeyType()

  at C:\code\demo\vendor\directorytree\ldaprecord\src\Query\Builder.php:1967
    1964▕             return $this->dynamicWhere($method, $parameters);
    1965▕         }
    1966▕
    1968▕             'Call to undefined method %s::%s()',
    1969▕             static::class,
    1970▕             $method
    1971▕         ));

  1   C:\code\demo\vendor\directorytree\ldaprecord\src\Query\Model\Builder.php:58
      LdapRecord\Query\Builder::__call("getKeyType", [])

  2   C:\code\demo\vendor\directorytree\ldaprecord\src\Models\Model.php:178
      LdapRecord\Query\Model\Builder::__call("getKeyType", [])

My providers in auth.php

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

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

Migration is running correctly if I temporarily uncomment the default auth provider and comment out the one using ldap driver.

stevebauman commented 2 years ago

Hi @juhotaipale,

This has been reported here as well: https://github.com/DirectoryTree/LdapRecord-Laravel/issues/423

This is not an issue with LdapRecord-Laravel. Laravel Nova must provide a way of overriding the Nova::userModel() so that they may change the configuration path to your user model.

stevebauman commented 2 years ago

I've made a tweet to one of the creators of Laravel Nova, hopefully we can get something merged to resolve this:

https://twitter.com/SteveTheBauman/status/1517492302935216129

crynobone commented 2 years ago
  1. Run php artisan vendor:publish --tag=nova-migrations
  2. Add Laravel\Nova\Nova::ignoreMigrations() to App\Providers\NovaServiceProvider
  3. Edit generated CreateActionEventsTable migration.
  4. Run php artisan migrate
stevebauman commented 2 years ago

Closing as this is a duplicate of https://github.com/DirectoryTree/LdapRecord-Laravel/issues/423 and has been reported as an issue to Nova.

pniaps commented 1 year ago

Thanks @crynobone , works like a charm.