make password changing working from user admin pages

This commit is contained in:
Lars Kneschke 2001-02-12 21:13:09 +00:00
parent 8ce2e59b25
commit 9ebb3bfaae
4 changed files with 56 additions and 27 deletions

View File

@ -142,7 +142,7 @@
if ($_userData['passwd'])
{
$auth = CreateObject('phpgwapi.auth');
# $auth->change_password($old_passwd, $_userData['passwd']);
$auth->change_password($old_passwd, $_userData['passwd'], $_userData['account_id']);
}
$apps = CreateObject('phpgwapi.applications',array(intval($_userData['account_id']),'u'));

View File

@ -84,6 +84,7 @@
$entry["givenname"] = $this->data["firstname"];
ldap_modify($ds, $allValues[0]["dn"], $entry);
#print ldap_error($ds);
}
function add($account_name, $account_type, $first_name, $last_name, $passwd = False)
@ -205,4 +206,16 @@
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('todo', 'run', ".$accountid.", 'u', 1)",__LINE__,__FILE__);
return $accountid;
}
function getDNforID($_account_id)
{
global $phpgw;
$ds = $phpgw->common->ldapConnect();
$sri = ldap_search($ds, $phpgw_info["server"]["ldap_context"], "uidnumber=$_account_id");
$allValues = ldap_get_entries($ds, $sri);
return $allValues[0]["dn"];
}
}

View File

@ -57,17 +57,27 @@
return False;
}
function change_password($old_passwd, $new_passwd, $account_id="") {
function change_password($old_passwd, $new_passwd, $_account_id="")
{
global $phpgw_info, $phpgw;
$ldap = $phpgw->common->ldapConnect();
if ("" == $_account_id)
{
$_account_id = $phpgw_info['user']['account_id'];
}
$encrypted_passwd = $phpgw->common->encrypt_password($new_passwd);
$entry['userpassword'] = $encrypted_passwd;
#$entry['phpgw_lastpasswd_change'] = time();
$dn = $phpgw_info['user']['account_dn'];
$ds = $phpgw->common->ldapConnect();
$sri = ldap_search($ds, $phpgw_info["server"]["ldap_context"], "uidnumber=$_account_id");
$allValues = ldap_get_entries($ds, $sri);
if (!@ldap_modify($ldap, $dn, $entry)) return false;
$entry['userpassword'] = $phpgw->common->encrypt_password($new_passwd);
$dn = $allValues[0]["dn"];
if (!@ldap_modify($ds, $dn, $entry))
{
return false;
}
return $encrypted_passwd;
}
@ -77,9 +87,10 @@
global $phpgw;
$now = time();
$phpgw->db->query("update phpgw_accounts set account_lastloginfrom='"
. "$ip', account_lastlogin='" . $now
. "' where account_lid='$account_lid'",__LINE__,__FILE__);
}
}
}
?>

View File

@ -43,15 +43,20 @@
}
}
function change_password($old_passwd, $new_passwd)
function change_password($old_passwd, $new_passwd, $_account_id="")
{
global $phpgw_info, $phpgw;
$encrypted_passwd = md5($new_passwd);
if ("" == $_account_id)
{
$_account_id = $phpgw_info["user"]["account_id"];
}
$phpgw->db->query("update phpgw_accounts set account_pwd='" . md5($new_passwd) . "' "
. "where account_lid='" . $phpgw_info["user"]["userid"] . "'",__LINE__,__FILE__);
. "where account_id='" . $_account_id . "'",__LINE__,__FILE__);
$phpgw->db->query("update phpgw_accounts set account_lastpwd_change='" . time() . "' where account_id='"
. $phpgw_info["user"]["account_id"] . "'",__LINE__,__FILE__);
. $_account_id . "'",__LINE__,__FILE__);
return $encrypted_passwd;
}