You are here

function _ldap_server_ajax_test in Lightweight Directory Access Protocol (LDAP) 6

Implements the AJAX server test.

Parameters

$sid: LDAP server ID.

Return value

The JSON data.

File

./ldap_server.admin.inc, line 495

Code

function _ldap_server_ajax_test($sid) {
  if (!is_numeric($sid)) {
    return;
  }
  $server = new ldap_server($sid);

  #  if ($_POST['bindpw_clear'] == 'undefined') {

  #    $server->set_binddn($_POST['binddn']);

  #    $server->set_bindpw($_POST['bindpw']);

  #  }
  if (!$server
    ->connect()) {
    drupal_json(array(
      'status' => 0,
      'message' => t('Unable to connect to the LDAP server.'),
    ));
  }
  drupal_json($server
    ->bind() ? array(
    'status' => 1,
    'message' => t('Authentication with the LDAP server succeeded.'),
  ) : array(
    'status' => 0,
    'message' => t('Authentication with the LDAP server failed.'),
  ));
  exit;
}