You are here

function ldap_servers_test_binding_credentials in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.test_form.inc \ldap_servers_test_binding_credentials()
  2. 7.2 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 208

Code

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