You are here

protected function SimpleLdapServerSettingsForm::getBindStatus in Simple LDAP 8

Helper function that returns a message about the status of the connection.

1 call to SimpleLdapServerSettingsForm::getBindStatus()
SimpleLdapServerSettingsForm::buildForm in src/Form/SimpleLdapServerSettingsForm.php
Form constructor.

File

src/Form/SimpleLdapServerSettingsForm.php, line 153

Class

SimpleLdapServerSettingsForm

Namespace

Drupal\simple_ldap\Form

Code

protected function getBindStatus() {
  $config = $this
    ->config('simple_ldap.server');
  $host = $config
    ->get('host');
  if (!empty($host)) {
    $server = \Drupal::service('simple_ldap.server');
    $server
      ->connect();
    if ($server
      ->bind()) {
      $status = $this
        ->t("Successfully binded to @host.", array(
        '@host' => $host,
      ));
    }
    else {
      $status = $this
        ->t("Could not bind to @host. Please check your settings below.", array(
        '@host' => $host,
      ));
    }
  }
  else {
    $status = 'Not connected.';
  }
  return $status;
}