Changeset View
Changeset View
Standalone View
Standalone View
src/app/Backends/LDAP.php
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | class LDAP | ||||
{ | { | ||||
if (!empty(self::$ldap)) { | if (!empty(self::$ldap)) { | ||||
self::$ldap->close(); | self::$ldap->close(); | ||||
self::$ldap = null; | self::$ldap = null; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Validates that ldap is available as configured. | |||||
* | |||||
* @throws \Exception | |||||
*/ | |||||
public static function healthcheck(): void | |||||
{ | |||||
$config = self::getConfig('admin'); | |||||
machniak: This `if` is kinda redundant. The method should work anyway. Also, just "validate" as a method… | |||||
$ldap = self::initLDAP($config); | |||||
$mgmtRootDN = \config('ldap.admin.root_dn'); | |||||
$hostedRootDN = \config('ldap.hosted.root_dn'); | |||||
$result = $ldap->search($mgmtRootDN, '', 'base'); | |||||
if (!$result || $result->count() != 1) { | |||||
self::throwException($ldap, "Failed to find the configured management domain $mgmtRootDN"); | |||||
} | |||||
$result = $ldap->search($hostedRootDN, '', 'base'); | |||||
if (!$result || $result->count() != 1) { | |||||
self::throwException($ldap, "Failed to find the configured hosted domain $hostedRootDN"); | |||||
} | |||||
} | |||||
/** | |||||
* Create a domain in LDAP. | * Create a domain in LDAP. | ||||
* | * | ||||
* @param \App\Domain $domain The domain to create. | * @param \App\Domain $domain The domain to create. | ||||
* | * | ||||
* @throws \Exception | * @throws \Exception | ||||
*/ | */ | ||||
public static function createDomain(Domain $domain): void | public static function createDomain(Domain $domain): void | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,311 Lines • Show Last 20 Lines |
This if is kinda redundant. The method should work anyway. Also, just "validate" as a method name is maybe not the best name. How about "heathcheck" or "setupcheck"?