From 9adf13dc8cf7a4c02f6c4364541d86acfd5de136 Mon Sep 17 00:00:00 2001 From: jengo Date: Tue, 31 Oct 2000 11:50:35 +0000 Subject: [PATCH] Edit LDAP users is now working properly --- admin/editaccount.php | 2 +- admin/inc/accounts_ldap.inc.php | 60 ++++++++++++++++++++++++++++++++- preferences/changepassword.php | 20 +++-------- preferences/settings.php | 8 +---- 4 files changed, 65 insertions(+), 25 deletions(-) diff --git a/admin/editaccount.php b/admin/editaccount.php index 7ddbe18d0c..bda8f0eb89 100755 --- a/admin/editaccount.php +++ b/admin/editaccount.php @@ -54,7 +54,7 @@ if (! $totalerrors) { $cd = account_edit(array("loginid" => $n_loginid, "permissions" => $new_permissions, "firstname" => $n_firstname, "lastname" => $n_lastname, - "passwd" => $n_passwd, "account_status" => $account_status, + "passwd" => $n_passwd, "account_status" => $n_account_status, "c_loginid" => $c_loginid, "groups" => $phpgw->accounts->groups_array_to_string($n_groups))); } diff --git a/admin/inc/accounts_ldap.inc.php b/admin/inc/accounts_ldap.inc.php index b665c4ed7a..54e4715ab7 100644 --- a/admin/inc/accounts_ldap.inc.php +++ b/admin/inc/accounts_ldap.inc.php @@ -219,7 +219,65 @@ function account_edit($account_info) { - + global $phpgw, $phpgw_info, $ldap; + + // This is just until the API fully handles reading the LDAP account info. + $lid = $account_info["loginid"]; + if ($account_info["c_loginid"]) { + $phpgw->db->query("update accounts set account_lid='" . $account_info["c_loginid"] + . "' where account_lid='" . $account_info["loginid"] . "'"); + + $account_info["loginid"] = $account_info["c_loginid"]; + + $entry["uid"] = $account_info["loginid"]; + $entry["homeDirectory"] = "/home/" . $account_info["loginid"]; + $entry["mail"] = $account_info["loginid"] . "@" . $phpgw_info["server"]["mail_suffix"]; + } + + if ($account_info["passwd"]) { + $entry["userpassword"] = $phpgw->common->encrypt_password($n_passwd); + + // Update the sessions table. (The user might be logged in) + $phpgw->db->query("update sessions set session_pwd='" . $phpgw->common->encrypt($n_passwd) . "' " + . "where session_lid='$lid'"); + } + + while ($permission = each($account_info["permissions"])) { + if ($phpgw_info["apps"][$permission[0]]["enabled"]) { + $phpgw->accounts->add_app($permission[0]); + } + } + + if (! $account_info["account_status"]) { + $account_info["account_status"] = "L"; + } + + $phpgw->db->query("update accounts set account_firstname='" + . addslashes($account_info["firstname"]) . "', account_lastname='" + . addslashes($account_info["lastname"]) . "', account_permissions='" + . $phpgw->accounts->add_app("",True) . "', account_status='" + . $account_info["account_status"] . "', account_groups='" + . $account_info["groups"] . "' where account_lid='" . $account_info["loginid"] + . "'"); + + $entry["cn"] = sprintf("%s %s", $account_info["firstname"], $account_info["lastname"]); + $entry["sn"] = $account_info["lastname"]; + $entry["givenname"] = $account_info["firstname"]; + + $dn = sprintf("uid=%s, %s", $phpgw_info["user"]["userid"],$phpgw_info["server"]["ldap_context"]); + @ldap_modify($ldap, $dn, $entry); + + $cd = 27; + if ($account_info["c_loginid"] != $account_info["loginid"]) { + $sep = $phpgw->common->filesystem_separator(); + + $basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep; + + if (! @rename($basedir . $lid, $basedir . $account_info["loginid"])) { + $cd = 35; + } + } + return $cd; } function account_delete($account_id) diff --git a/preferences/changepassword.php b/preferences/changepassword.php index a4f7959da8..6b886a6ee1 100755 --- a/preferences/changepassword.php +++ b/preferences/changepassword.php @@ -16,14 +16,10 @@ $phpgw_info["flags"]["currentapp"] = "preferences"; include("../header.inc.php"); - if ($phpgw_info["user"]["permissions"]["anonymous"]) { - Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/")); - exit; - } -if (! $submit) { - $phpgw->common->phpgw_header(); - $phpgw->common->navbar(); + if (! $submit) { + $phpgw->common->phpgw_header(); + $phpgw->common->navbar(); ?>
"> @@ -85,15 +81,7 @@ if (! $submit) { exit; } - if ($phpgw_info["server"]["ldap_encryption_type"] == "DES") { - $salt = $phpgw->common->randomstring(2); - $n_passwd = $phpgw->common->des_cryptpasswd($n_passwd, $salt); - } - if ($phpgw_info["server"]["ldap_encryption_type"] == "MD5") { - $salt = $phpgw->common->randomstring(9); - $n_passwd = $phpgw->common->md5_cryptpasswd($n_passwd, $salt); - } - $entry["userpassword"] = $n_passwd; + $entry["userpassword"] = $phpgw->common->encrypt_password($n_passwd); $dn = sprintf("uid=%s, %s", $phpgw_info["user"]["userid"],$phpgw_info["server"]["ldap_context"]); @ldap_modify($ldap, $dn, $entry); diff --git a/preferences/settings.php b/preferences/settings.php index 32134531e0..2253320f3a 100755 --- a/preferences/settings.php +++ b/preferences/settings.php @@ -155,13 +155,7 @@ } else { $phpgw->common->preferences_delete("byappnotheme",$phpgw_info["user"]["account_id"],"common"); - // If they don't have permissions to the headlines, - // we don't need to lock the table. - if ($phpgw_info["user"]["apps"]["headlines"]) { - $phpgw->db->lock(array("preferences","users_headlines")); - } else { - $phpgw->db->lock("preferences"); - } + $phpgw->db->lock("preferences"); $phpgw->common->preferences_add($phpgw_info["user"]["account_id"],"maxmatchs","common"); $phpgw->common->preferences_add($phpgw_info["user"]["account_id"],"tz_offset","common");