mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:19:00 +01:00
make password changing working from user admin pages
This commit is contained in:
parent
8ce2e59b25
commit
9ebb3bfaae
@ -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'));
|
||||
|
@ -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"];
|
||||
}
|
||||
}
|
||||
|
@ -57,29 +57,40 @@
|
||||
return False;
|
||||
}
|
||||
|
||||
function change_password($old_passwd, $new_passwd, $account_id="") {
|
||||
global $phpgw_info, $phpgw;
|
||||
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'];
|
||||
}
|
||||
|
||||
$ds = $phpgw->common->ldapConnect();
|
||||
$sri = ldap_search($ds, $phpgw_info["server"]["ldap_context"], "uidnumber=$_account_id");
|
||||
$allValues = ldap_get_entries($ds, $sri);
|
||||
|
||||
|
||||
$encrypted_passwd = $phpgw->common->encrypt_password($new_passwd);
|
||||
$entry['userpassword'] = $encrypted_passwd;
|
||||
#$entry['phpgw_lastpasswd_change'] = time();
|
||||
$dn = $phpgw_info['user']['account_dn'];
|
||||
|
||||
if (!@ldap_modify($ldap, $dn, $entry)) return false;
|
||||
|
||||
return $encrypted_passwd;
|
||||
}
|
||||
|
||||
function update_lastlogin($account_lid, $ip)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$now = time();
|
||||
$phpgw->db->query("update phpgw_accounts set account_lastloginfrom='"
|
||||
. "$ip', account_lastlogin='" . $now
|
||||
. "' where account_lid='$account_lid'",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
$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)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$now = time();
|
||||
|
||||
$phpgw->db->query("update phpgw_accounts set account_lastloginfrom='"
|
||||
. "$ip', account_lastlogin='" . $now
|
||||
. "' where account_lid='$account_lid'",__LINE__,__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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user