Adldap2 / Adldap2-Laravel

LDAP Authentication & Management for Laravel
MIT License
910 stars 184 forks source link

Windows authentication - SSO is querying users table by ID with GUID as parameter #874

Open danhorton7 opened 4 years ago

danhorton7 commented 4 years ago

Description:

I am setting up Windows LDAP authentication. Sync/import etc is working properly and connections are fine. My users DB table is synced and populated from the LDAP server.

When enabling the middleware, any requests now fire up the following error:

SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Error converting data type nvarchar to bigint. (SQL: select top 1 * from [users] where [id] = c6f2afc7-c8cd-4e03-a2de-5ac7e4393ae2)

Which is passing my objectguid as the search parameter.

`[previous exception] [object] (PDOException(code: 42000): SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Error converting data type nvarchar to bigint. at \vendor\laravel\framework\src\Illuminate\Database\Connection.php:336) [stacktrace]

0 \vendor\laravel\framework\src\Illuminate\Database\Connection.php(336): PDOStatement->execute()

1 \vendor\laravel\framework\src\Illuminate\Database\Connection.php(664): Illuminate\Database\Connection->Illuminate\Database\{closure}()

2 \vendor\laravel\framework\src\Illuminate\Database\Connection.php(631): Illuminate\Database\Connection->runQueryCallback()

3 \vendor\laravel\framework\src\Illuminate\Database\Connection.php(339): Illuminate\Database\Connection->run()

4 \vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php(2202): Illuminate\Database\Connection->select()

5 \vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php(2190): Illuminate\Database\Query\Builder->runSelect()

6 \vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php(2685): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()

7 \vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php(2191): Illuminate\Database\Query\Builder->onceWithColumns()

8 \vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php(539): Illuminate\Database\Query\Builder->get()

9 \vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php(523): Illuminate\Database\Eloquent\Builder->getModels()

10 \vendor\laravel\framework\src\Illuminate\Database\Concerns\BuildsQueries.php(143): Illuminate\Database\Eloquent\Builder->get()

11 \vendor\laravel\framework\src\Illuminate\Auth\EloquentUserProvider.php(52): Illuminate\Database\Eloquent\Builder->first()

12 \vendor\laravel\framework\src\Illuminate\Auth\SessionGuard.php(139): Illuminate\Auth\EloquentUserProvider->retrieveById()

13 \vendor\laravel\framework\src\Illuminate\Auth\GuardHelpers.php(60): Illuminate\Auth\SessionGuard->user()

14 \vendor\adldap2\adldap2-laravel\src\Middleware\WindowsAuthenticate.php(50): Illuminate\Auth\SessionGuard->check()

15 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Adldap\Laravel\Middleware\WindowsAuthenticate->handle()`

stevebauman commented 4 years ago

Strange - have you modified the identifiers.database.guid_column value inside your ldap_auth.php file?

danhorton7 commented 4 years ago

Hi Steve, no modifications. ldap_auth.php file below https://pastebin.com/EHRDDeV7

nilloc14 commented 2 years ago

I stumbled upon this issue as well yesterday. I am able to run the sync/import without issues, but SSO does not work unless I set the provider in the ldap_auth.php config to 'Adldap\Laravel\Auth\NoDatabaseUserProvider::class.' I would like to start using the database syncing, but have had to do without for now. I followed the documentation and configured the ldap_auth.php file as suggested, but no luck so far. Per the error in @danhorton7's original post, it is looks like it is trying to put the guid in the 'id' column for some reason. In my ldap_auth.php, I have 'guid_column' set to 'objectguid' and can't figure out why it is doing this. Below is my setup: