Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Can not to retrieve the user information after connecting to LDAP server #788

Open
mbsaberi opened this issue Jul 25, 2021 · 1 comment
Open

Comments

@mbsaberi
Copy link

  • Adldap2 Version: 10.3
  • LDAP Type: Active Directory
  • PHP Version: 7.2

Description:

Previously, I was using the adLDAP to connect to Active Directory server via PHP. In this project, I was able to retrieve the related information of user using the project methods completely. After some researches, and because I found out that the adLDAP does not have a live update anymore, I decided to use Adldap2 instead.
I wrote the codes and everything is OK up to retrieve the user information. But here, I am unable to fetch the information by using any of the methods which are mentioned at searching section of documents. I don't know what is the reason and what should I do to fetch such data from the users of AD.

Steps To Reproduce:

This is what I have in the project:

require './vendor/autoload.php';
$ad = new Adldap\Adldap();
$con = 'con1';

$configuration = array(
        'hosts' => [$ldap_server],
        'port' => $ldap_port,
        'username' => null,
        'password' => null,
        'timeout' => 5,
        'account_prefix' => '',
        'account_suffix' => ''
);

$ad->addProvider($configuration,$con);
$ad->setDefaultProvider($con);

try {
        $provider = $ad->connect($con, $ldap_test_username, $ldap_test_password);
        if ($provider->auth()->attempt($ldap_test_username, $ldap_test_password, $bindAsUser = true)) {
                 $search = $provider->search();
                 $search->select('cn', 'givenname', 'sn', 'description', 'mail', 'mobile');
                 $results = $search->where('cn', '=', $ldap_test_username)->get();
                 print_r($result);
        }
} catch(Adldap\Auth\BindException $e) {
        echo $e->getMessage();
}

And this is the only result:
Adldap\Query\Collection Object ( [items:protected] => Array ( ) )

@kabeza
Copy link

kabeza commented Apr 11, 2022

Hi @mbsaberi
I'm having the same problem. Could you solve it in some way?
Is it the configuration's base_dn ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants