mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-29 11:23:54 +01:00
Working on LDAP admin section
This commit is contained in:
parent
cb30556aaf
commit
bbcc442177
@ -46,11 +46,22 @@
|
|||||||
$account_info = account_read($method,$start,$sort,$order);
|
$account_info = account_read($method,$start,$sort,$order);
|
||||||
|
|
||||||
while (list($null,$account) = each($account_info)) {
|
while (list($null,$account) = each($account_info)) {
|
||||||
|
// while (list($key) = each($account_info[0])) {
|
||||||
|
// for ($i=0; $i<count($account_info);$i++) {
|
||||||
|
// echo "<br>0: " . $account_info[1][$key];
|
||||||
|
// echo "<br>1: " . $a[2];
|
||||||
|
// echo "<br>2: " . $b[1];
|
||||||
|
|
||||||
|
$lastname = $account["account_lastname"];
|
||||||
|
$firstname = $account["account_firstname"];
|
||||||
|
$account_id = $account["account_id"];
|
||||||
|
$loginid = $account["account_lid"];
|
||||||
|
|
||||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||||
$t->set_var("tr_color",$tr_color);
|
$t->set_var("tr_color",$tr_color);
|
||||||
|
|
||||||
$lastname = $account["account_lastname"];
|
// $lastname = $account["account_lastname"];
|
||||||
$firstname = $account["account_firstname"];
|
// $firstname = $account["account_firstname"];
|
||||||
|
|
||||||
if (! $lastname) $lastname = ' ';
|
if (! $lastname) $lastname = ' ';
|
||||||
if (! $firstname) $firstname = ' ';
|
if (! $firstname) $firstname = ' ';
|
||||||
@ -58,17 +69,17 @@
|
|||||||
$t->set_var("row_firstname",$firstname);
|
$t->set_var("row_firstname",$firstname);
|
||||||
$t->set_var("row_lastname",$lastname);
|
$t->set_var("row_lastname",$lastname);
|
||||||
$t->set_var("row_edit",'<a href="'.$phpgw->link("editaccount.php","account_id="
|
$t->set_var("row_edit",'<a href="'.$phpgw->link("editaccount.php","account_id="
|
||||||
. $account["account_id"]) . '"> ' . lang("Edit") . ' </a>');
|
. $account_id) . '"> ' . lang("Edit") . ' </a>');
|
||||||
|
|
||||||
if ($phpgw_info["user"]["userid"] != $account["account_lid"]) {
|
if ($phpgw_info["user"]["userid"] != $account["account_lid"]) {
|
||||||
$t->set_var("row_delete",'<a href="' . $phpgw->link("deleteaccount.php",'account_id='
|
$t->set_var("row_delete",'<a href="' . $phpgw->link("deleteaccount.php",'account_id='
|
||||||
. $account["account_id"]) . '"> '.lang("Delete").' </a>');
|
. $account_id) . '"> '.lang("Delete").' </a>');
|
||||||
} else {
|
} else {
|
||||||
$t->set_var("row_delete"," ");
|
$t->set_var("row_delete"," ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$t->set_var("row_view",'<a href="' . $phpgw->link("viewaccount.php", "account_id="
|
$t->set_var("row_view",'<a href="' . $phpgw->link("viewaccount.php", "account_id="
|
||||||
. $account["account_id"]) . '"> ' . lang("View") . ' </a>');
|
. $account_id) . '"> ' . lang("View") . ' </a>');
|
||||||
|
|
||||||
if ($total == 1) {
|
if ($total == 1) {
|
||||||
$t->set_var("output","");
|
$t->set_var("output","");
|
||||||
|
@ -24,16 +24,6 @@
|
|||||||
Header("Location: " . $phpgw->link("accounts.php"));
|
Header("Location: " . $phpgw->link("accounts.php"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is gonna go soon. (jengo)
|
|
||||||
function change_owner($app,$table,$field,$new,$old)
|
|
||||||
{
|
|
||||||
global $phpgw, $phpgw_info;
|
|
||||||
|
|
||||||
if ($phpgw_info["apps"][$app]["enabled"] || ! $app) {
|
|
||||||
$phpgw->db->query("update $table set $field='$new' where $field='$old'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($submit) {
|
if ($submit) {
|
||||||
if ($old_loginid != $n_loginid) {
|
if ($old_loginid != $n_loginid) {
|
||||||
if (account_exsists($n_loginid)) {
|
if (account_exsists($n_loginid)) {
|
||||||
@ -64,64 +54,8 @@
|
|||||||
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
|
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Header("Location: " . $phpgw->link("accounts.php", "cd=$cd"));
|
||||||
// $phpgw->db->query("select account_lid from accounts where account_id=$account_id");
|
exit;
|
||||||
// $phpgw->db->next_record();
|
|
||||||
// $lid = $phpgw->db->f("account_lid");
|
|
||||||
|
|
||||||
|
|
||||||
/* if (! $error) {
|
|
||||||
$phpgw->db->lock(array('accounts','preferences','sessions'));
|
|
||||||
if ($n_passwd) {
|
|
||||||
$phpgw->db->query("update accounts set account_pwd='" . md5($n_passwd) . "', "
|
|
||||||
. "account_lastpwd_change='" . time() . "' where account_lid='" . "$lid'");
|
|
||||||
$phpgw->db->query("update sessions set session_pwd='" . addslashes($n_passwd)
|
|
||||||
. "' where session_lid='$lid'");
|
|
||||||
}
|
|
||||||
while ($permission = each($new_permissions)) {
|
|
||||||
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
|
||||||
$phpgw->accounts->add_app($permission[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $n_account_status) {
|
|
||||||
$n_account_status = "L";
|
|
||||||
}
|
|
||||||
$cd = 27;
|
|
||||||
|
|
||||||
// If they changed there loginid, we need to change the owner in ALL
|
|
||||||
// tables to reflect on the new one
|
|
||||||
if ($lid != $n_loginid) {
|
|
||||||
change_owner("","preferences","preference_owner",$n_loginid,$lid);
|
|
||||||
change_owner("addressbook","addressbook","ab_owner",$n_loginid,$lid);
|
|
||||||
change_owner("todo","todo","todo_owner",$n_loginid,$lid);
|
|
||||||
change_owner("","accounts","account_lid",$n_loginid,$lid);
|
|
||||||
change_owner("","sessions","session_lid",$n_loginid,$lid);
|
|
||||||
change_owner("calendar","webcal_entry","cal_create_by",$n_loginid,$lid);
|
|
||||||
change_owner("calendar","webcal_entry_user","cal_login",$n_loginid,$lid);
|
|
||||||
|
|
||||||
if ($lid <> $n_loginid) {
|
|
||||||
$sep = $phpgw->common->filesystem_separator();
|
|
||||||
|
|
||||||
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
|
||||||
|
|
||||||
if (! @rename($basedir . $lid, $basedir . $n_loginid)) {
|
|
||||||
$cd = 35;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$phpgw->db->query("update accounts set account_firstname='" . addslashes($n_firstname) . "',"
|
|
||||||
. " account_lastname='" . addslashes($n_lastname) . "', account_permissions='"
|
|
||||||
. $phpgw->accounts->add_app("",True) . "', account_status='"
|
|
||||||
. "$n_account_status', account_groups='"
|
|
||||||
. $phpgw->accounts->groups_array_to_string($n_groups)
|
|
||||||
. "' where account_lid='$n_loginid'");
|
|
||||||
|
|
||||||
$phpgw->db->unlock();
|
|
||||||
Header("Location: " . $phpgw->link("accounts.php", "cd=$cd"));
|
|
||||||
exit;
|
|
||||||
} // if ! $error */
|
|
||||||
} // if $submit
|
} // if $submit
|
||||||
|
|
||||||
$phpgw->common->phpgw_header();
|
$phpgw->common->phpgw_header();
|
||||||
|
@ -41,7 +41,14 @@
|
|||||||
$sr = ldap_search($ldap,$phpgw_info["server"]["ldap_context"],$filter,array("uid"));
|
$sr = ldap_search($ldap,$phpgw_info["server"]["ldap_context"],$filter,array("uid"));
|
||||||
$info = ldap_get_entries($ldap, $sr);
|
$info = ldap_get_entries($ldap, $sr);
|
||||||
|
|
||||||
return count($info);
|
$total = 0;
|
||||||
|
for ($i=0;$i<count($info);$i++) {
|
||||||
|
if (! $phpgw_info["server"]["global_denied_users"][$info[$i]["uid"][0]]) {
|
||||||
|
$total++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
function account_view($loginid)
|
function account_view($loginid)
|
||||||
@ -64,6 +71,17 @@
|
|||||||
{
|
{
|
||||||
global $phpgw_info, $ldap;
|
global $phpgw_info, $ldap;
|
||||||
|
|
||||||
|
/* echo "sort: $sort";
|
||||||
|
if ($sort == "account_lastname") {
|
||||||
|
$sort = 3;
|
||||||
|
} else if ($sort == "account_firstname") {
|
||||||
|
$sort = 2;
|
||||||
|
} else {
|
||||||
|
$sort = 1;
|
||||||
|
}
|
||||||
|
echo " - sort: $sort";
|
||||||
|
*/
|
||||||
|
|
||||||
$filter = "(|(uid=*))";
|
$filter = "(|(uid=*))";
|
||||||
$sr = ldap_search($ldap,$phpgw_info["server"]["ldap_context"],$filter,array("sn","givenname","uid","uidnumber"));
|
$sr = ldap_search($ldap,$phpgw_info["server"]["ldap_context"],$filter,array("sn","givenname","uid","uidnumber"));
|
||||||
$info = ldap_get_entries($ldap, $sr);
|
$info = ldap_get_entries($ldap, $sr);
|
||||||
@ -72,11 +90,18 @@
|
|||||||
if (! $phpgw_info["server"]["global_denied_users"][$info[$i]["uid"][0]]) {
|
if (! $phpgw_info["server"]["global_denied_users"][$info[$i]["uid"][0]]) {
|
||||||
$account_info[$i]["account_id"] = $info[$i]["uidnumber"][0];
|
$account_info[$i]["account_id"] = $info[$i]["uidnumber"][0];
|
||||||
$account_info[$i]["account_lid"] = $info[$i]["uid"][0];
|
$account_info[$i]["account_lid"] = $info[$i]["uid"][0];
|
||||||
$account_info[$i]["account_firstname"] = $info[$i]["givenname"][0];
|
$account_info[$i]["account_lastname"] = $info[$i]["givenname"][0];
|
||||||
$account_info[$i]["account_lastname"] = $info[$i]["sn"][0];
|
$account_info[$i]["account_firstname"] = $info[$i]["sn"][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// echo " - order: $order";
|
||||||
|
/* if ($order == "ASC") {
|
||||||
|
sort($account_info[$sort]);
|
||||||
|
} else {
|
||||||
|
rsort($account_info[$sort]);
|
||||||
|
} */
|
||||||
|
|
||||||
return $account_info;
|
return $account_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,11 +230,24 @@
|
|||||||
$phpgw->db->next_record();
|
$phpgw->db->next_record();
|
||||||
|
|
||||||
ldap_delete($ldap,"uid=" . $phpgw->db->f("account_lid") . ", ". $phpgw_info["server"]["ldap_context"]);
|
ldap_delete($ldap,"uid=" . $phpgw->db->f("account_lid") . ", ". $phpgw_info["server"]["ldap_context"]);
|
||||||
|
$phpgw->db->query("delete from accounts where account_id='$account_id'");
|
||||||
}
|
}
|
||||||
|
|
||||||
function account_exsists($loginid)
|
function account_exsists($loginid)
|
||||||
{
|
{
|
||||||
|
global $phpgw_info, $ldap;
|
||||||
|
|
||||||
|
$filter = "(|(uid=$loginid))";
|
||||||
|
|
||||||
|
$sr = ldap_search($ldap,$phpgw_info["server"]["ldap_context"],$filter,array("uid"));
|
||||||
|
$total = ldap_get_entries($ldap, $sr);
|
||||||
|
|
||||||
|
// Odd, but it works
|
||||||
|
if (count($total) == 2) {
|
||||||
|
return True;
|
||||||
|
} else {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function account_close()
|
function account_close()
|
||||||
|
@ -140,9 +140,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ($permission = each($account_info["permissions"])) {
|
while ($permission = each($account_info["permissions"])) {
|
||||||
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
||||||
$phpgw->accounts->add_app($permission[0]);
|
$phpgw->accounts->add_app($permission[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $account_info["account_status"]) {
|
if (! $account_info["account_status"]) {
|
||||||
@ -150,27 +150,13 @@
|
|||||||
}
|
}
|
||||||
$cd = 27;
|
$cd = 27;
|
||||||
|
|
||||||
// If they changed there loginid, we need to change the owner in ALL
|
if ($account_info["c_loginid"] != $account_info["loginid"]) {
|
||||||
// tables to reflect on the new one
|
$sep = $phpgw->common->filesystem_separator();
|
||||||
if ($lid != $account_info["loginid"]) {
|
|
||||||
/*
|
|
||||||
change_owner("","preferences","preference_owner",$account_info["loginid"],$lid);
|
|
||||||
change_owner("addressbook","addressbook","ab_owner",$account_info["loginid"],$lid);
|
|
||||||
change_owner("todo","todo","todo_owner",$account_info["loginid"],$lid);
|
|
||||||
// change_owner("","accounts","account_lid",$account_info["loginid"],$lid);
|
|
||||||
change_owner("","sessions","session_lid",$account_info["loginid"],$lid);
|
|
||||||
change_owner("calendar","webcal_entry","cal_create_by",$account_info["loginid"],$lid);
|
|
||||||
change_owner("calendar","webcal_entry_user","cal_login",$account_info["loginid"],$lid);
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($lid != $n_loginid) {
|
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
||||||
$sep = $phpgw->common->filesystem_separator();
|
|
||||||
|
|
||||||
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
if (! @rename($basedir . $lid, $basedir . $account_info["loginid"])) {
|
||||||
|
$cd = 35;
|
||||||
if (! @rename($basedir . $lid, $basedir . $account_info["loginid"])) {
|
|
||||||
$cd = 35;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user