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

Can't contact LDAP server - Error in the pull function #808

Open
noBloodOnTheLeaves opened this issue Jun 7, 2022 · 0 comments
Open

Can't contact LDAP server - Error in the pull function #808

noBloodOnTheLeaves opened this issue Jun 7, 2022 · 0 comments

Comments

@noBloodOnTheLeaves
Copy link

noBloodOnTheLeaves commented Jun 7, 2022

  • Adldap2 Version: 10.4
  • LDAP Type:
  • PHP Version: 7.4

Hey! We used Adldap\Adldap in our project, but it's too old library and i want use Adldap2/Adldap2

This code was before with Adldap\Adldap:
`
$ldapOptions = [
'user_suffix' => $suffix . '\',
'account_suffix' => '',
'base_dn' => "DC={$suffix},DC=local",
'domain_controllers' => ["dc{$suffix}dc.{$suffix}.local"],
'admin_username' => "some_name",
'admin_password' => "some_password",
'real_primarygroup' => '',
'use_ssl' => true,
'use_tls' => false,
'recursive_groups' => true,
'ad_port' => "some_port",
'sso' => '',
];

    try {
        $adldap = new Adldap($ldapOptions);
        $options['base_dn'] = $adldap->getBaseDn();
        $options['ad_port'] = $adldap->getPort();
        $is_auth = $adldap->authenticate($suffix . "\\" . $login, $request->password);
    } catch (AdldapException $e) {
        throw new AppException('Can't connect to LDAP server');
    }

I try to overwrite this with Adldap2/Adldap2:
$config = [
// Mandatory Configuration Options
'hosts' => ['dc.some.dn'],
'base_dn' => 'dc=some,dc=dn',
'username' => 'some_name',
'password' => 'some_password',

        // Optional Configuration Options
        'schema'           => ActiveDirectory::class,
        'account_prefix'   => '',
        'account_suffix'   => '',
        'port'             => some_port,
        'follow_referrals' => false,
        'use_ssl'          => true,
        'use_tls'          => false,
        'version'          => 3,
        'timeout'          => 5,

        // Custom LDAP Options
        'custom_options'   => [
            LDAP_OPT_X_TLS_REQUIRE_CERT => LDAP_OPT_X_TLS_NEVER
        ]
    ];

    $connectionName = 'some';

    $ad = new Adldap();
    $ad->addProvider($config, $connectionName);

    try {
        $provider = $ad->connect($connectionName);
        $rawConnection = $provider->getConnection();
        $result = $rawConnection->search('dc=some,dc=dn',"cn=some_user", ['cn', 'memberof']);
        return response()->json([
            'status' => 'success',
            'data' => $result,
        ]);
    } catch (BindException $e) {
        $detailError = $e->getDetailedError();
        return response()->json([
            'status' => 'error',
            'message' => $e->getMessage(),
            'diag' => $detailError->getDiagnosticMessage(),
            'message' => $detailError->getErrorMessage(),
            'code' => $detailError->getErrorCode(),
        ]);
    }

`
I just copy paste config with changes array keys like in Documentation. Port, username, password and etc are right, because i just copy from Controller with Adldap/Adldap that works fine. (Port is integer :) , i read all issue with this error like that)

My ldap config:
TLS_CACERT /etc/ssl/certs/ca-certificates.crt
TLS_REQCERT neverroot@mc-apache:/var/www/html#
SASL_NOCANON on

BUT i got error:
diag: "Error in the pull function." message: "Can't contact LDAP server" status: "error"
I try play with config values, but i failed)
What else can i try? =)

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

1 participant