You are here

function _ldapauth_check_ldap in LDAP integration 5.2

1 call to _ldapauth_check_ldap()
_ldapauth_user_authenticate in ./ldapauth.module

File

./ldapauth.module, line 824

Code

function _ldapauth_check_ldap($name, $pass) {
  global $ldap;
  $login_ok = false;
  $result = db_query("SELECT name FROM {ldapauth} WHERE status = '%d' ORDER BY sid", 1);
  while ($row = db_fetch_object($result)) {

    // cycle thru the authentication schemes - first successful one wins
    // instantiate ldap
    _ldapauth_init($row->name);
    $config_name = $ldap
      ->getOption('name');

    // Strip name and server from ID:
    if ($server = strrchr($name, '@')) {
      $login_name = substr($name, 0, strlen($name) - strlen($server));
      $server = substr($server, 1);
    }
    else {
      $login_name = $name;
      $server = '';
    }

    // This is in case somebody tries to log in as "jdoe@"
    if (preg_match('/@$/', $name)) {
      $login_name = $name;
    }
    if (ldapauth_auth($name, $pass, $server)) {
      $login_ok = true;
      break;

      // break out of the auth check cycle
    }
  }
  return $login_ok;
}