DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
483 stars 51 forks source link

[Bug] php artisan ldap:test never connects but ldap_connect() from php Can connect #601

Closed eliellima00 closed 8 months ago

eliellima00 commented 8 months ago

Environment:

Describe the bug: I'm following the docs and trying to connect to ldap. I try to use .ENV and published configs, but when I test using the command from documentation, the result is every the same as bellow.

conection -> default successfull -> no username -> ldap@grupoatto message -> ldap_connect(): Could not create session handle: Bad parameter to an ldap routine. Error Code: [2]

I try to connect with vannilla PHP to test, and it can connect.

`<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class TestLdapConnection extends Command { protected $signature = 'ldap:test-command'; protected $description = 'Test LDAP connection';

public function __construct()
{
    parent::__construct();
}

public function handle()
{
    $ldapserver ='host';
    $ldapuser = 'user';
    $ldappass = 'password';

    $ldapconn = ldap_connect($ldapserver);

    if (!$ldapconn) {
        $this->error("Can't connect.");
        return;
    }

    ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);

    if (ldap_bind($ldapconn, $ldapuser, $ldappass)) {
        $this->info("Connection Successfull");
    } else {
        $this->error("Wrong LDAP connection: " . ldap_error($ldapconn));
    }

    ldap_unbind($ldapconn);
}

}`

I don't know if I'm wrong, or where I did go wrong, I just followed the documentations