【问题标题】:adldap2 laravel it is only returning 'false'adldap2 laravel 它只返回“假”
【发布时间】:2019-04-23 01:04:53
【问题描述】:

我正在尝试使用adldap2 访问adldap server

服务器一切正常,我已经使用 Apache Directory Studio 对其进行了测试。

I have followed all these instructions 但没有成功。我所有的请求都返回“假”或空集合。

我做错了什么?

这是我的文件:

# \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),

            ],

        ],

    ],

];

直接使用web.php测试我:

<?php

use Adldap\Laravel\Facades\Adldap;

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

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

这是我的回复错误

false response result

【问题讨论】:

    标签: php laravel ldap openldap adldap


    【解决方案1】:

    如果您的查询或 LDAP 设置中有错误,通常会返回“false”。您可以尝试使用 ldap_error 函数获取错误。

    在 adldab2 中,您的连接中应该有一个来自您的 Provider 的方法

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多