LdapRecord-Laravel: LdapRecord\Query\Model\Builder::find(): Argument #1 ($dn) must be of type array|string, null given
Environment:
- LDAP Server Type: ActiveDirectory
- LdapRecord-Laravel Major Version: V3
- PHP Version: 8.1.2
- Laravel
composer.json
"require": {
"php": "^8.1",
"appstract/laravel-opcache": "^4.0",
"directorytree/ldaprecord-laravel": "^3.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"motomedialab/laravel-vite-helper": "^1.4",
"spatie/laravel-permission": "^5.10"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.8",
"barryvdh/laravel-ide-helper": "^2.13",
"fakerphp/faker": "^1.9.1",
"laravel/breeze": "^1.21",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.1",
"spatie/laravel-ignition": "^2.0"
},
I get the error above when I try php artisan ldap:browse and then choose inspect. The php artisan ldap:test command returns OK results.
This works:
use LdapRecord\Container;
$connection = Container::getConnection('default');
$connection->auth()->attempt('username@company.com', 'password');
but this doesn’t:
use Illuminate\Support\Facades\Auth;
$credentials = [
'userprincipalname' => 'username@company.com',
'password' => 'password',
];
Auth::attempt($credentials)
I have a feeling that I might not have the package installed properly but not sure how to test it. I tried it on a fresh Laravel installation but still the same. I am going to try it on a different laptop next, maybe on a Linux machine.
Do you have any suggestion on what I can try?
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 25 (11 by maintainers)
Commits related to this issue
- Properly retrieve base DN from query #578 — committed to DirectoryTree/LdapRecord-Laravel by stevebauman 9 months ago
Ahh okay, no worries @anchan42! I’m really glad you were able to get to the bottom of it.
Thanks for hanging in there with me while we debugged this 🙏
@anchan42 Apologies for the delayed reply!
This is suspiciously sounding like there may be a permission issue reading some attributes (specifically
objectclass
) on your ActiveDirectory server when you’re bound to the server with an anonymous bind (null username and password)…The
objectclass
attribute is explicitly requested on all LdapRecord searches performed on models, as it is necessary to determine what the object type is.Can you try with your raw LDAP snippet you’ve posted above and include the
objectclass
attribute with your selected attributes? I.e.:Typically with LDAP integrations, administrators create specific service accounts with explicit permissions for binding to the LDAP server, though I totally understand not all environments are the same and administrators like to do things in alternate ways sometimes (whatever the case may be).
EDIT: Also, can you try performing a raw query on the LdapRecord connection with an anonymous bind? Ex: