mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-13 17:38:19 +01:00
Merged in LDAP patch
This commit is contained in:
parent
38fa9d6cdb
commit
74e0869c8f
@ -53,10 +53,10 @@
|
||||
|
||||
if (! $totalerrors) {
|
||||
$cd = account_edit(array("loginid" => $n_loginid, "permissions" => $new_permissions,
|
||||
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
||||
"passwd" => $n_passwd, "account_status" => $n_account_status,
|
||||
"c_loginid" => $c_loginid,
|
||||
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
|
||||
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
||||
"passwd" => $n_passwd, "account_status" => $n_account_status,
|
||||
"c_loginid" => $c_loginid, "account_id" => rawurldecode($account_id),
|
||||
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
|
||||
}
|
||||
|
||||
Header("Location: " . $phpgw->link("accounts.php", "cd=$cd"));
|
||||
@ -66,17 +66,14 @@
|
||||
$phpgw->common->phpgw_header();
|
||||
$phpgw->common->navbar();
|
||||
|
||||
$phpgw->db->query("select account_lid from accounts where account_id=$account_id");
|
||||
$phpgw->db->next_record();
|
||||
$db_perms = $phpgw->accounts->read_apps($phpgw->db->f("account_lid"));
|
||||
$userData = $phpgw->accounts->read_userData($account_id);
|
||||
|
||||
$db_perms = $phpgw->accounts->read_apps($userData["account_lid"]);
|
||||
|
||||
$phpgw->db->query("select * from accounts where account_id=$account_id");
|
||||
$phpgw->db->next_record();
|
||||
$account_status = $phpgw->db->f("account_status");
|
||||
?>
|
||||
<form method="POST" action="<?php echo $phpgw->link("editaccount.php"); ?>">
|
||||
<input type="hidden" name="account_id" value="<? echo $account_id; ?>">
|
||||
<input type="hidden" name="old_loginid" value="<? echo $phpgw->db->f("account_lid"); ?>">
|
||||
<input type="hidden" name="account_id" value="<? echo rawurlencode($userData["account_id"]); ?>">
|
||||
<input type="hidden" name="old_loginid" value="<? echo $userData["account_lid"]; ?>">
|
||||
<?php
|
||||
if ($error) {
|
||||
echo "<center>" . $phpgw->common->error_list($error) . "</center>";
|
||||
@ -86,21 +83,21 @@
|
||||
<table border=0 width=65%>
|
||||
<tr>
|
||||
<td><?php echo lang("LoginID"); ?></td>
|
||||
<td><input name="n_loginid" value="<? echo $phpgw->db->f("account_lid"); ?>"></td>
|
||||
<td><input name="n_loginid" value="<? echo $userData["account_lid"]; ?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo lang("First Name"); ?></td>
|
||||
<td><input name="n_firstname" value="<?echo $phpgw->db->f("account_firstname"); ?>"></td>
|
||||
<td><input name="n_firstname" value="<?echo $userData["firstname"]; ?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo lang("Last Name"); ?></td>
|
||||
<td><input name="n_lastname" value="<? echo $phpgw->db->f("account_lastname"); ?>"></td>
|
||||
<td><input name="n_lastname" value="<? echo $userData["lastname"]; ?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo lang("Groups"); ?></td>
|
||||
<td><select name="n_groups[]" multiple size="5">
|
||||
<?php
|
||||
$user_groups = $phpgw->accounts->read_group_names($phpgw->db->f("account_lid"));
|
||||
$user_groups = $phpgw->accounts->read_group_names($userData["account_lid"]);
|
||||
|
||||
$phpgw->db->query("select * from groups");
|
||||
while ($phpgw->db->next_record()) {
|
||||
@ -148,7 +145,10 @@
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo lang("Account active"); ?></td>
|
||||
<td><input type="checkbox" name="n_account_status" value="A" <?php if ($account_status == "A") { echo " checked"; } ?>>
|
||||
<td>
|
||||
<input type="checkbox" name="n_account_status" value="A"
|
||||
<?php if ($userData["status"] == "A") { echo " checked"; } ?>
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -51,6 +51,8 @@
|
||||
return $total;
|
||||
}
|
||||
|
||||
|
||||
// i think we don't need this anymore, replaced by $phpgw->accounts->read_userData();
|
||||
function account_view($loginid)
|
||||
{
|
||||
global $phpgw_info, $ldap;
|
||||
@ -86,9 +88,9 @@
|
||||
$sr = ldap_search($ldap,$phpgw_info["server"]["ldap_context"],$filter,array("sn","givenname","uid","uidnumber"));
|
||||
$info = ldap_get_entries($ldap, $sr);
|
||||
|
||||
for ($i=0; $i<count($info); $i++) {
|
||||
for ($i=0; $i<$info["count"]; $i++) {
|
||||
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"] = rawurlencode($info[$i]["dn"]);
|
||||
$account_info[$i]["account_lid"] = $info[$i]["uid"][0];
|
||||
$account_info[$i]["account_lastname"] = $info[$i]["givenname"][0];
|
||||
$account_info[$i]["account_firstname"] = $info[$i]["sn"][0];
|
||||
@ -114,15 +116,15 @@
|
||||
// This method is only temp. We need to figure out the best way to assign uidnumbers and
|
||||
// guidnumbers.
|
||||
|
||||
$phpgw->db->query("select (max(account_id)+1) from accounts");
|
||||
$phpgw->db->next_record();
|
||||
//$phpgw->db->query("select (max(account_id)+1) from accounts");
|
||||
//$phpgw->db->next_record();
|
||||
|
||||
$account_info["account_id"] = $phpgw->db->f(0);
|
||||
//$account_info["account_id"] = $phpgw->db->f(0);
|
||||
|
||||
// Much of this is going to be guess work for now, until we get things planned out.
|
||||
$entry["uid"] = $account_info["loginid"];
|
||||
$entry["uidNumber"] = $account_info["account_id"];
|
||||
$entry["gidNumber"] = $account_info["account_id"];
|
||||
//$entry["uidNumber"] = $account_info["account_id"];
|
||||
#$entry["gidNumber"] = $account_info["account_id"];
|
||||
$entry["userpassword"] = $account_info["passwd"];
|
||||
$entry["loginShell"] = "/bin/bash";
|
||||
$entry["homeDirectory"] = "/home/" . $account_info["loginid"];
|
||||
@ -149,9 +151,29 @@
|
||||
$entry["objectclass"][3] = "inetOrgperson";
|
||||
$entry["objectclass"][4] = "person";
|
||||
$entry["objectclass"][5] = "top";
|
||||
/* $dn=sprintf("cn=%s %s, %s", $givenname, $sn, $BASEDN);*/
|
||||
$dn=sprintf("uid=%s, %s", $account_info["loginid"], $phpgw_info["server"]["ldap_context"]);
|
||||
|
||||
$i=0;
|
||||
reset ($account_info["permissions"]);
|
||||
while (list($key,$value) = each($account_info["permissions"]))
|
||||
{
|
||||
$entry["phpgw_account_perms"][$i] = $key;
|
||||
$i++;
|
||||
}
|
||||
|
||||
// find a free userid, we need that for the dn
|
||||
$sri = ldap_search($ldap,rawurldecode("$dn"),"objectclass=*");
|
||||
$allValues = ldap_get_entries($ldap, $sri);
|
||||
|
||||
$newUIDNumber = 0;
|
||||
for($i=0; $i < $allValues["count"]; $i++)
|
||||
{
|
||||
if (($allValues[$i]["uidnumber"][0]) > $newUIDNumber) $newUIDNumber = $allValues[$i]["uidnumber"][0];
|
||||
}
|
||||
$newUIDNumber++;
|
||||
$entry["uidNumber"] = $newUIDNumber;
|
||||
|
||||
$dn=sprintf("uidnumber=%s, %s", $newUIDNumber, $phpgw_info["server"]["ldap_context"]);
|
||||
|
||||
// add the entries
|
||||
if (ldap_add($ldap, $dn, $entry)) {
|
||||
$cd = 28;
|
||||
@ -162,23 +184,23 @@
|
||||
@ldap_close($ldap);
|
||||
|
||||
add_default_preferences($account_info["account_id"]);
|
||||
$phpgw->db->lock(array("accounts","preferences"));
|
||||
#$phpgw->db->lock(array("accounts","preferences"));
|
||||
|
||||
while ($permission = each($account_info["permissions"])) {
|
||||
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
||||
$phpgw->accounts->add_app($permission[0]);
|
||||
}
|
||||
}
|
||||
#while ($permission = each($account_info["permissions"])) {
|
||||
# if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
||||
# $phpgw->accounts->add_app($permission[0]);
|
||||
# }
|
||||
#}
|
||||
|
||||
$sql = "insert into accounts (account_id,account_lid,account_pwd,account_firstname,"
|
||||
. "account_lastname,account_permissions,account_groups,account_status,"
|
||||
. "account_lastpwd_change) values ('" . $account_info["account_id"] . "','"
|
||||
. $account_info["loginid"] . "','x','". addslashes($account_info["firstname"]) . "','"
|
||||
. addslashes($account_info["lastname"]) . "','" . $phpgw->accounts->add_app("",True)
|
||||
. "','" . $account_info["groups"] . "','A',0)";
|
||||
#$sql = "insert into accounts (account_id,account_lid,account_pwd,account_firstname,"
|
||||
# . "account_lastname,account_permissions,account_groups,account_status,"
|
||||
# . "account_lastpwd_change) values ('" . $account_info["account_id"] . "','"
|
||||
# . $account_info["loginid"] . "','x','". addslashes($account_info["firstname"]) . "','"
|
||||
# . addslashes($account_info["lastname"]) . "','" . $phpgw->accounts->add_app("",True)
|
||||
# . "','" . $account_info["groups"] . "','A',0)";
|
||||
|
||||
$phpgw->db->query($sql);
|
||||
$phpgw->db->unlock();
|
||||
#$phpgw->db->query($sql);
|
||||
#$phpgw->db->unlock();
|
||||
|
||||
$sep = $phpgw->common->filesystem_separator();
|
||||
|
||||
@ -196,18 +218,17 @@
|
||||
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"];
|
||||
$entry["mail"] = $account_info["loginid"] . "@" . $phpgw_info["server"]["mail_suffix"];
|
||||
}
|
||||
|
||||
if ($account_info["passwd"]) {
|
||||
@ -228,19 +249,28 @@
|
||||
$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"]
|
||||
. "'");
|
||||
#$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"];
|
||||
$entry["cn"] = sprintf("%s %s", $account_info["firstname"], $account_info["lastname"]);
|
||||
$entry["sn"] = $account_info["lastname"];
|
||||
$entry["givenname"] = $account_info["firstname"];
|
||||
$entry["phpgw_status"] = $account_info["account_status"];
|
||||
|
||||
$i=0;
|
||||
reset ($account_info["permissions"]);
|
||||
while (list($key,$value) = each($account_info["permissions"]))
|
||||
{
|
||||
$entry["phpgw_account_perms"][$i] = $key;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$dn = sprintf("uid=%s, %s", $phpgw_info["user"]["userid"],$phpgw_info["server"]["ldap_context"]);
|
||||
$dn = $account_info["account_id"];
|
||||
@ldap_modify($ldap, $dn, $entry);
|
||||
|
||||
$cd = 27;
|
||||
@ -260,11 +290,7 @@
|
||||
{
|
||||
global $phpgw_info, $phpgw, $ldap;
|
||||
|
||||
$phpgw->db->query("select account_lid from accounts where account_id='$account_id'");
|
||||
$phpgw->db->next_record();
|
||||
|
||||
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'");
|
||||
ldap_delete($ldap,$account_id);
|
||||
}
|
||||
|
||||
function account_exsists($loginid)
|
||||
|
@ -25,20 +25,26 @@
|
||||
Header("Location: " . $phpgw->link("accounts.php"));
|
||||
}
|
||||
|
||||
$phpgw->db->query("select account_lid from accounts where account_id='$account_id'");
|
||||
$phpgw->db->next_record();
|
||||
$loginid = $phpgw->db->f("account_lid");
|
||||
|
||||
$db_perms = $phpgw->accounts->read_apps($loginid);
|
||||
$account_info = account_view($loginid);
|
||||
$userData = $phpgw->accounts->read_userData($account_id);
|
||||
|
||||
$phpgw->db->query("select account_lastlogin,account_lastloginfrom,account_status from accounts "
|
||||
. "where account_id='$account_id'");
|
||||
$phpgw->db->next_record();
|
||||
$loginid = $userData["account_lid"];
|
||||
$account_lastlogin = $userData["account_lastlogin"];
|
||||
$account_lastloginfrom = $userData["account_lastloginfrom"];
|
||||
$account_status = $userData["account_status"];
|
||||
|
||||
$db_perms = $phpgw->accounts->read_apps($loginid);
|
||||
|
||||
|
||||
#$phpgw->db->query("select account_lid from accounts where account_id='$account_id'");
|
||||
#$phpgw->db->next_record();
|
||||
#$loginid = $phpgw->db->f("account_lid");
|
||||
|
||||
#$account_info = account_view($loginid);
|
||||
|
||||
#$phpgw->db->query("select account_lastlogin,account_lastloginfrom,account_status from accounts "
|
||||
# . "where account_id='$account_id'");
|
||||
#$phpgw->db->next_record();
|
||||
|
||||
$account_lastlogin = $phpgw->db->f("account_lastlogin");
|
||||
$account_lastloginfrom = $phpgw->db->f("account_lastloginfrom");
|
||||
$account_status = $phpgw->db->f("account_status");
|
||||
|
||||
?>
|
||||
<center>
|
||||
@ -55,12 +61,12 @@
|
||||
|
||||
<tr bgcolor="<?php echo $phpgw_info["theme"]["row_off"]; ?>">
|
||||
<td width="40%"><?php echo lang("First Name"); ?></td>
|
||||
<td width="60%"><?php echo $account_info["account_firstname"]; ?> </td>
|
||||
<td width="60%"><?php echo $userData["firstname"]; ?> </td>
|
||||
</tr>
|
||||
|
||||
<tr bgcolor="<?php echo $phpgw_info["theme"]["row_on"]; ?>">
|
||||
<td width="40%"><?php echo lang("Last Name"); ?></td>
|
||||
<td width="60%"><?php echo $account_info["account_lastname"]; ?> </td>
|
||||
<td width="60%"><?php echo $userData["lastname"]; ?> </td>
|
||||
</tr>
|
||||
|
||||
<tr bgcolor="<?php echo $phpgw_info["theme"]["row_off"]; ?>">
|
||||
@ -79,7 +85,7 @@
|
||||
|
||||
echo "<tr bgcolor=\"" . $phpgw_info["theme"]["row_on"] . "\"><td>"
|
||||
. lang("account active") . "</td> <td>";
|
||||
if ($phpgw->db->f("account_status") == "A")
|
||||
if ($userData["status"] == "A")
|
||||
echo lang("yes");
|
||||
else
|
||||
echo "<b>" . lang("no") . "</b>";
|
||||
@ -88,8 +94,7 @@
|
||||
<tr bgcolor="<?php echo $phpgw_info["theme"]["row_off"]; ?>">
|
||||
<td>Groups: </td>
|
||||
<td><?php
|
||||
$user_groups = $phpgw->accounts->read_group_names($phpgw->db->f("account_lid"));
|
||||
|
||||
$user_groups = $phpgw->accounts->read_group_names($userData["account_lid"]);
|
||||
for ($i=0;$i<count($user_groups); $i++) {
|
||||
echo $user_groups[$i][1];
|
||||
if (count($user_groups) !=0 && $i != count($user_groups)-1)
|
||||
@ -100,15 +105,15 @@
|
||||
<tr bgcolor="<?php echo $phpgw_info["theme"]["row_on"]; ?>">
|
||||
<td>Last login</td><td> <?php
|
||||
|
||||
if (! $account_lastlogin)
|
||||
if (! $userData["lastlogin"])
|
||||
echo "Never";
|
||||
else
|
||||
echo $phpgw->common->show_date($account_lastlogin);
|
||||
echo $phpgw->common->show_date($userData["lastlogin"]);
|
||||
|
||||
?></td></tr>
|
||||
<tr bgcolor="<?php echo $phpgw_info["theme"]["row_off"]; ?>">
|
||||
<td>Last login from</td>
|
||||
<td><?php echo $account_lastloginfrom; ?> </td>
|
||||
<td><?php echo $userData["lastloginfrom"]; ?> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
@ -83,7 +83,7 @@
|
||||
|
||||
$entry["userpassword"] = $phpgw->common->encrypt_password($n_passwd);
|
||||
|
||||
$dn = sprintf("uid=%s, %s", $phpgw_info["user"]["userid"],$phpgw_info["server"]["ldap_context"]);
|
||||
$dn = $phpgw_info["user"]["account_id"];;
|
||||
@ldap_modify($ldap, $dn, $entry);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user