added session support

...
This commit is contained in:
dechutes 2003-04-09 17:04:02 +00:00
parent e0d693ed2f
commit d4a879a987
1 changed files with 53 additions and 23 deletions

View File

@ -25,6 +25,10 @@ $Id$
include_once ('../config/config.php'); include_once ('../config/config.php');
include_once("ldap.php"); include_once("ldap.php");
// start session
session_save_path("../sess");
@session_start();
// class representing local user entry with attributes of ldap user entry // class representing local user entry with attributes of ldap user entry
include_once("userentry.php"); include_once("userentry.php");
@ -34,47 +38,73 @@ echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\" />
echo "<script src=\"./functions.js\" type=\"text/javascript\" language=\"javascript\"></script>"; echo "<script src=\"./functions.js\" type=\"text/javascript\" language=\"javascript\"></script>";
echo "</head>"; echo "</head>";
echo "<body bgcolor=\"#F5F5F5\">"; echo "<body bgcolor=\"#F5F5F5\">";
// config object should be in session!!!
$config = new Config();
$ldap = new Ldap($config);
// username/password should also be in session!!! // generate attribute-description table
$username = "cn=admin,o=test,c=de"; $attr_array; // list of LDAP attributes to show
$passwd = "secret"; $desc_array; // list of descriptions for the attributes
$result = $ldap->connect ($username, $passwd); $attr_string = $_SESSION["config"]->get_userlistAttributes();
$temp_array = explode(";", $attr_string);
$hash_table = $_SESSION["ldap"]->attributeUserArray();
for ($i = 0; $i < sizeof($temp_array); $i++) {
// if value is predifined, look up description in hash_table
if (substr($temp_array[$i],0,1) == "#") {
$attr = substr($temp_array[$i],1);
$attr_array[$i] = $attr;
$desc_array[] = $hash_table[$attr];
}
// if not predefined, the attribute is seperated by a ":" from description
else {
$attr = explode(":", $temp_array[$i]);
$attr_array[$i] = $attr[0];
$desc_array[$i] = $attr[1];
}
}
$user_dn_list = $ldap->getUsers ($config->get_UserSuffix()); $user_dn_list = $_SESSION["ldap"]->getUsers
($_SESSION["config"]->get_UserSuffix());
echo ("<form action=\"../templates/account.php?type=user\" method=\"post\">\n");
echo "<table width=\"100%\">\n"; echo "<table width=\"100%\">\n";
// print attribute headers // print attribute headers
echo "<tr>"; echo "<tr>";
echo "<th class=\"userlist\"></th>"; echo "<th class=\"userlist\"></th>";
echo "<th class=\"userlist\">Vorname</th>"; for ($k = 0; $k < sizeof($desc_array); $k++) {
echo "<th class=\"userlist\">Nachname</th>"; echo "<th class=\"userlist\">" . $desc_array[$k] . "</th>";
echo "<th class=\"userlist\">Uid</th>"; }
echo "<th class=\"userlist\">Home Verzeichnis</th>";
echo "</tr>"; echo "</tr>";
$row_number = 0; $row_number = 0;
foreach ($user_dn_list as $user_dn) { foreach ($user_dn_list as $user_dn) {
echo "<tr onmouseover=\"setPointer(this, " . $row_number . ", 'over', '#DDDDDD', '#CCFFCC', '#FFCC99');\" onmouseout=\"setPointer(this, " . $row_number . ", 'out', '#DDDDDD', '#CCFFCC', '#FFCC99');\" onmousedown=\"setPointer(this, " . $row_number . ", 'click', '#DDDDDD', '#CCFFCC', '#FFCC99');\">\n"; echo "<tr onmouseover=\"setPointer(this, " . $row_number . ", 'over', '#DDDDDD', '#CCCCFF', '#FFCCCC');\" onmouseout=\"setPointer(this, " . $row_number . ", 'out', '#DDDDDD', '#CCCCFF', '#FFCCCC');\" onmousedown=\"setPointer(this, " . $row_number . ", 'click', '#DDDDDD', '#CCCCFF', '#FFCCCC');\">\n";
$row_number++; $row_number++;
$userentry = new UserEntry(); $userentry = new UserEntry();
$userentry = $ldap->getEntry ($user_dn, $userentry); $userentry = $_SESSION["ldap"]->getEntry ($user_dn, $userentry);
$ldap->getEntry ($user_dn, $userentry); // $ldap->getEntry ($user_dn, $userentry);
echo ("<td class=\"userlist\">" . "<input type=\"checkbox\" name=\"..\"" . "</td>"); echo ("<td bgcolor=\"#DDDDDD\" >" . "<input type=\"checkbox\" name=\"..\"" . "</td>");
echo ("<td class=\"userlist\">" . current ($userentry->getGivenName()) . "</td>"); echo ("<td bgcolor=\"#DDDDDD\" class=\"userlist\"><a href=\"../templates/account.php?type=edituser&uid=" . current ($userentry->getUid()) . "\">" . current ($userentry->getUid()) . "</a></td>");
echo ("<td class=\"userlist\">" . current ($userentry->getSn()) . "</td>"); echo ("<td bgcolor=\"#DDDDDD\" class=\"userlist\">" . current ($userentry->getCn()) . "</td>");
echo ("<td class=\"userlist\">" . current ($userentry->getUid()) . "</td>"); echo ("<td bgcolor=\"#DDDDDD\" class=\"userlist\">" . current ($userentry->getSn()) . "</td>");
echo ("<td class=\"userlist\">" . current ($userentry->gethomeDirectory()) . "</td>"); echo ("<td bgcolor=\"#DDDDDD\" class=\"userlist\">" . current ($userentry->gethomeDirectory()) . "</td>");
echo "</tr>\n"; echo "</tr>\n";
} }
echo "</table>"; echo "</table>";
echo ("<br />");
echo ("<table cellspacing=\"4\" align=\"left\" border=\"0\">");
echo ("<tr><td>");
echo ("<input type=\"button\" name=\"deluser\" value=\"" . _("Delete selected Users") . "\" onClick=\"self.location.href='../templates/account.php?type=delete'\"></td>\n");
echo ("<td>");
echo ("<input type=\"button\" name=\"newuser\" value=\"" . _("New User") . "\" onClick=\"self.location.href='../templates/account.php?type=user'\">");
echo ("</td></tr>");
echo ("</table>\n");
echo ("</form>\n");
echo "</body>"; echo "</body>";
echo "</html>";
$ldap->close();
?> ?>