mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
Cleaning up LDAP support
This commit is contained in:
parent
41f184664e
commit
471f42b67a
@ -22,15 +22,16 @@
|
||||
|
||||
$phpgw->template->set_block("header","row","footer");
|
||||
|
||||
$phpgw->templateotal = account_total();
|
||||
$total = account_total();
|
||||
|
||||
$phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_color"]);
|
||||
$phpgw->template->set_var("th_bg",$phpgw_info["theme"]["th_bg"]);
|
||||
|
||||
$phpgw->template->set_var("left_next_matchs",$phpgw->nextmatchs->left("accounts.php",$start,$phpgw->templateotal));
|
||||
$phpgw->template->set_var("left_next_matchs",$phpgw->nextmatchs->left("accounts.php",$start,$total));
|
||||
$phpgw->template->set_var("lang_user_accounts",lang("user accounts"));
|
||||
$phpgw->template->set_var("right_next_matchs",$phpgw->nextmatchs->right("accounts.php",$start,$phpgw->templateotal));
|
||||
$phpgw->template->set_var("right_next_matchs",$phpgw->nextmatchs->right("accounts.php",$start,$total));
|
||||
|
||||
$phpgw->template->set_var("lang_loginid",$phpgw->nextmatchs->show_sort_order($sort,"account_lid",$order,"accounts.php",lang("LoginID")));
|
||||
$phpgw->template->set_var("lang_lastname",$phpgw->nextmatchs->show_sort_order($sort,"account_lastname",$order,"accounts.php",lang("last name")));
|
||||
$phpgw->template->set_var("lang_firstname",$phpgw->nextmatchs->show_sort_order($sort,"account_firstname",$order,"accounts.php",lang("first name")));
|
||||
|
||||
@ -63,6 +64,7 @@
|
||||
if (! $lastname) $lastname = ' ';
|
||||
if (! $firstname) $firstname = ' ';
|
||||
|
||||
$phpgw->template->set_var("row_loginid",$loginid);
|
||||
$phpgw->template->set_var("row_firstname",$firstname);
|
||||
$phpgw->template->set_var("row_lastname",$lastname);
|
||||
$phpgw->template->set_var("row_edit",'<a href="'.$phpgw->link("editaccount.php","account_id="
|
||||
@ -78,10 +80,10 @@
|
||||
$phpgw->template->set_var("row_view",'<a href="' . $phpgw->link("viewaccount.php", "account_id="
|
||||
. $account_id) . '"> ' . lang("View") . ' </a>');
|
||||
|
||||
if ($phpgw->templateotal == 1) {
|
||||
if ($total == 1) {
|
||||
$phpgw->template->set_var("output","");
|
||||
}
|
||||
if ($phpgw->templateotal != ++$i) {
|
||||
if ($total != ++$i) {
|
||||
$phpgw->template->parse("output","row",True);
|
||||
}
|
||||
}
|
||||
|
@ -41,13 +41,17 @@
|
||||
$sr = ldap_search($ldap,$phpgw_info["server"]["ldap_context"],$filter,array("uid"));
|
||||
$info = ldap_get_entries($ldap, $sr);
|
||||
|
||||
$total = 0;
|
||||
$total = -1;
|
||||
for ($i=0;$i<count($info);$i++) {
|
||||
if (! $phpgw_info["server"]["global_denied_users"][$info[$i]["uid"][0]]) {
|
||||
$total++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($total == 1) {
|
||||
$total = 2;
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
@ -110,80 +114,77 @@
|
||||
function account_add($account_info)
|
||||
{
|
||||
global $phpgw_info, $phpgw, $ldap;
|
||||
|
||||
|
||||
$account_info["passwd"] = $phpgw->common->encrypt_password($account_info["passwd"]);
|
||||
|
||||
// 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["userpassword"] = $account_info["passwd"];
|
||||
$entry["loginShell"] = "/bin/bash";
|
||||
$entry["homeDirectory"] = "/home/" . $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["company"] = $company;
|
||||
//$entry["title"] = $title;
|
||||
$entry["mail"] = $account_info["loginid"] . "@" . $phpgw_info["server"]["mail_suffix"];
|
||||
$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"];
|
||||
$entry["cn"] = sprintf("%s %s", $account_info["firstname"], $account_info["lastname"]);
|
||||
$entry["sn"] = $account_info["lastname"];
|
||||
$entry["givenname"] = $account_info["firstname"];
|
||||
//$entry["company"] = $company;
|
||||
//$entry["title"] = $title;
|
||||
$entry["mail"] = $account_info["loginid"] . "@" . $phpgw_info["server"]["mail_suffix"];
|
||||
//$entry["telephonenumber"] = $telephonenumber;
|
||||
//$entry["homephone"] = $homephone;
|
||||
//$entry["pagerphone"] = $pagerphone;
|
||||
//$entry["cellphone"] = $cellphone;
|
||||
//$entry["streetaddress"] = $streetaddress;
|
||||
//$entry["locality"] = $locality;
|
||||
//$entry["st"] = $st;
|
||||
//$entry["postalcode"] = $postalcode;
|
||||
//$entry["countryname"] = $countryname;
|
||||
//$entry["homeurl"] = $homeurl;
|
||||
//$entry["description"] = $description;
|
||||
//$entry["homephone"] = $homephone;
|
||||
//$entry["pagerphone"] = $pagerphone;
|
||||
//$entry["cellphone"] = $cellphone;
|
||||
//$entry["streetaddress"] = $streetaddress;
|
||||
//$entry["locality"] = $locality;
|
||||
//$entry["st"] = $st;
|
||||
//$entry["postalcode"] = $postalcode;
|
||||
//$entry["countryname"] = $countryname;
|
||||
//$entry["homeurl"] = $homeurl;
|
||||
//$entry["description"] = $description;
|
||||
$entry["objectclass"][0] = "account";
|
||||
$entry["objectclass"][1] = "posixAccount";
|
||||
$entry["objectclass"][2] = "shadowAccount";
|
||||
$entry["objectclass"][3] = "inetOrgperson";
|
||||
$entry["objectclass"][4] = "person";
|
||||
$entry["objectclass"][5] = "top";
|
||||
|
||||
$i=0;
|
||||
reset ($account_info["permissions"]);
|
||||
while (list($key,$value) = each($account_info["permissions"]))
|
||||
{
|
||||
$entry["phpgw_account_perms"][$i] = $key;
|
||||
$i++;
|
||||
}
|
||||
/* $dn=sprintf("cn=%s %s, %s", $givenname, $sn, $BASEDN);*/
|
||||
$dn=sprintf("uid=%s, %s", $account_info["loginid"], $phpgw_info["server"]["ldap_context"]);
|
||||
|
||||
// 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;
|
||||
} else {
|
||||
$cd = 99; // Come out with a code for this
|
||||
$cd = 99; // Come out with a code for this
|
||||
}
|
||||
|
||||
|
||||
@ldap_close($ldap);
|
||||
|
||||
add_default_preferences($account_info["account_id"]);
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
|
||||
$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();
|
||||
|
||||
$sep = $phpgw->common->filesystem_separator();
|
||||
|
||||
@ -197,7 +198,7 @@
|
||||
|
||||
return $cd;
|
||||
}
|
||||
|
||||
|
||||
function account_edit($account_info)
|
||||
{
|
||||
global $phpgw, $phpgw_info, $ldap;
|
||||
|
@ -22,7 +22,7 @@
|
||||
if ($order) {
|
||||
$ordermethod = "order by $order $sort";
|
||||
} else {
|
||||
$ordermethod = "order by account_lastname,account_firstname,account_lid asc";
|
||||
$ordermethod = "order by account_lid,account_lastname,account_firstname asc";
|
||||
}
|
||||
|
||||
if (! $sort) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<!-- BEGIN header -->
|
||||
<p>
|
||||
<table border="0" width="65%" align="center">
|
||||
<table border="0" width="70%" align="center">
|
||||
<tr bgcolor="{bg_color}">
|
||||
<td align="left">{left_next_matchs}</td>
|
||||
<td align="center">{lang_user_accounts}</td>
|
||||
@ -9,8 +9,9 @@
|
||||
</table>
|
||||
|
||||
<center>
|
||||
<table border=0 width=65%>
|
||||
<table border="0" width="70%">
|
||||
<tr bgcolor="{th_bg}">
|
||||
<td>{lang_loginid}</td>
|
||||
<td>{lang_lastname}</td>
|
||||
<td>{lang_firstname}</td>
|
||||
<td>{lang_edit}</td>
|
||||
@ -23,6 +24,7 @@
|
||||
|
||||
<!-- BEGIN row -->
|
||||
<tr bgcolor="{tr_color}">
|
||||
<td>{row_loginid}</td>
|
||||
<td>{row_lastname}</td>
|
||||
<td>{row_firstname}</td>
|
||||
<td width="5%">{row_edit}</td>
|
||||
@ -36,9 +38,9 @@
|
||||
</center>
|
||||
|
||||
<form method="POST" action="{actionurl}">
|
||||
<table border="0" width="65%" align="center">
|
||||
<table border="0" width="70%" align="center">
|
||||
<tr>
|
||||
<td align=left>
|
||||
<td align="left">
|
||||
<input type="submit" value="{lang_add}"></form>
|
||||
</td>
|
||||
<td align="right">
|
||||
|
@ -76,8 +76,8 @@
|
||||
<option value="Y.m.d"<?php echo $df["Y.m.d"]; ?>>y.m.d</option>
|
||||
|
||||
<option value="d/m/Y"<?php echo $df["d/m/Y"]; ?>>d/m/y</option>
|
||||
<option value="d-m-Y"<?php echo $df["d-m-Y"]; ?>>d-m-y</option>
|
||||
<option value="d.m.Y"<?php echo $df["d.m.Y"]; ?>>d.m.y</option>
|
||||
<option value="d-m-Y"<?php echo $df["d-m-Y"]; ?>>d-m-y</option>
|
||||
<option value="d.m.Y"<?php echo $df["d.m.Y"]; ?>>d.m.y</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@ -103,8 +103,9 @@
|
||||
while ($phpgw->db->next_record()) {
|
||||
echo "<option value=\"" . $phpgw->db->f("lang_id") . "\"";
|
||||
if ($phpgw_info["user"]["preferences"]["common"]["lang"]) {
|
||||
if ($phpgw->db->f("lang_id") == $phpgw_info["user"]["preferences"]["common"]["lang"]) {
|
||||
echo " selected"; }
|
||||
if ($phpgw->db->f("lang_id") == $phpgw_info["user"]["preferences"]["common"]["lang"]) {
|
||||
echo " selected";
|
||||
}
|
||||
} elseif ($phpgw->db->f("lang_id") == "EN") {
|
||||
echo " selected";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user