You are here

function ldap_servers_update_8301 in Lightweight Directory Access Protocol (LDAP) 8.3

Same name and namespace in other branches
  1. 8.4 ldap_servers/ldap_servers.install \ldap_servers_update_8301()

Updates bind method to new value.

File

ldap_servers/ldap_servers.install, line 45
Install, update and uninstall functions for the LDAP API module.

Code

function ldap_servers_update_8301() {
  $factory = \Drupal::service('ldap.servers');

  /** @var \Drupal\ldap_servers\ServerFactory $factory */
  $servers = $factory
    ->getAllServers();
  foreach ($servers as $server) {
    $currentMethod = $server
      ->get('bind_method');
    if ($currentMethod == 1) {
      $server
        ->set('bind_method', 'service_account');
    }
    elseif ($currentMethod == 2) {
      $server
        ->set('bind_method', 'user');
    }
    elseif ($currentMethod == 3) {
      $server
        ->set('bind_method', 'anon');
    }
    elseif ($currentMethod == 4) {
      $server
        ->set('bind_method', 'anon_user');
    }
    $server
      ->save();
  }
}