From 50c4666ecce6b5d36a0607317650283b2d3fd8ef Mon Sep 17 00:00:00 2001 From: jengo Date: Tue, 10 Apr 2001 07:58:19 +0000 Subject: [PATCH] SF #413717 - Fixed undefined function update_lastlogin(), this problem was for more then just mail_auth --- phpgwapi/inc/class.auth_http.inc.php | 12 +++ phpgwapi/inc/class.auth_ldap.inc.php | 118 ++++++++++++++------------- phpgwapi/inc/class.auth_mail.inc.php | 13 +++ 3 files changed, 85 insertions(+), 58 deletions(-) diff --git a/phpgwapi/inc/class.auth_http.inc.php b/phpgwapi/inc/class.auth_http.inc.php index 0ee0e5abdb..cef85fd3b8 100644 --- a/phpgwapi/inc/class.auth_http.inc.php +++ b/phpgwapi/inc/class.auth_http.inc.php @@ -41,5 +41,17 @@ global $phpgw_info, $phpgw; return False; } + + // Since there account data will still be stored in SQL, this should be safe to do. (jengo) + 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__); + } } ?> diff --git a/phpgwapi/inc/class.auth_ldap.inc.php b/phpgwapi/inc/class.auth_ldap.inc.php index f6bc9af670..34d2b170d2 100644 --- a/phpgwapi/inc/class.auth_ldap.inc.php +++ b/phpgwapi/inc/class.auth_ldap.inc.php @@ -1,32 +1,33 @@ * - * and Joseph Engo * - * Authentication based on LDAP Server * - * Copyright (C) 2000, 2001 Joseph Engo * - * -------------------------------------------------------------------------* - * This library is part of the phpGroupWare API * - * http://www.phpgroupware.org/api * - * ------------------------------------------------------------------------ * - * This library is free software; you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 of the License, * - * or any later version. * - * This library is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License * - * along with this library; if not, write to the Free Software Foundation, * - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - \**************************************************************************/ + /**************************************************************************\ + * phpGroupWare API - Auth from LDAP * + * This file written by Lars Kneschke * + * and Joseph Engo * + * Authentication based on LDAP Server * + * Copyright (C) 2000, 2001 Joseph Engo * + * -------------------------------------------------------------------------* + * This library is part of the phpGroupWare API * + * http://www.phpgroupware.org/api * + * ------------------------------------------------------------------------ * + * This library is free software; you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as published by * + * the Free Software Foundation; either version 2.1 of the License, * + * or any later version. * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public License * + * along with this library; if not, write to the Free Software Foundation, * + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + \**************************************************************************/ - /* $Id$ */ + /* $Id$ */ class auth { - function authenticate($username, $passwd) { + 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..... @@ -37,7 +38,7 @@ // 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) + if ($allValues['count'] > 0) { // we only care about the first dn $userDN = $allValues[0]['dn']; @@ -54,43 +55,44 @@ // dn not found or password wrong return False; - } - - function change_password($old_passwd, $new_passwd, $_account_id="") - { - global $phpgw_info, $phpgw; - - if ("" == $_account_id) - { - $_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)) + function change_password($old_passwd, $new_passwd, $_account_id="") { - return false; + global $phpgw_info, $phpgw; + + if ("" == $_account_id) + { + $_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; } - return $encrypted_passwd; + // This data needs to be updated in LDAP, not SQL (jengo) + 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_id='$account_id'",__LINE__,__FILE__); + } } - - 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_id='$account_id'",__LINE__,__FILE__); - } -} ?> diff --git a/phpgwapi/inc/class.auth_mail.inc.php b/phpgwapi/inc/class.auth_mail.inc.php index 10dc7d6c3b..4778f4b494 100644 --- a/phpgwapi/inc/class.auth_mail.inc.php +++ b/phpgwapi/inc/class.auth_mail.inc.php @@ -67,5 +67,18 @@ global $phpgw_info, $phpgw; return False; } + + // Since there account data will still be stored in SQL, this should be safe to do. (jengo) + 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__); + } + } ?>