13d12
< define('LDAPAUTH_AUTH_HTTP',            2); 
38d36
<   global $user;
41,76d38
< 
<   if (LDAPAUTH_LOGIN_PROCESS == LDAPAUTH_AUTH_HTTP) {
<     $authname = '';
<     // Make sure we get the remote user whichever way it is available.
<     if (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
<       $authname = $_SERVER['REDIRECT_REMOTE_USER'];
<     }
<     elseif (isset($_SERVER['REMOTE_USER'])) {
<       $authname = $_SERVER['REMOTE_USER'];
<     }
< 
<     $authname = trim($authname);
<     // Pretty up the username from NTLM authentication (i.e. Windows)
<     // Get 'bar' from 'foo1\foo2\bar'
<     $authname = array_pop(explode("\\", $authname));
<     // Get 'foo' from 'foo@bar'
<     $authname = array_shift(explode('@', $authname));
< 
<     // Perform some cleanup so plaintext passwords aren't available under
<     // mod_auth_kerb.
<     unset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
< 
<     // Retrieve user credentials
<     $result = db_query("SELECT uid FROM {authmap} WHERE authname = '%s' AND module = 'ldapauth'", $authname);
<     $expected = db_fetch_array($result);
<     if (isset($user) && $user->uid === $expected['uid']) {
<       // Do nothing: user is already logged into Drupal with session data matching
<       // HTTP authentication.
<     }
<     else {
<       $login['name'] = $authname;
<       $login['pass'] = 'password';
<       ldapauth_authenticate($login);
<     }
<   }
< 
176c138
<         if (isset($account->ldap_authentified) && (LDAPAUTH_LOGIN_PROCESS == LDAPAUTH_AUTH_EXCLUSIVED || LDAPAUTH_LOGIN_PROCESS == LDAPAUTH_AUTH_HTTP || !LDAPAUTH_SYNC_PASSWORDS)) {
---
>         if (isset($account->ldap_authentified) && (LDAPAUTH_LOGIN_PROCESS == LDAPAUTH_AUTH_EXCLUSIVED || !LDAPAUTH_SYNC_PASSWORDS)) {
189c151
<          'ldap_server' => array('#type' => 'user_profile_item', '#title' => t('LDAP server'), '#value' => l($row->name, 'admin/settings/ldap/ldapauth/edit/'. $row->sid), '#weight' => 0),
---
>          'ldap_server' => array('#type' => 'user_profile_item', '#title' => t('LDAP server'), '#value' => l($row->name, 'admin/settings/ldapauth/edit/'. $row->sid), '#weight' => 0),
297,301c259,263
< //  $result = db_query("SELECT uid FROM {users} WHERE name = '%s' AND uid = '1'", $name);
< //  if ($account = db_fetch_object($result)) {
< //    user_authenticate($form_values);
< //    return;
< //  }
---
>   $result = db_query("SELECT uid FROM {users} WHERE name = '%s' AND uid = '1'", $name);
>   if ($account = db_fetch_object($result)) {
>     user_authenticate($form_values);
>     return;
>   }
420,424c382,384
<     if (LDAPAUTH_LOGIN_PROCESS != LDAPAUTH_AUTH_HTTP) {
<       // Try to authenticate.
<       if (!$_ldapauth_ldap->connect($dn, $pass))
<         continue;
<     }
---
>     // Try to authenticate.
>     if (!$_ldapauth_ldap->connect($dn, $pass))
>       continue;
