You are here

function ldap_servers_test_binding_credentials in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.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 355

Code

function ldap_servers_test_binding_credentials(&$ldap_server, $bindpw, &$results_tables) {
  $errors = FALSE;
  $results = array();
  $ldap_result = $ldap_server
    ->connect();
  if ($ldap_result != LDAP_SUCCESS) {
    $results_tables['basic'][] = array(
      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'][] = array(
        t('Successfully bound to server'),
      );
    }
    else {
      $results_tables['basic'][] = array(
        t('Failed to bind to server. ldap error #') . $bind_result . ' ' . $ldap_server
          ->errorMsg('ldap'),
      );
      $errors = TRUE;
    }
  }
  return array(
    $errors,
    $results,
  );
}