diff --git a/README.md b/README.md index 779a3d1..743342d 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/app/Classes/LDAP/Server.php b/app/Classes/LDAP/Server.php index f215c17..161a8b5 100644 --- a/app/Classes/LDAP/Server.php +++ b/app/Classes/LDAP/Server.php @@ -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'); diff --git a/config/ldap.php b/config/ldap.php index c31183b..92f64b9 100644 --- a/config/ldap.php +++ b/config/ldap.php @@ -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', + ], + ], /*