Back

BindException in Guard.php line 80: Can't contact LDAP server


Hi, i just learned to use laravel and ldap. Currently, I'm creating a web system for employees. I have created a user database before. Then, I want when the user login, the user database first whether the account is registered or not in the user database. If the account is registered, ldap server will check whether the account is also registered on ldap server or not. If the account is registered, then the user can login to the web system. If the account is not listed in one of them (either in the user database or ldap server) then the user can not enter the web system. It's just that i found error when making it, is there anybody can help me? I hope my question can be understood by those who read it.

BindException in Guard.php line 80: Can't contact LDAP server

this is my code :

adldap.php

<?php return [ 'connections' => [ 'default' => [ 'auto_connect' => true, 'connection' => Adldap\Connections\Ldap::class, 'schema' => Adldap\Schemas\ActiveDirectory::class, 'connection_settings' => [ 'account_prefix' => env('ADLDAP_ACCOUNT_PREFIX', ''), 'account_suffix' => env('ADLDAP_ACCOUNT_SUFFIX', ''), //'domain_controllers' => explode(' ', env('ADLDAP_CONTROLLERS', 'corp-dc1.corp.acme.org corp-dc2.corp.acme.org')), 'domain_controllers' => explode(' ', env('ADLDAP_CONTROLLERS', '12.7.2.19')), 'port' => env('ADLDAP_PORT', 389), 'timeout' => env('ADLDAP_TIMEOUT', 5), //'base_dn' => env('ADLDAP_BASEDN', 'dc=corp,dc=acme,dc=org'), 'base_dn' => env('ADLDAP_BASEDN', 'o=PKT'), 'admin_account_suffix' => env('ADLDAP_ADMIN_ACCOUNT_SUFFIX', ''), 'admin_username' => env('ADLDAP_ADMIN_USERNAME', '0000001'), 'admin_password' => env('ADLDAP_ADMIN_PASSWORD', '123456'), 'follow_referrals' => false, 'use_ssl' => false, 'use_tls' => false, ], ], ], ]; // Create a new Adldap Provider instance. $provider = new \Adldap\Connections\Provider(connections); $ad = new \Adldap\Adldap(connections); try { // Connect to the provider you specified in your configuration. $provider = $ad->connect('default'); // Connection was successful. // We can now perform operations on the connection. $user = $provider->search()->users()->find('0000001'); } catch (\Adldap\Auth\BindException $e) { die("Can't connect / bind to the LDAP server! Error: $e"); }

Sign in to participate in this thread!


We'd like to thank these amazing companies for supporting us