false, 'port' => 389, 'encryption' => 'tls', 'email_attribute' => 'mail', 'name_attribute' => 'cn', 'auto_provision' => false, 'auto_approve' => false, ]; protected function casts(): array { return [ 'active' => 'boolean', 'port' => 'integer', 'encryption' => LdapEncryption::class, 'bind_password' => 'encrypted', 'auto_provision' => 'boolean', 'auto_approve' => 'boolean', ]; } public static function current(): self { return static::query()->firstOrNew([]); } /** * Whether a login may consult the directory at all. * * The extension check is part of the answer rather than a separate * question: an administrator can save settings on a server that cannot * talk LDAP, and every login must then behave exactly as if the * feature were switched off rather than throwing. */ public function usable(): bool { return $this->active && extension_loaded('ldap') && is_string($this->host) && $this->host !== '' && is_string($this->base_dn) && $this->base_dn !== ''; } }