duanri1985 2019-04-23 01:04
浏览 143
已采纳

adldap2 laravel它只返回'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

  • 写回答

1条回答

  • doupao3662 2019-04-23 09:54
    关注

    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()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集