You are here

function _ldaphelp_bind_test in LDAP integration 6

2 calls to _ldaphelp_bind_test()
ldaphelp_bindtrials in ldaphelp/ldaphelp_wizard.inc
ldaphelp_wizard_form in ldaphelp/ldaphelp_wizard.inc
@file wizard file for ldaphelp module

File

ldaphelp/ldaphelp.module, line 139
The ldaphelp module is a module to help admins debug ldap_integration modules.

Code

function _ldaphelp_bind_test($ldapserver) {
  global $_ldapauth_ldap;
  $test = array();
  $_ldapauth_ldap = new LDAPInterface();
  foreach ($ldapserver as $key => $value) {
    $_ldapauth_ldap
      ->setOption($key, $value);
  }
  if ($_ldapauth_ldap
    ->getOption('binddn') && $_ldapauth_ldap
    ->getOption('bindpw')) {
    $test['bind_result'] = $_ldapauth_ldap
      ->connectAndBind($_ldapauth_ldap
      ->getOption('binddn'), $_ldapauth_ldap
      ->getOption('bindpw'));
    $test['bind_type'] = "non-anon";
  }
  else {
    $test['bind_result'] = $_ldapauth_ldap
      ->connectAndBind();
    $test['bind_type'] = "anon";
  }
  if ($test['bind_result']) {
    $test['bind_result_text'] = "Success";
    $test['bind_success'] = TRUE;
  }
  else {
    $test['bind_result_error'] = ldap_error($_ldapauth_ldap->connection);
    $test['bind_result_errno'] = ldap_errno($_ldapauth_ldap->connection);
    $test['bind_result_text'] = "Fail";
    $test['bind_success'] = FALSE;
  }
  return $test;
}