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

[BUG] connection with environment configuration doesn't work, with custom Provider instance it does #607

@renepardon

Description

@renepardon
  • Laravel Version: 5.7.*
  • Adldap2-Laravel Version: ^4.0
  • PHP Version: 7.2
  • LDAP Type: OpenLDAP

Description:

When creating a custom instance of \Adldap\Connections\Provider I'm able to connect to the OpenLDAP server. Using the environment variables with the same configuration doesn't work and I receive Invalid DN syntax for all attempts. openldap within the controllers is a docker container with the same hostname which can be accessed from my laravel docker container.

Not working example

.env

ADLDAP_ACCOUNT_PREFIX="" ADLDAP_ACCOUNT_SUFFIX="" ADLDAP_CONTROLLERS="openldap" ADLDAP_PORT=389 ADLDAP_TIMEOUT=5 ADLDAP_BASEDN="dc=company,dc=com" ADLDAP_ADMIN_ACCOUNT_PREFIX="" ADLDAP_ADMIN_ACCOUNT_SUFFIX="" ADLDAP_ADMIN_USERNAME="cn=admin,dc=company,dc=com" ADLDAP_ADMIN_PASSWORD="secret" ADLDAP_USE_SSL=false ADLDAP_USE_TLS=false ADLDAP_FOLLOW_REFERRALS=false ADLDAP_ELOQUENT_USERNAME=username ADLDAP_PASSWORD_SYNC=true ADLDAP_LOGIN_FALLBACK=true

AuthController.php

public function login(Request $request, AdldapInterface $ldap) { // does not work - "Invalid DN syntax" error appears dd($ldap->search()->all()); }

Creating a custom instance of the Provider - working example

AuthController.php

public function login(Request $request) { $config = [ // Mandatory Configuration Options 'domain_controllers' => ['openldap'], 'base_dn' => 'dc=company,dc=com', 'admin_username' => 'cn=admin,dc=company,dc=com', 'admin_password' => 'secret', // Optional Configuration Options 'account_prefix' => '', 'account_suffix' => '', 'admin_account_suffix' => '', 'port' => 389, 'follow_referrals' => false, 'use_ssl' => false, 'use_tls' => false, ]; $schema = new OpenLDAP(); // this works $provider = new \Adldap\Connections\Provider($config, null, $schema); // this also works $provider->auth()->attempt('cn=mySecondUserIveCreated,dc=company,dc=com', 'secret'); // and yes, this also works dd($provider->search()->all()); }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions