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$ */
class auth
{
class auth
{
function authenticate($username, $passwd)
{
global $phpgw_info, $phpgw, $PHP_AUTH_USER;
function authenticate($username, $passwd) {
global $phpgw_info, $phpgw, $PHP_AUTH_USER;
if (isset($PHP_AUTH_USER)) {
return True;
} else {
return False;
}
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
return False;
}
}
?>
if (isset($PHP_AUTH_USER)) {
return True;
} else {
return False;
}
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
return False;
}
}
?>

View File

@ -24,39 +24,38 @@
/* $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) {
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'];
$ldap = ldap_connect($phpgw_info['server']['ldap_host']);
// generate a bogus password to pass if the user doesn't give us one
// this gets around systems that are anonymous search enabled
if (empty($passwd)) $passwd = crypt(microtime());
// try to bind as the user with user suplied password
if (ldap_bind($ldap,$userDN, $passwd)) return True;
}
// 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'];
// Turn error reporting back to normal
error_reporting(7);
// generate a bogus password to pass if the user doesn't give us one
// this gets around systems that are anonymous search enabled
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
error_reporting(7);
// dn not found or password wrong
return False;
}
// dn not found or password wrong
return False;
}
function change_password($old_passwd, $new_passwd, $_account_id="")
{
global $phpgw_info, $phpgw;
@ -65,32 +64,33 @@
{
$_account_id = $phpgw_info['user']['account_id'];
}
$ds = $phpgw->common->ldapConnect();
$sri = ldap_search($ds, $phpgw_info["server"]["ldap_context"], "uidnumber=$_account_id");
$allValues = ldap_get_entries($ds, $sri);
$entry['userpassword'] = $phpgw->common->encrypt_password($new_passwd);
$dn = $allValues[0]["dn"];
if (!@ldap_modify($ds, $dn, $entry))
{
return false;
}
return $encrypted_passwd;
}
function update_lastlogin($account_lid, $ip)
function update_lastlogin($account_id, $ip)
{
global $phpgw;
$account_id = get_account_id($account_id);
$now = time();
$phpgw->db->query("update phpgw_accounts set account_lastloginfrom='"
. "$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$ */
class auth
{
class auth
{
function authenticate($username, $passwd)
{
global $phpgw_info, $phpgw;
error_reporting(error_reporting() - 2);
function authenticate($username, $passwd) {
global $phpgw_info, $phpgw;
error_reporting(error_reporting() - 2);
if ($phpgw_info['server']['mail_login_type'] == 'vmailmgr')
{
$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') {
$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';
}
error_reporting(error_reporting() + 2);
if ($mailauth == False) {
return False;
} else {
imap_close($mailauth);
return True;
}
}
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);
}
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;
}
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
return False;
}
}
?>

View File

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