425 lines
17 KiB
PHP
Executable File
425 lines
17 KiB
PHP
Executable File
<?php
|
|
|
|
include("kurs/datenbankanbindung.php"); // fügt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php
|
|
|
|
|
|
// Grundlegende Abfolge bei LDAP ist verbinden, binden, suchen,
|
|
// interpretieren des Sucheergebnisses, Verbindung schließen
|
|
|
|
if (isset($_GET['action']))
|
|
$action = $_GET['action'];
|
|
else
|
|
$action = "";
|
|
|
|
switch($action){
|
|
default:
|
|
echo"
|
|
|
|
<html>
|
|
<head>
|
|
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
|
|
<link rel=\"stylesheet\" href=\"tmpl/standard/css/styles_pc.css\" type=\"text/css\">
|
|
<title>Suchen</title>
|
|
</head>
|
|
<body onload=\"if(document.login)document.login.suchstring.focus();return false;\">
|
|
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
|
|
<tr>
|
|
<td>
|
|
<div align=\"center\">
|
|
<table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
|
|
<tr>
|
|
<td width=\"1%\" background=\"tmpl/standard/images/box_e1.gif\">
|
|
<img height=\"40\" src=\"tmpl/standard/images/blank.gif\" width=\"22\">
|
|
</td>
|
|
<td width=\"95%\" background=\"tmpl/standard/images/box_top.gif\">
|
|
<img height=\"10\" src=\"tmpl/standard/images/blank.gif\" width=\"1\"><br>
|
|
<font class=\"hd\">LDAP Suche</font><br>
|
|
<font class=\"sh\">In der Benutzerverwaltung suchen</font>
|
|
<img height=\"5\" src=\"tmpl/standard/images/blank.gif\" width=\"1\">
|
|
</td>
|
|
<td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"tmpl/standard/images/box_top.gif\" valign=\"top\">
|
|
</td>
|
|
<td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"tmpl/standard/images/box_e2.gif\">
|
|
<img height=\"40\" src=\"tmpl/standard/images/blank.gif\" width=\"22\">
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td width=\"1%\" background=\"tmpl/standard/images/box_l.gif\">
|
|
<img height=\"1\" src=\"tmpl/standard/images/blank.gif\" width=\"95%\">
|
|
</td>
|
|
<td colspan=\"2\"><br>
|
|
<p></p>
|
|
<p></p>
|
|
<p></p>
|
|
<p></p>
|
|
<form action="; echo $_SERVER['PHP_SELF'] . "?action=suchen"; echo" method=\"POST\" name=\"login\">
|
|
<input type=\"hidden\" name=\"tparam\" value=\"945180225\">
|
|
<table cellspacing=\"1\" cellpadding=\"1\" width=\"100%\" border=\"0\">
|
|
<tr>
|
|
<td class=\"formdesc\" width=\"60%\">
|
|
Suchbegriff:
|
|
</td>
|
|
<td width=\"40%\">
|
|
<input type=\"text\" name=\"suchstring\" size=\"40\" tabindex=\"2\"><br>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class=\"formdesc\" width=\"60%\">
|
|
Suchpfad:
|
|
</td>
|
|
<td width=\"40%\">
|
|
<input type=\"radio\" name=\"suchpfad\" value=\"sn\" checked>Nachnamen<br>
|
|
<input type=\"radio\" name=\"suchpfad\" value=\"samaccountname\">UIDs
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class=\"formdesc\" width=\"60%\">
|
|
Domain:
|
|
</td>
|
|
<td width=\"40%\">
|
|
<select name='domain'>
|
|
<option value='hsnet'>HSNET (Professoren, Lehrbeauftragte, Angestellte)</option>
|
|
<option value='studnet'>STUDNET (Studierende)</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align=\"center\" colspan=\"2\">
|
|
<br>
|
|
<font size=\"1\">Es können auch nur Teile des Begriffs eingegeben werden: Begri*</font>
|
|
<p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center' colspan=\"2\">
|
|
<input title=\"Suchen\" type=\"image\" src=\"tmpl/standard/images/suchen.gif\" border=\"0\">
|
|
</td>
|
|
</tr>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<p><br>
|
|
</p>
|
|
</td>
|
|
<td width=\"1%\" background=\"tmpl/standard/images/box_r.gif\">
|
|
<img height=\"1\" src=\"tmpl/standard/images/blank.gif\" width=\"22\">
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"tmpl/standard/images/box_e3.gif\">
|
|
<img height=\"16\" src=\"tmpl/standard/images/blank.gif\" width=\"22\"></td>
|
|
<td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"tmpl/standard/images/box_bottom.gif\" colspan=\"2\">
|
|
<img height=\"16\" src=\"tmpl/standard/images/blank.gif\" width=\"8\"></td>
|
|
<td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"tmpl/standard/images/box_e4.gif\">
|
|
<img height=\"16\" src=\"tmpl/standard/images/blank.gif\" width=\"22\"> </td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
";
|
|
break;
|
|
case "suchen":
|
|
if($_POST['suchstring'] != "")
|
|
{
|
|
$suchstring=$_POST['suchstring'];
|
|
$suchpfad=$_POST['suchpfad'];
|
|
$domain=$_POST['domain'];
|
|
setcookie("suchpfad","$suchpfad");
|
|
setcookie("suchstring","$suchstring");
|
|
setcookie("domain","$domain");
|
|
}
|
|
|
|
if($suchstring == "")
|
|
{
|
|
$suchpfad=$_COOKIE["suchpfad"];
|
|
$suchstring=$_COOKIE["suchstring"];
|
|
}
|
|
|
|
|
|
$nummer = 0 + $_GET['nummer'];
|
|
|
|
if(empty($_GET['sort']))
|
|
{
|
|
$sort = "desc";
|
|
}else{
|
|
NULL;
|
|
}
|
|
|
|
|
|
if(isset($_GET['sort0']))
|
|
{
|
|
if($sort0 == "asc")
|
|
{
|
|
$sort = "desc";
|
|
} else {
|
|
$sort = "asc";
|
|
}
|
|
}
|
|
|
|
if(isset($_GET['sort1']))
|
|
{
|
|
if($sort1 == "asc")
|
|
{
|
|
$sort = "desc";
|
|
} else {
|
|
$sort = "asc";
|
|
}
|
|
}
|
|
|
|
if(isset($_GET['sort3']))
|
|
{
|
|
if($sort3 == "asc")
|
|
{
|
|
$sort = "desc";
|
|
} else {
|
|
$sort = "asc";
|
|
}
|
|
}
|
|
|
|
if(isset($_GET['sort4']))
|
|
{
|
|
if($sort4 == "asc")
|
|
{
|
|
$sort = "desc";
|
|
} else {
|
|
$sort = "asc";
|
|
}
|
|
}
|
|
|
|
if(isset($_GET['sort5']))
|
|
{
|
|
if($sort5 == "asc")
|
|
{
|
|
$sort = "desc";
|
|
} else {
|
|
$sort = "asc";
|
|
}
|
|
}
|
|
|
|
$_ad_username="LDAPqueryUser";
|
|
$_ad_password="ldHS332";
|
|
|
|
if($domain == "hsnet"){
|
|
$_ldap_dn = "ou=OUHochschulnetzwerk,dc=hsnet,dc=hs-ludwigsburg,dc=de";
|
|
$ds=@ldap_connect("141.10.128.30", "389"); // muss ein gültiger LDAP Server Port 389->3268
|
|
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
|
|
}
|
|
|
|
if($domain == "studnet"){
|
|
$_ldap_dn = "ou=ouStudnet,dc=studnet,dc=hs-ludwigsburg,dc=de";
|
|
$ds=@ldap_connect("141.10.144.37", "389"); // muss ein gültiger LDAP Server Port 389->3268
|
|
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
|
|
}
|
|
|
|
|
|
if ($ds) {
|
|
|
|
$r=ldap_bind($ds, $_ad_username, $_ad_password);
|
|
|
|
|
|
// Suchen des Nachnamen-Eintrags
|
|
#$suchstring2=$suchstring;
|
|
#$sr=ldap_search($ds,"o=fhov", "cn=$suchstring");
|
|
$sr=ldap_search($ds, $_ldap_dn, "$suchpfad=$suchstring");
|
|
|
|
|
|
|
|
$anzahl = ldap_count_entries($ds,$sr);
|
|
|
|
$info = ldap_get_entries($ds, $sr);
|
|
|
|
|
|
|
|
// Funktion mit der Sortierung
|
|
function multi_sort($input, $key, $type) {
|
|
if(is_array($input) && is_numeric($key)) {
|
|
$tmp_arr = array();
|
|
$output = array();
|
|
foreach($input as $i_key => $i_value) {
|
|
$tmp_arr[$i_key] = $i_value[$key];
|
|
}
|
|
natcasesort($tmp_arr);
|
|
reset($tmp_arr);
|
|
foreach($tmp_arr as $tmp_key => $tmp_val) {
|
|
$output[] = $input[$tmp_key];
|
|
}
|
|
if(strtolower($type) != "asc") return $output;
|
|
else return array_reverse($output);
|
|
}
|
|
}
|
|
|
|
for ($i=0; $i<$info["count"]; $i++) {
|
|
|
|
//$dn enthält dn-string ==> 'cn=test,ou=extern,o=fhov': Nachfolgende Zeilen nur ou extrahieren
|
|
$dn = $info[$i]['dn'];
|
|
$b = strpos ($dn, "ou=")+3; // Position bestimmen wo ou anfängt, +3 damit "ou=" nicht mitangezeigt wird, also Positon um 3 nach recht verschoben wird
|
|
$c = strpos ($dn, ",o="); // Position bestimmen woe ,o= anfängt
|
|
$d = $c-$b; // beide Werte subrahieren, dann erhält man die Länge von ou
|
|
$dn = substr($dn, $b, $d);
|
|
|
|
|
|
|
|
$old_arr[$i][0] = $info[$i]['cn'][0];
|
|
$old_arr[$i][1] = $info[$i]['sn'][0];
|
|
$old_arr[$i][2] = $info[$i]['givenname'][0];
|
|
$old_arr[$i][3] = $dn;
|
|
|
|
if ($dn == 'DOZ') // bei den DOZ steht oft sowas wie "Prof." in dem Feld AG --> AG ausblenden
|
|
{
|
|
$old_arr[$i][4] = '';
|
|
}else{
|
|
$old_arr[$i][4] = $info[$i]['generationqualifier'][0];
|
|
};
|
|
|
|
$old_arr[$i][5] = $info[$i]['mail'][0];
|
|
}
|
|
|
|
$new_arr = multi_sort($old_arr, $nummer, "$sort");
|
|
|
|
|
|
echo"
|
|
<html>
|
|
|
|
<head>
|
|
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
|
|
<link rel=\"stylesheet\" href=\"tmpl/standard/css/styles_pc.css\" type=\"text/css\">
|
|
<title>Suchergebnisse</title>
|
|
</head>
|
|
|
|
<body>
|
|
<table valign=\"top\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" border=\"0\">
|
|
<tr>
|
|
<td width=\"10\" background=\"tmpl/standard/images/box_e1.gif\">
|
|
<img height=\"40\" src=\"tmpl/standard/images/blank.gif\" width=\"22\"></td>
|
|
<td align=\"left\" width=\"98%\" background=\"tmpl/standard/images/box_top.gif\" valign=\"top\">
|
|
<img height=\"10\" src=\"tmpl/standard/images/blank.gif\" width=\"1\"><br>
|
|
<font class=\"hd\">Suchergebnisse zu Begriff $suchstring</font><br>";
|
|
if ($anzahl == 1){$einheit="Suchergebnis";}else{$einheit="Suchergebnisse";}
|
|
echo"
|
|
<font class=\"sh\">$anzahl $einheit</font><br>
|
|
<img height=\"5\" src=\"tmpl/standard/images/blank.gif\" width=\"1\"></td>
|
|
<td align=\"right\" width=\"1%\" background=\"tmpl/standard/images/box_e2.gif\">
|
|
<img height=\"40\" src=\"tmpl/standard/images/blank.gif\" width=\"22\"></td>
|
|
</tr>
|
|
<tr>
|
|
<td width=\"1%\" background=\"tmpl/standard/images/box_l.gif\">
|
|
<img height=\"1\" src=\"tmpl/standard/images/blank.gif\" width=\"22\"></td>
|
|
<td>
|
|
<table valign=\"top\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#E7E8ED\" width=\"100%\" id=\"AutoNumber1\">
|
|
<tr>
|
|
<td width=\"15%\">
|
|
<b><a href=".$_SERVER['PHP_SELF'] ."?nummer=0&action=suchen&sort0=$sort>UID</a></b>
|
|
</td>
|
|
<td width=\"20%\">
|
|
<b><a href=".$_SERVER['PHP_SELF'] ."?nummer=1&action=suchen&sort1=$sort>Name</a></b>
|
|
</td>
|
|
<td width=\"15%\">
|
|
<b><a href=".$_SERVER['PHP_SELF'] ."?nummer=3&action=suchen&sort3=$sort>Gruppe</a></b>
|
|
</td>
|
|
<td width=\"15%\">
|
|
<b><a href=".$_SERVER['PHP_SELF'] ."?nummer=4&action=suchen&sort4=$sort>AG</a></b>
|
|
</td>
|
|
<td width=\"35%\">
|
|
<b><a href=".$_SERVER['PHP_SELF'] ."?nummer=5&action=suchen&sort5=$sort>Mail</a></b>
|
|
</td>
|
|
</tr>";
|
|
|
|
for ($i=0; $i<$info["count"]; $i++) {
|
|
/*
|
|
echo "01 ".$info[$i]['samaccountname'][0]."<br>";
|
|
echo "02 ".$info[$i]['givenname'][0]."<br>";
|
|
echo "03 ".$info[$i]['mail'][0]."<br>";
|
|
echo "04 ".$info[$i]['language'][0]."<br>";
|
|
echo "05 ".$info[$i]['allowunlimitedcredit'][0]."<br>";
|
|
echo "06 ".$info[$i]['accountbalance'][0]."<br>";
|
|
echo "07 ".$info[$i]['groupmembership'][0]."<br>";
|
|
echo "08 ".$info[$i]['groupmembership'][1]."<br>";
|
|
echo "08a".$info[$i]['groupmembership'][2]."<br>";
|
|
echo "08b".$info[$i]['groupmembership'][3]."<br>";
|
|
echo "09 ".$info[$i]['sn'][0]."<br>";
|
|
echo "10 ".$info[$i]['securityequals'][0]."<br>";
|
|
echo "11 ".$info[$i]['profile'][0]."<br>";
|
|
echo "12 ".$info[$i]['passwordrequired'][0]."<br>";
|
|
echo "13 ".$info[$i]['passwordminimumlength'][0]."<br>";
|
|
echo "14 ".$info[$i]['passwordexpirationtime'][0]."<br>";
|
|
echo "15 ".$info[$i]['passwordexpirationinterval'][0]."<br>";
|
|
echo "16 ".$info[$i]['passwordallowchange'][0]."<br>";
|
|
echo "17 ".$info[$i]['objectclass'][0]."<br>";
|
|
echo "18 ".$info[$i]['logintime'][0]."<br>";
|
|
echo "19 ".$info[$i]['loginintruderaddress'][0]."<br>";
|
|
echo "20 ".$info[$i]['loginexpirationtime'][0]."<br>";
|
|
echo "21 ".$info[$i]['ndshomedirectory'][0]."<br>";
|
|
echo "22 ".$info[$i]['cn'][0]."<br>";
|
|
echo "23 ".$info[$i]['acl'][0]."<br>";
|
|
echo "24 ".$info[$i][dn]."<br>";
|
|
echo "<p>";
|
|
echo "<p>";
|
|
*/
|
|
|
|
|
|
$uid = $info[$i]['samaccountname'][0];
|
|
$vorname = $info[$i]['givenname'][0];
|
|
$nachname = $info[$i]['sn'][0];
|
|
$dn = $info[$i][dn];
|
|
$ag = $new_arr[$i][4];
|
|
$mail = $info[$i]['mail'][0];
|
|
|
|
|
|
echo"
|
|
<tr>
|
|
<td width=\"15%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
|
|
$uid
|
|
</td>
|
|
<td width=\"20%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
|
|
$vorname $nachname
|
|
</td>
|
|
<td valign=\"middle\" width=\"15%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
|
|
$dn
|
|
</td>
|
|
<td valign=\"middle\" width=\"15%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
|
|
$ag
|
|
</td>
|
|
<td width=\"35%\" style=\"border-left-style: none; border-left-width: medium; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: solid; border-bottom-width: 1px\">
|
|
$mail
|
|
</td>
|
|
</td>
|
|
</tr>";
|
|
$uid = "";
|
|
$sn = "";
|
|
$givenname = "";
|
|
$dn = "";
|
|
$mail = "";
|
|
$ag = "";
|
|
}
|
|
echo"
|
|
</table>
|
|
</td>
|
|
<td width=\"1%\" background=\"tmpl/standard/images/box_r.gif\">
|
|
<img height=\"1\" src=\"tmpl/standard/images/blank.gif\" width=\"22\"></td>
|
|
</tr>
|
|
<tr>
|
|
<td align=\"left\" width=\"1%\" background=\"tmpl/standard/images/box_e3.gif\">
|
|
<img height=\"16\" src=\"tmpl/standard/images/blank.gif\" width=\"22\"></td>
|
|
<td align=\"left\" width=\"98%\" background=\"tmpl/standard/images/box_bottom.gif\">
|
|
<img height=\"16\" src=\"tmpl/standard/images/blank.gif\" width=\"8\"></td>
|
|
<td align=\"right\" width=\"1%\" background=\"tmpl/standard/images/box_e4.gif\">
|
|
<img height=\"16\" src=\"tmpl/standard/images/blank.gif\" width=\"22\"> </td>
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>";
|
|
|
|
|
|
ldap_close($ds);
|
|
|
|
} else {
|
|
echo "<h4>Verbindung zum LDAP Server nicht möglich</h4>";
|
|
}
|
|
|
|
} //ENDE SWITCH CASE
|
|
?>
|