Remove hardcoded use of default LDAP server, added example for opendj

This commit is contained in:
Deon George 2025-01-22 15:27:52 +11:00
parent 16452ebfa9
commit 3a4b0bfe05
3 changed files with 22 additions and 5 deletions

View File

@ -52,6 +52,7 @@ The update to v2 is progressing well - here is a list of work to do and done:
Support is known for these LDAP servers:
- [X] OpenLDAP
- [X] OpenDJ
- [ ] Microsoft Active Directory
If there is an LDAP server that you have that you would like to have supported, please open an issue to request it.

View File

@ -59,14 +59,14 @@ final class Server
* Gets the root DN of the specified LDAPServer, or throws an exception if it
* can't find it.
*
* @param null $connection Return a collection of baseDNs
* @param string|null $connection Return a collection of baseDNs
* @param bool $objects Return a collection of Entry Models
* @return Collection
* @throws ObjectNotFoundException
* @testedin GetBaseDNTest::testBaseDNExists();
* @todo Need to allow for the scenario if the baseDN is not readable by ACLs
*/
public static function baseDNs(string $connection='default',bool $objects=TRUE): Collection
public static function baseDNs(string $connection=NULL,bool $objects=TRUE): Collection
{
$cachetime = Carbon::now()
->addSeconds(Config::get('ldap.cache.time'));
@ -360,9 +360,13 @@ final class Server
}
// Try to get the schema DN from the specified entry.
$schema_dn = $this->schemaDN('default');
$schema_dn = $this->schemaDN($this->connection);
$schema = $this->fetch($schema_dn);
// If our schema's null, we didnt find it.
if (! $schema)
throw new Exception('Couldnt find schema at:'.$schema_dn);
switch ($item) {
case 'attributetypes':
Log::debug('Attribute Types');

View File

@ -13,7 +13,7 @@ return [
|
*/
'default' => env('LDAP_CONNECTION', 'default'),
'default' => env('LDAP_CONNECTION', 'openldap'),
/*
|--------------------------------------------------------------------------
@ -28,7 +28,7 @@ return [
'connections' => [
'default' => [
'openldap' => [
'hosts' => [env('LDAP_HOST', '127.0.0.1')],
'username' => env('LDAP_USERNAME', 'cn=user,dc=local,dc=com'),
'password' => env('LDAP_PASSWORD', 'secret'),
@ -40,6 +40,18 @@ return [
'name' => env('LDAP_NAME','LDAP Server'),
],
'opendj' => [
'hosts' => ['opendj'],
'username' => 'cn=Directory Manager',
'password' => 'password',
'port' => 1389,
'base_dn' => 'dc=example,dc=com',
'timeout' => env('LDAP_TIMEOUT', 5),
'use_ssl' => env('LDAP_SSL', false),
'use_tls' => env('LDAP_TLS', false),
'name' => 'OpenDJ Server',
],
],
/*