Adldap2-Laravel
Adldap2-Laravel copied to clipboard
No LDAP query results / Search: Operations error
"php": "^7.2", "adldap2/adldap2-laravel": "^6.0", "laravel/framework": "^6.0",
Active Directory
Description:
When running an import:
[2019-09-07 16:50:00] local.INFO: LDAP (ldap://172.x.x.x:389) - Connection: default - Operation: Binding - Username:
[2019-09-07 16:50:00] local.INFO: LDAP (ldap://172.x.x.x:389) - Connection: default - Operation: Bound - Username:
[2019-09-07 16:50:00] local.ERROR: ldap_search(): Search: Operations error {"exception":"[object] (ErrorException(code: 0): ldap_search(): Search: Operations error at C:\\xampp\\htdocs\\draw\\vendor\\adldap2\\adldap2\\src\\Connections\\Ldap.php:279)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'ldap_search(): ...', 'C:\\\\xampp\\\\htdocs...', 279, Array)
#1 C:\\xampp\\htdocs\\draw\\vendor\\adldap2\\adldap2\\src\\Connections\\Ldap.php(279): ldap_search(Resource id #524, 'dc=littleriverc...', '(&(objectclass=...', Array, false, 0, 0)
#2 C:\\xampp\\htdocs\\draw\\vendor\\adldap2\\adldap2\\src\\Query\\Builder.php(474): Adldap\\Connections\\Ldap->search('dc=littleriverc...', '(&(objectclass=...', Array, false, 0)
#3 C:\\xampp\\htdocs\\draw\\vendor\\adldap2\\adldap2\\src\\Query\\Builder.php(497): Adldap\\Query\\Builder->run('(&(objectclass=...')
#4 C:\\xampp\\htdocs\\draw\\vendor\\adldap2\\adldap2\\src\\Query\\Builder.php(425): Adldap\\Query\\Builder->runPaginate('(&(objectclass=...', 50, true)
#5 C:\\xampp\\htdocs\\draw\\vendor\\adldap2\\adldap2\\src\\Query\\Builder.php(433): Adldap\\Query\\Builder->Adldap\\Query\\{closure}()
#6 C:\\xampp\\htdocs\\draw\\vendor\\adldap2\\adldap2-laravel\\src\\Commands\\Console\\Import.php(219): Adldap\\Query\\Builder->paginate()
#7 C:\\xampp\\htdocs\\draw\\vendor\\adldap2\\adldap2-laravel\\src\\Commands\\Console\\Import.php(58): Adldap\\Laravel\\Commands\\Console\\Import->getUsers()
#8 [internal function]: Adldap\\Laravel\\Commands\\Console\\Import->handle()
#9 C:\\xampp\\htdocs\\draw\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(32): call_user_func_array(Array, Array)
#10 C:\\xampp\\htdocs\\draw\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(90): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#11 C:\\xampp\\htdocs\\draw\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#12 C:\\xampp\\htdocs\\draw\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(591): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#13 C:\\xampp\\htdocs\\draw\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(192): Illuminate\\Container\\Container->call(Array)
#14 C:\\xampp\\htdocs\\draw\\vendor\\symfony\\console\\Command\\Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#15 C:\\xampp\\htdocs\\draw\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(179): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#16 C:\\xampp\\htdocs\\draw\\vendor\\symfony\\console\\Application.php(915): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#17 C:\\xampp\\htdocs\\draw\\vendor\\symfony\\console\\Application.php(272): Symfony\\Component\\Console\\Application->doRunCommand(Object(Adldap\\Laravel\\Commands\\Console\\Import), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#18 C:\\xampp\\htdocs\\draw\\vendor\\symfony\\console\\Application.php(148): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#19 C:\\xampp\\htdocs\\draw\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Application.php(90): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#20 C:\\xampp\\htdocs\\draw\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(131): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#21 C:\\xampp\\htdocs\\draw\\artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 {main}
"}
Or When trying to login with user
[2019-09-07 16:57:10] local.INFO: LDAP (ldap://172.x.x.x:389) - Connection: default - Operation: Binding - Username:
[2019-09-07 16:57:10] local.INFO: LDAP (ldap://172.x.x.x:389) - Connection: default - Operation: Bound - Username:
[2019-09-07 16:57:10] local.INFO: LDAP (ldap://172.x.x.x:389) - Connection: default - Operation: Search - Base DN: dc=company,dc=local - Filter: (&(objectclass=user)(objectcategory=person)(!(objectclass=contact))(samaccountname=REDACTED)) - Selected: (*,objectguid) - Time Elapsed: 1.7
It seems to be getting a connection as I have plenty of logs before that state it wasnt, but are no longer being reported. I have tried every combination of having prefix/suffix. The one thing that doesnt change is the
Binding - Username:
always logs as blank.
Has any solutions?
Hi @michaellrcr,
Can you post your config/ldap.php
with sensitive details omitted? Do you have auto_connect
disabled?
`<?php
return [
'logging' => env('LDAP_LOGGING', true),
'connections' => [
'default' => [
'auto_connect' => env('LDAP_AUTO_CONNECT', true),
'connection' => Adldap\Connections\Ldap::class,
'settings' => [
'schema' => Adldap\Schemas\ActiveDirectory::class,
'account_prefix' => env('LDAP_ACCOUNT_PREFIX', ''),
'account_suffix' => env('LDAP_ACCOUNT_SUFFIX', ''),
'hosts' => explode(' ', env('LDAP_HOSTS', '172.16.0.3')),
'port' => env('LDAP_PORT', 389),
'timeout' => env('LDAP_TIMEOUT', 5),
'base_dn' => env('LDAP_BASE_DN', 'dc=mydomain,dc=end'),
'username' => env('[email protected]'),
'password' => env('******'),
'follow_referrals' => false,
'use_ssl' => env('LDAP_USE_SSL', false),
'use_tls' => env('LDAP_USE_TLS', false),
],
],
],
]; `
I have had experienced the same issue and other issues when LDAP_AUTO_CONNECT was false.
Running:
php artisan adldap:import
returned "There were no users found to import." and spat out the same error above in the logs.
Users changing passwords in LDAP could not use the new password with the application.
After enabling LDAP_AUTO_CONNECT all issues resolved themselves, it would be nice if this was not the case as auto connect slows down the application.
@michaellrcr Somewhere in your application, try retrieving any record to see if your configuration is right and you're able to get results:
use Adldap\Laravel\Facades\Adldap;
// Get all records from the LDAP directory:
$records = Adldap::search()->get();
// Dump the returned results:
dd($records);
@eldiddio
After enabling LDAP_AUTO_CONNECT all issues resolved themselves, it would be nice if this was not the case as auto connect slows down the application.
This is only the case wherever you use Adldap2 in your application. Requests to your application that do not use Adldap2 will not instantiate a connection due to the singleton registration:
https://github.com/Adldap2/Adldap2-Laravel/blob/9d2e2c7ff57f6da9a88b7b96b344ac61f42855e6/src/AdldapServiceProvider.php#L57-L70
As described in the documentation, if you'd like to handle connectivity yourself, feel free to do so using Adldap::connect()
.
There's honestly no other way of gracefully allowing developers to use and assume LDAP connectivity in their application. If you know of a way, I'd love to hear it!