You are here

function ldap_servers_update_8404 in Lightweight Directory Access Protocol (LDAP) 8.4

Fix encryption settings.

File

ldap_servers/ldap_servers.install, line 157

Code

function ldap_servers_update_8404() {
  $storage = \Drupal::service('entity_type.manager')
    ->getStorage('ldap_server');

  /** @var \Drupal\ldap_servers\Entity\Server $server */
  foreach ($storage
    ->loadMultiple() as $server) {
    $server
      ->set('encryption', 'none');
    if ($server
      ->get('tls')) {
      $server
        ->set('encryption', 'tls');
    }
    if ($server
      ->get('port') == 636) {
      $server
        ->set('encryption', 'ssl');
    }
    $server
      ->save();
  }
}