phplaravelldapopenldapadldap

adldap2 laravel it is only returning 'false'


I'm trying to use the adldap2 to access an adldap server.

it's everything ok with the server, i have used the Apache Directory Studio to test it.

I have followed all these instructions but withou success. All of my requests are returning 'false' or a empty collection.

what am i doing wrong?

Here are my files:

# \config\ldap.php 
return [

    'logging' => env('LDAP_LOGGING', false),

    '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', 'ldap.forumsys.com')),

                'port' => env('LDAP_PORT', 389),

                'timeout' => env('LDAP_TIMEOUT', 5),

                'base_dn' => env('LDAP_BASE_DN', 'dc=example,dc=com'),

                'username' => env(' cn=read-only-admin,dc=example,dc=com'),
                'password' => env('password'),

                'follow_referrals' => false,

                'use_ssl' => env('LDAP_USE_SSL', false),
                'use_tls' => env('LDAP_USE_TLS', false),

            ],

        ],

    ],

];

To test I using the web.php directly:

<?php

use Adldap\Laravel\Facades\Adldap;

Route::get('/api', function(){

    $user = Adldap::search()->users()->find('newton');
    dd($user);
    return 'test page';
});

Here is my response error

false response result


Solution

  • Normaly a "false" is returned if there is an error in your Query or LDAP Settings. You could try to get the error with the ldap_error function.

    In adldab2 there should be an method in your Connection from your Provider

    $ad = new \Adldap\Adldap();
    $config = [...]; // your config
    $ad->addProvider($config);
    $provider = $ad->connect();
    // do your query stuff
    $provider->getConnection()->getLastError()