Fix account_id use in update_lastlogin to use get_account_id; formatting

This commit is contained in:
Miles Lott 2001-03-26 21:36:32 +00:00
parent 5f06d2940e
commit e2afce4073
4 changed files with 134 additions and 125 deletions

View File

@ -24,21 +24,22 @@
/* $Id$ */ /* $Id$ */
class auth class auth
{ {
function authenticate($username, $passwd)
{
global $phpgw_info, $phpgw, $PHP_AUTH_USER;
function authenticate($username, $passwd) { if (isset($PHP_AUTH_USER)) {
global $phpgw_info, $phpgw, $PHP_AUTH_USER; return True;
} else {
return False;
}
}
if (isset($PHP_AUTH_USER)) { function change_password($old_passwd, $new_passwd) {
return True; global $phpgw_info, $phpgw;
} else { return False;
return False; }
} }
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
return False;
}
}
?> ?>

View File

@ -24,38 +24,37 @@
/* $Id$ */ /* $Id$ */
class auth class auth
{ {
function authenticate($username, $passwd) {
global $phpgw_info, $phpgw;
// error_reporting MUST be set to zero, otherwise you'll get nasty LDAP errors with a bad login/pass...
// these are just "warnings" and can be ignored.....
error_reporting(0);
function authenticate($username, $passwd) { $ldap = ldap_connect($phpgw_info['server']['ldap_host']);
global $phpgw_info, $phpgw;
// error_reporting MUST be set to zero, otherwise you'll get nasty LDAP errors with a bad login/pass...
// these are just "warnings" and can be ignored.....
error_reporting(0);
$ldap = ldap_connect($phpgw_info['server']['ldap_host']); // find the dn for this uid, the uid is not always in the dn
$sri = ldap_search($ldap, $phpgw_info['server']['ldap_context'], 'uid='.$username);
$allValues = ldap_get_entries($ldap, $sri);
if($allValues['count'] > 0)
{
// we only care about the first dn
$userDN = $allValues[0]['dn'];
// find the dn for this uid, the uid is not always in the dn // generate a bogus password to pass if the user doesn't give us one
$sri = ldap_search($ldap, $phpgw_info['server']['ldap_context'], 'uid='.$username); // this gets around systems that are anonymous search enabled
$allValues = ldap_get_entries($ldap, $sri); if (empty($passwd)) $passwd = crypt(microtime());
if($allValues['count'] > 0) // try to bind as the user with user suplied password
{ if (ldap_bind($ldap,$userDN, $passwd)) return True;
// we only care about the first dn }
$userDN = $allValues[0]['dn'];
// generate a bogus password to pass if the user doesn't give us one // Turn error reporting back to normal
// this gets around systems that are anonymous search enabled error_reporting(7);
if (empty($passwd)) $passwd = crypt(microtime());
// try to bind as the user with user suplied password
if (ldap_bind($ldap,$userDN, $passwd)) return True;
}
// Turn error reporting back to normal // dn not found or password wrong
error_reporting(7); return False;
}
// dn not found or password wrong
return False;
}
function change_password($old_passwd, $new_passwd, $_account_id="") function change_password($old_passwd, $new_passwd, $_account_id="")
{ {
@ -82,15 +81,16 @@
return $encrypted_passwd; return $encrypted_passwd;
} }
function update_lastlogin($account_lid, $ip) function update_lastlogin($account_id, $ip)
{ {
global $phpgw; global $phpgw;
$account_id = get_account_id($account_id);
$now = time(); $now = time();
$phpgw->db->query("update phpgw_accounts set account_lastloginfrom='" $phpgw->db->query("update phpgw_accounts set account_lastloginfrom='"
. "$ip', account_lastlogin='" . $now . "$ip', account_lastlogin='" . $now
. "' where account_lid='$account_lid'",__LINE__,__FILE__); . "' where account_id='$account_id'",__LINE__,__FILE__);
} }
} }
?> ?>

View File

@ -23,42 +23,49 @@
/* $Id$ */ /* $Id$ */
class auth class auth
{ {
function authenticate($username, $passwd)
{
global $phpgw_info, $phpgw;
error_reporting(error_reporting() - 2);
function authenticate($username, $passwd) { if ($phpgw_info['server']['mail_login_type'] == 'vmailmgr')
global $phpgw_info, $phpgw; {
error_reporting(error_reporting() - 2); $username = $username . '@' . $phpgw_info['server']['mail_suffix'];
}
if ($phpgw_info['server']['mail_server_type']=='imap')
{
$phpgw_info['server']['mail_port'] = '143';
}
elseif ($phpgw_info['server']['mail_server_type']=='pop3')
{
$phpgw_info['server']['mail_port'] = '110';
}
if( $phpgw_info['server']['mail_server_type']=='pop3')
{
$mailauth = imap_open('{'.$phpgw_info['server']['mail_server'].'/pop3'
.':'.$phpgw_info['server']['mail_port'].'}INBOX', $username , $passwd);
}
else
{ //assume imap
$mailauth = imap_open('{'.$phpgw_info['server']['mail_server']
.':'.$phpgw_info['server']['mail_port'].'}INBOX', $username , $passwd);
}
if ($phpgw_info['server']['mail_login_type'] == 'vmailmgr') { error_reporting(error_reporting() + 2);
$username = $username . '@' . $phpgw_info['server']['mail_suffix']; if ($mailauth == False) {
} return False;
if ($phpgw_info['server']['mail_server_type']=='imap') { } else {
$phpgw_info['server']['mail_port'] = '143'; imap_close($mailauth);
} elseif ($phpgw_info['server']['mail_server_type']=='pop3') { return True;
$phpgw_info['server']['mail_port'] = '110'; }
} }
if( $phpgw_info['server']['mail_server_type']=='pop3') { function change_password($old_passwd, $new_passwd) {
$mailauth = imap_open('{'.$phpgw_info['server']['mail_server'].'/pop3' global $phpgw_info, $phpgw;
.':'.$phpgw_info['server']['mail_port'].'}INBOX', $username , $passwd); return False;
} else { //assume imap }
$mailauth = imap_open('{'.$phpgw_info['server']['mail_server'] }
.':'.$phpgw_info['server']['mail_port'].'}INBOX', $username , $passwd);
}
error_reporting(error_reporting() + 2);
if ($mailauth == False) {
return False;
} else {
imap_close($mailauth);
return True;
}
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
return False;
}
}
?> ?>

View File

@ -24,47 +24,48 @@
/* $Id$ */ /* $Id$ */
class auth class auth
{ {
function authenticate($username, $passwd)
{
global $phpgw_info, $phpgw;
$db = $phpgw->db;
function authenticate($username, $passwd) $db->query("SELECT * FROM phpgw_accounts WHERE account_lid = '$username' AND "
{ . "account_pwd='" . md5($passwd) . "' AND account_status ='A'",__LINE__,__FILE__);
global $phpgw_info, $phpgw; $db->next_record();
$db = $phpgw->db;
$db->query("SELECT * FROM phpgw_accounts WHERE account_lid = '$username' AND " if ($db->f('account_lid')) {
. "account_pwd='" . md5($passwd) . "' AND account_status ='A'",__LINE__,__FILE__); return True;
$db->next_record(); } else {
return False;
}
}
if ($db->f('account_lid')) { function change_password($old_passwd, $new_passwd, $_accountid="")
return True; {
} else { global $phpgw_info, $phpgw;
return False;
}
}
function change_password($old_passwd, $new_passwd, $_accountid="") $encrypted_passwd = md5($new_passwd);
{ $_account_id = get_account_id($_accountid);
global $phpgw_info, $phpgw;
$encrypted_passwd = md5($new_passwd); $phpgw->db->query("update phpgw_accounts set account_pwd='" . md5($new_passwd) . "' "
$_account_id = get_account_id($_accountid); . "where account_id='" . $_account_id . "'",__LINE__,__FILE__);
$phpgw->db->query("update phpgw_accounts set account_lastpwd_change='" . time() . "' where account_id='"
. $_account_id . "'",__LINE__,__FILE__);
$phpgw->db->query("update phpgw_accounts set account_pwd='" . md5($new_passwd) . "' " return $encrypted_passwd;
. "where account_id='" . $_account_id . "'",__LINE__,__FILE__); }
$phpgw->db->query("update phpgw_accounts set account_lastpwd_change='" . time() . "' where account_id='"
. $_account_id . "'",__LINE__,__FILE__);
return $encrypted_passwd; function update_lastlogin($account_id, $ip)
} {
global $phpgw;
function update_lastlogin($account_id, $ip) $account_id = get_account_id($account_id);
{
global $phpgw;
$phpgw->db->query("update phpgw_accounts set account_lastloginfrom='" $phpgw->db->query("update phpgw_accounts set account_lastloginfrom='"
. "$ip', account_lastlogin='" . time() . "$ip', account_lastlogin='" . time()
. "' where account_id='$account_id'",__LINE__,__FILE__); . "' where account_id='$account_id'",__LINE__,__FILE__);
} }
} }
?> ?>