You are here

function ldap_servers_test_binding_credentials in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.test_form.inc \ldap_servers_test_binding_credentials()
  2. 7 ldap_servers/ldap_servers.test_form.inc \ldap_servers_test_binding_credentials()

Submit hook for the LDAP server form.

1 call to ldap_servers_test_binding_credentials()
ldap_servers_test_form_submit in ldap_servers/ldap_servers.test_form.inc
Submit hook for the LDAP server form.

File

ldap_servers/ldap_servers.test_form.inc, line 388

Code

function ldap_servers_test_binding_credentials(&$ldap_server, $bindpw, &$results_tables) {
  $errors = FALSE;
  $results = [];
  $ldap_result = $ldap_server
    ->connect();
  if ($ldap_result != LDAP_SUCCESS) {
    $results_tables['basic'][] = [
      t('Failed to connect to LDAP server.  See watchdog error logs for details.') . $ldap_server
        ->errorMsg('ldap'),
    ];
    $errors = TRUE;
  }
  if (!$errors) {
    $bind_result = $ldap_server
      ->bind($ldap_server->binddn, $bindpw, FALSE);
    if ($bind_result == LDAP_SUCCESS) {
      $results_tables['basic'][] = [
        t('Successfully bound to server'),
      ];
    }
    else {
      $results_tables['basic'][] = [
        t('Failed to bind to server. ldap error #') . $bind_result . ' ' . $ldap_server
          ->errorMsg('ldap'),
      ];
      $errors = TRUE;
    }
  }
  return [
    $errors,
    $results,
  ];
}