mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 09:52:22 +00:00
Auhtentifizierung gegen 2 LDAP Server ermöglicht
This commit is contained in:
@@ -212,7 +212,7 @@ function change_password($passwort_alt, $passwort_neu, $uid)
|
||||
$ldap = new ldap();
|
||||
|
||||
// Bind des User mit alten Passwort
|
||||
if($ldap->connect('starttls', LDAP_SERVER_MASTER, $user_dn, $passwort_alt))
|
||||
if($ldap->connect(LDAP_SERVER_MASTER,LDAP_PORT,$user_dn, $passwort_alt, LDAP_STARTTLS))
|
||||
{
|
||||
// Passwort verschlüsseln
|
||||
//SSHA
|
||||
|
||||
@@ -16,6 +16,7 @@ require_once('../../../include/functions.inc.php');
|
||||
require_once('../../../include/File/SearchReplace.php');
|
||||
require_once('../../../include/File/Match.php');
|
||||
require_once('../../../include/phrasen.class.php');
|
||||
require_once('../../../include/authentication.class.php');
|
||||
|
||||
$sprache = getSprache();
|
||||
$p=new phrasen($sprache);
|
||||
@@ -79,18 +80,12 @@ function ip_increment($ip = "")
|
||||
}
|
||||
else if ($txtUID && $txtPassword)
|
||||
{
|
||||
//$ldap_conn = @ConnectLDAP("pdc1.technikum-wien.at") or die("Der LDAP-Server ist nicht erreichbar.");
|
||||
$ldap_conn = ldap_connect(LDAP_SERVER) or die($p->t("global/LDAPserverNichtErreichbar"));
|
||||
$user_dn = "uid=$txtUID, ou=People, dc=technikum-wien, dc=at";
|
||||
|
||||
if(!@ldap_bind($ldap_conn, $user_dn, $txtPassword) === true)
|
||||
{
|
||||
$error = 2;
|
||||
}
|
||||
// Passwort pruefen
|
||||
$auth = new authentication();
|
||||
if($auth->checkpassword($txtUID, $txtPassword))
|
||||
$error=0;
|
||||
else
|
||||
{
|
||||
$error = 0;
|
||||
}
|
||||
$error=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -102,7 +97,8 @@ function ip_increment($ip = "")
|
||||
{
|
||||
if(isset($txtMAC) && $txtMAC != "")
|
||||
{
|
||||
$sql_query = "SELECT DISTINCT vorname, nachname FROM campus.vw_benutzer WHERE uid='".addslashes($txtUID)."' LIMIT 1";
|
||||
$sql_query = "SELECT DISTINCT vorname, nachname
|
||||
FROM campus.vw_benutzer WHERE uid=".$db->db_add_param($txtUID)." LIMIT 1";
|
||||
|
||||
if($result = $db->db_query($sql_query))
|
||||
{
|
||||
@@ -237,14 +233,14 @@ function ip_increment($ip = "")
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
//echo "error:".$error;
|
||||
|
||||
if ($error == 1)
|
||||
echo '<h3>'.$p->t("notebookregister/passwortEingebenWennUIDgeaendert").'.</h3>';
|
||||
else if ($error == 2)
|
||||
echo '<h3>'.$p->t("notebookregister/passwortErneutEingeben").'.</h3>';
|
||||
else if ($error == 3)
|
||||
echo '<h3>'.$p->t("notebookregister/MACadresseBereitsVerwendet").'.</h3>';
|
||||
//echo "result:".$mac_result;
|
||||
|
||||
if(isset($mac_result) && $mac_result!='')
|
||||
{
|
||||
if($mac_result == 0)
|
||||
@@ -267,16 +263,6 @@ function ip_increment($ip = "")
|
||||
?>
|
||||
<p><?php echo $p->t("notebookregister/notebook_absatz2");?></p>
|
||||
</td>
|
||||
<!--<td class="menubox">
|
||||
<p><a href="content.php?content_id=">Links zu Unterpunkten</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="teambox" style="width: 20%;">TEAM:<br /><br /><a href="mailto:">Titelpre Vorname Nachname Titelpost</a><br />Aufgaben, Verantwortlichkeiten, Expertisen<br />T: +43 1 333 40 77-DW<br />E: <a href="mailto:">aliasadresse@technikum-wien.at</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 20%;" valign="top"> </td>
|
||||
</tr>-->
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -68,20 +68,41 @@ define('URLAUB_TOOLS',true);
|
||||
// auth_session - Sessions mit LDAP (Testbetrieb)
|
||||
define("AUTH_SYSTEM", "auth_mixed");
|
||||
// Gibt den Namen fuer die htaccess Authentifizierung an (muss mit dem Attribut AuthName im htaccess uebereinstimmen)
|
||||
define("AUTH_NAME","Technikum-Wien");
|
||||
define("AUTH_NAME","FHComplete");
|
||||
|
||||
// LDAP_SERVER: Adresse des LDAP Servers
|
||||
define("LDAP_SERVER","www.technikum-wien.at");
|
||||
// LDAP Master Server fuer Passwort Aenderungen
|
||||
/*
|
||||
* LDAP Einstellungen
|
||||
*
|
||||
* LDAP_SERVER: LDAP Server URL inkl. ldap:// bzw ldaps://
|
||||
* LDAP_PORT: LDAP Port (389 | 636)
|
||||
* LDAP_STARTTLS: Starttls für Verschlüsselung starten (true | false)
|
||||
* LDAP_BASE_DN: Basis DN der User (ou=People,dc=example,dc=com)
|
||||
* LDAP_BIND_USER: DN des Users falls eine Authentifizierung am LDAP noetig ist oder null
|
||||
* LDAP_BIND_PASSWORD: Passwort des Users falls eine Authentifizierung am LDAP noetig ist oder null
|
||||
* LDAP_USER_SEARCH_FILTER: LDAP Attribut in dem der Username steht nach dem gesucht wird (uid | sAMAccountName)
|
||||
*/
|
||||
define('LDAP_SERVER','ldap://ldap.example.com');
|
||||
define('LDAP_PORT',389);
|
||||
define('LDAP_STARTTLS',true);
|
||||
define('LDAP_BASE_DN','ou=People,dc=example,dc=com');
|
||||
define('LDAP_BIND_USER',null);
|
||||
define('LDAP_BIND_PASSWORD',null);
|
||||
define('LDAP_USER_SEARCH_FILTER','uid');
|
||||
|
||||
// 2. LDAP Server (zB wenn Mitarbeiter und Studierende auf 2 getrennten Servern liegen)
|
||||
/*
|
||||
define('LDAP2_SERVER','ldaps://dc1.example.com');
|
||||
define('LDAP2_PORT',636);
|
||||
define('LDAP2_STARTTLS',false);
|
||||
define('LDAP2_BASE_DN','ou=Mitarbeiter,dc=example,dc=com');
|
||||
define('LDAP2_BIND_USER','cn=fhcomplete,dc=example,dc=com');
|
||||
define('LDAP2_BIND_PASSWORD','Pa55w0rd');
|
||||
define('LDAP2_USER_SEARCH_FILTER','sAMAccountName');
|
||||
*/
|
||||
|
||||
// LDAP MASTER SERVER fuer Passwort Aenderungen
|
||||
define('LDAP_SERVER_MASTER',LDAP_SERVER);
|
||||
// LDAP BASIS DN fuer User
|
||||
define("LDAP_BASE_DN","ou=People, dc=technikum-wien, dc=at");
|
||||
//User fuer LDAP BIND falls Authentifizierung noetig
|
||||
define("LDAP_BIND_USER",null);
|
||||
//Passwort fuer LDAP BIND falls Authentifzierung noetig
|
||||
define("LDAP_BIND_PASSWORD",null);
|
||||
//LDAP Attribut in dem der Username steht nach dem gesucht wird
|
||||
define("LDAP_USER_SEARCH_FILTER","uid");
|
||||
|
||||
// Attribut fuer Zutrittskartennummer im LDAP
|
||||
define("LDAP_CARD_NUMBER","twHitagCardNumber");
|
||||
// Attribut fuer Zutrittskartennummer2 im LDAP
|
||||
|
||||
@@ -41,17 +41,37 @@ define('DOMAIN','technikum-wien.at');
|
||||
// auth_session - Sessions mit LDAP (Testbetrieb)
|
||||
define("AUTH_SYSTEM", "auth_mixed");
|
||||
// Gibt den Namen fuer die htaccess Authentifizierung an (muss mit dem Attribut AuthName im htaccess uebereinstimmen)
|
||||
define("AUTH_NAME","Technikum-Wien");
|
||||
define("AUTH_NAME","FHComplete");
|
||||
|
||||
//LDAP_SERVER: Speichert die Adresse des LDAP Servers
|
||||
define("LDAP_SERVER","ldap.technikum-wien.at");
|
||||
define("LDAP_BASE_DN","ou=People, dc=technikum-wien, dc=at");
|
||||
//User fuer LDAP BIND falls Authentifizierung noetig
|
||||
define("LDAP_BIND_USER",null);
|
||||
//Passwort fuer LDAP BIND falls Authentifzierung noetig
|
||||
define("LDAP_BIND_PASSWORD",null);
|
||||
//LDAP Attribut in dem der Username steht nach dem gesucht wird
|
||||
define("LDAP_USER_SEARCH_FILTER","uid");
|
||||
/*
|
||||
* LDAP Einstellungen
|
||||
*
|
||||
* LDAP_SERVER: LDAP Server URL inkl. ldap:// bzw ldaps://
|
||||
* LDAP_PORT: LDAP Port (389 | 636)
|
||||
* LDAP_STARTTLS: Starttls für Verschlüsselung starten (true | false)
|
||||
* LDAP_BASE_DN: Basis DN der User (ou=People,dc=example,dc=com)
|
||||
* LDAP_BIND_USER: DN des Users falls eine Authentifizierung am LDAP noetig ist oder null
|
||||
* LDAP_BIND_PASSWORD: Passwort des Users falls eine Authentifizierung am LDAP noetig ist oder null
|
||||
* LDAP_USER_SEARCH_FILTER: LDAP Attribut in dem der Username steht nach dem gesucht wird (uid | sAMAccountName)
|
||||
*/
|
||||
define('LDAP_SERVER','ldap://ldap.example.com');
|
||||
define('LDAP_PORT',389);
|
||||
define('LDAP_STARTTLS',true);
|
||||
define('LDAP_BASE_DN','ou=People,dc=example,dc=com');
|
||||
define('LDAP_BIND_USER',null);
|
||||
define('LDAP_BIND_PASSWORD',null);
|
||||
define('LDAP_USER_SEARCH_FILTER','uid');
|
||||
|
||||
// 2. LDAP Server (zB wenn Mitarbeiter und Studierende auf 2 getrennten Servern liegen)
|
||||
/*
|
||||
define('LDAP2_SERVER','ldaps://dc1.example.com');
|
||||
define('LDAP2_PORT',636);
|
||||
define('LDAP2_STARTTLS',false);
|
||||
define('LDAP2_BASE_DN','ou=Mitarbeiter,dc=example,dc=com');
|
||||
define('LDAP2_BIND_USER','cn=fhcomplete,dc=example,dc=com');
|
||||
define('LDAP2_BIND_PASSWORD','Pa55w0rd');
|
||||
define('LDAP2_USER_SEARCH_FILTER','sAMAccountName');
|
||||
*/
|
||||
|
||||
// Attribut fuer Zutrittskartennummer im LDAP
|
||||
define("LDAP_CARD_NUMBER","twHitagCardNumber");
|
||||
|
||||
@@ -68,6 +68,16 @@ class authentication extends auth
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob der User extern (zB im LDAP) angelegt ist
|
||||
* @param $username UID des Users
|
||||
* @return boolean true wenn vorhanden, sonst false
|
||||
*/
|
||||
public function UserExternalExists($username)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// derzeit manual_basic_auth in functions.inc.php eventuell
|
||||
// direkt von getUser aus aufrufen wenn nicht authentifiziert
|
||||
public function RequireLogin()
|
||||
|
||||
@@ -23,10 +23,35 @@
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/basis.class.php');
|
||||
require_once(dirname(__FILE__).'/../addons/ldap/vilesci/ldap.class.php');
|
||||
|
||||
class authentication extends auth
|
||||
{
|
||||
public $ldap_config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ldap_config[]=array('LDAP_SERVER'=>LDAP_SERVER,
|
||||
'LDAP_PORT'=>LDAP_PORT,
|
||||
'LDAP_STARTTLS'=>LDAP_STARTTLS,
|
||||
'LDAP_BASE_DN'=>LDAP_BASE_DN,
|
||||
'LDAP_BIND_USER'=>LDAP_BIND_USER,
|
||||
'LDAP_BIND_PASSWORD'=>LDAP_BIND_PASSWORD,
|
||||
'LDAP_USER_SEARCH_FILTER'=>LDAP_USER_SEARCH_FILTER);
|
||||
|
||||
// Wenn ein zweiter LDAP Server angegeben wurde, diesen mitaufnehmen
|
||||
if(defined('LDAP2_SERVER'))
|
||||
{
|
||||
$this->ldap_config[]=array('LDAP_SERVER'=>LDAP2_SERVER,
|
||||
'LDAP_PORT'=>LDAP2_PORT,
|
||||
'LDAP_STARTTLS'=>LDAP2_STARTTLS,
|
||||
'LDAP_BASE_DN'=>LDAP2_BASE_DN,
|
||||
'LDAP_BIND_USER'=>LDAP2_BIND_USER,
|
||||
'LDAP_BIND_PASSWORD'=>LDAP2_BIND_PASSWORD,
|
||||
'LDAP_USER_SEARCH_FILTER'=>LDAP2_USER_SEARCH_FILTER);
|
||||
}
|
||||
}
|
||||
|
||||
public function login($username)
|
||||
{
|
||||
// Nicht noetig da dies ueber htaccess gesteuert wird
|
||||
@@ -48,62 +73,67 @@ class authentication extends auth
|
||||
}
|
||||
}
|
||||
|
||||
// derzeit checkldapuser in functions.inc.php bzw per htaccess
|
||||
/**
|
||||
* Prueft ob Username und Passwort stimmen
|
||||
* @param $username UID des Users
|
||||
* @param $passwort Passwort des Users
|
||||
* @return boolean true wenn Passwort ok, false wenn falsch
|
||||
*/
|
||||
public function checkpassword($username, $passwort)
|
||||
{
|
||||
if($connect=ldap_connect(LDAP_SERVER))
|
||||
// Alle vorhandenen LDAP Server nacheinander durchlaufen
|
||||
// bis einer passt.
|
||||
foreach($this->ldap_config as $ldap)
|
||||
{
|
||||
ldap_set_option($connect, LDAP_OPT_REFERRALS,0);
|
||||
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION,3);
|
||||
|
||||
// bind to ldap connection
|
||||
if(($bind=ldap_bind($connect, LDAP_BIND_USER, LDAP_BIND_PASSWORD)) == false)
|
||||
$ldap_obj = new ldap();
|
||||
// Verbindung zum Server
|
||||
if($ldap_obj->connect($ldap['LDAP_SERVER'],$ldap['LDAP_PORT'],$ldap['LDAP_BIND_USER'],$ldap['LDAP_BIND_PASSWORD'],$ldap['LDAP_STARTTLS']))
|
||||
{
|
||||
$this->errormsg="LDAP BIND Fehlgeschlagen";
|
||||
return false;
|
||||
}
|
||||
// DN des Users holen
|
||||
if($userdn = $ldap_obj->GetUserDN($username, $ldap['LDAP_BASE_DN'],$ldap['LDAP_USER_SEARCH_FILTER']))
|
||||
{
|
||||
// Verbindung trennen
|
||||
$ldap_obj->unbind();
|
||||
|
||||
// search for user
|
||||
if (($res_id = ldap_search( $connect, LDAP_BASE_DN, LDAP_USER_SEARCH_FILTER."=$username")) == false)
|
||||
{
|
||||
$this->errorsmg="Suche in LDAP fehlgeschlagen";
|
||||
return false;
|
||||
// Verbindung mit DN des Users und dessen Passwort herstellen
|
||||
if($ldap_obj->connect($ldap['LDAP_SERVER'],$ldap['LDAP_PORT'],$userdn,$passwort,$ldap['LDAP_STARTTLS']))
|
||||
{
|
||||
// Passwort und User OK
|
||||
$ldap_obj->unbind();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ldap_count_entries($connect, $res_id) != 1)
|
||||
{
|
||||
$this->errormsg='Username wurde nicht oder oefter gefunden';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (( $entry_id = ldap_first_entry($connect, $res_id))== false)
|
||||
{
|
||||
$this->errormsg='LDAP Fetch fehlgeschlagen';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (( $user_dn = ldap_get_dn($connect, $entry_id)) == false)
|
||||
{
|
||||
$this->errormsg='LDAP user-dn fetched fehlgeschlagen';
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Authentifizierung des User */
|
||||
if (($link_id = @ldap_bind($connect, $user_dn, $passwort)) == false)
|
||||
{
|
||||
$this->errormsg='LDAP Bind fehlgeschlagen: '.ldap_error($connect);
|
||||
return false;
|
||||
}
|
||||
|
||||
ldap_close($connect);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
// Kein Eintrag gefunden
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob der User im LDAP angelegt ist
|
||||
* @param $username UID des Users
|
||||
* @return boolean true wenn vorhanden, sonst false
|
||||
*/
|
||||
public function UserExternalExists($username)
|
||||
{
|
||||
// Alle vorhandenen LDAP Server nacheinander durchlaufen
|
||||
// bis einer passt.
|
||||
foreach($this->ldap_config as $ldap)
|
||||
{
|
||||
$this->errormsg='Verbindung zum LDAP Server fehlgeschlagen';
|
||||
$ldap_obj = new ldap();
|
||||
// Verbindung zum Server
|
||||
if($ldap_obj->connect($ldap['LDAP_SERVER'],$ldap['LDAP_PORT'],$ldap['LDAP_BIND_USER'],$ldap['LDAP_BIND_PASSWORD'],$ldap['LDAP_STARTTLS']))
|
||||
{
|
||||
// User suchen
|
||||
if($userdn = $ldap_obj->GetUserDN($username, $ldap['LDAP_BASE_DN'],$ldap['LDAP_USER_SEARCH_FILTER']))
|
||||
{
|
||||
$ldap_obj->unbind();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$ldap_obj->unbind();
|
||||
}
|
||||
ldap_close($connect);
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// derzeit manual_basic_auth in functions.inc.php eventuell
|
||||
|
||||
@@ -99,6 +99,33 @@ class authentication extends auth
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob der User im LDAP angelegt ist
|
||||
* @param $username UID des Users
|
||||
* @return boolean true wenn vorhanden, sonst false
|
||||
*/
|
||||
public function UserExternalExists($username)
|
||||
{
|
||||
// Alle vorhandenen LDAP Server nacheinander durchlaufen
|
||||
// bis einer passt.
|
||||
foreach($this->ldap_config as $ldap)
|
||||
{
|
||||
$ldap_obj = new ldap();
|
||||
// Verbindung zum Server
|
||||
if($ldap_obj->connect($ldap['LDAP_SERVER'],$ldap['LDAP_PORT'],$ldap['LDAP_BIND_USER'],$ldap['LDAP_BIND_PASSWORD'],$ldap['LDAP_STARTTLS']))
|
||||
{
|
||||
// User suchen
|
||||
if($userdn = $ldap_obj->GetUserDN($username, $ldap['LDAP_BASE_DN'],$ldap['LDAP_USER_SEARCH_FILTER']))
|
||||
{
|
||||
$ldap_obj->unbind();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$ldap_obj->unbind();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function RequireLogin()
|
||||
{
|
||||
$_SESSION['request_uri']=$_SERVER['REQUEST_URI'];
|
||||
|
||||
@@ -28,6 +28,7 @@ abstract class auth extends basis
|
||||
{
|
||||
abstract function getUser();
|
||||
abstract function checkpassword($username, $passwort);
|
||||
abstract function UserExternalExists($username);
|
||||
abstract function RequireLogin();
|
||||
abstract function isUserLoggedIn();
|
||||
abstract function getOriginalUser();
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Script zur Erstellung einer Statistik über die Häufigkeit der Passwortänderungen
|
||||
*
|
||||
* Prueft wie viele User gestern das Passwort geaendert haben
|
||||
* und schickt eine Liste mit den md5 Hashes per Mail
|
||||
*/
|
||||
require_once('../config/vilesci.config.inc.php');
|
||||
require_once('../include/mail.class.php');
|
||||
|
||||
if($connect=@ldap_connect(LDAP_SERVER))
|
||||
{
|
||||
// bind to ldap connection
|
||||
if(($bind=@ldap_bind($connect)) == false)
|
||||
{
|
||||
print "bind:__FAILED__<br>\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
$ts = mktime(0,0,0,date('m'),date('d')-1,date('Y'));
|
||||
// search for user
|
||||
if (($res_id = ldap_search( $connect, LDAP_BASE_DN, "uid=*")) == false)
|
||||
{
|
||||
print "failure: search in LDAP-tree failed<br>";
|
||||
return false;
|
||||
}
|
||||
|
||||
$entries = ldap_get_entries($connect, $res_id);
|
||||
$notset=0;
|
||||
$anzahl_geaendert=0;
|
||||
$message = "Dies ist ein automatisches Mail.\n\n";
|
||||
$message.= "Folgende Personen haben heute ihr Passwort geaendert:\n\n";
|
||||
|
||||
for ($i=0; $i < $entries["count"]; $i++)
|
||||
{
|
||||
if(!isset($entries[$i]["sambapwdlastset"]))
|
||||
{
|
||||
$notset++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastset = $entries[$i]["sambapwdlastset"][0];
|
||||
if($lastset>$ts)
|
||||
{
|
||||
$anzahl_geaendert++;
|
||||
$message.= "\n".md5($entries[$i]["uid"][0]);
|
||||
//var_dump($entries);
|
||||
//echo $entries[$i]["cn"][0]."<br />";
|
||||
//echo ."<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$message.="\n\nEintraege Gesamt:".$entries["count"];
|
||||
$message.="\nNie geaendert/nicht gesetzt:".$notset;
|
||||
$message.="\nHeute geaendert:".$anzahl_geaendert;
|
||||
|
||||
$to = MAIL_ADMIN;
|
||||
$from = 'no-reply@'.DOMAIN;
|
||||
$subject = 'Passwort Aenderung Statistik';
|
||||
|
||||
$mail = new mail($to, $from, $subject, $message);
|
||||
if(!$mail->send())
|
||||
echo 'Mail schicken fehlgeschlagen<br>';
|
||||
else
|
||||
echo 'Mail erfolgreich verschickt<br>';
|
||||
|
||||
echo nl2br($message);
|
||||
@ldap_close($connect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no conection to ldap server
|
||||
echo "no connection to '$ldap_server'<br>\n";
|
||||
}
|
||||
?>
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Christian Paminger < christian.paminger@technikum-wien.at >
|
||||
* Andreas Oesterreicher < andreas.oesterreicher@technikum-wien.at >
|
||||
* Rudolf Hangl < rudolf.hangl@technikum-wien.at >
|
||||
* Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at >
|
||||
*/
|
||||
|
||||
require_once('../../config/vilesci.config.inc.php');
|
||||
require_once('../../include/basis_db.class.php');
|
||||
if (!$db = new basis_db())
|
||||
die('Es konnte keine Verbindung zum Server aufgebaut werden.');
|
||||
|
||||
require_once('../../include/functions.inc.php');
|
||||
|
||||
// Variablen setzen
|
||||
if (isset($_GET['uid']))
|
||||
$uid=$_GET['uid'];
|
||||
if (isset($_GET['aktiv']))
|
||||
$aktiv=$_GET['aktiv'];
|
||||
else
|
||||
$aktiv='f';
|
||||
|
||||
// Benutzer daktivieren
|
||||
if ($aktiv=='t')
|
||||
if (isset($uid))
|
||||
{
|
||||
$qry = "UPDATE tbl_benutzer SET aktiv=FALSE WHERE uid='$uid';";
|
||||
if(!$result = $db->db_query($qry))
|
||||
die ($db->db_last_error());
|
||||
}
|
||||
else
|
||||
die('UID ist nicht gesetzt.');
|
||||
|
||||
// LDAP Verbindung
|
||||
$ds=ldap_connect(LDAP_SERVER); // must be a valid LDAP server!
|
||||
//echo "connect result is " . $ds . "<br />";
|
||||
if ($ds)
|
||||
{
|
||||
//echo "Binding ...";
|
||||
if (!$r=ldap_bind($ds)) // this is an "anonymous" bind, typically
|
||||
die("<h4>Unable to connect to LDAP server</h4>");
|
||||
}
|
||||
else
|
||||
die("<h4>Unable to connect to LDAP server</h4>");
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>LDAP-Check</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="../../skin/vilesci.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body class="background_main">
|
||||
<h1>LDAP-Check (Benutzer)</h1>
|
||||
<br>
|
||||
Benutzer werden geladen und die UID im LDAP geprueft.
|
||||
<BR><BR>
|
||||
Folgende Benutzer sind aktiv und haben keinen LDAP-Eintrag:<BR>
|
||||
|
||||
<?php
|
||||
$qry = "SELECT uid, titelpre,titelpost, nachname, vorname, vornamen, tbl_benutzer.aktiv FROM tbl_benutzer JOIN tbl_person USING (person_id) WHERE tbl_benutzer.aktiv AND uid NOT LIKE '\\\\_%' ";
|
||||
|
||||
if($result = $db->db_query($qry))
|
||||
{
|
||||
echo $db->db_num_rows($result);
|
||||
echo "<table class='liste'>";
|
||||
echo "<tr class='liste'><th>UID</th><th>Titel</th><th>Nachname</th><th>Vorname</th><th>Vornamen</th><th>TitelPost</th><th>Aktiv</th><th>eMail</th><th colspan='3'>Aktion</th></tr>";
|
||||
|
||||
$i=0;
|
||||
while ($row=$db->db_fetch_object($result))
|
||||
{
|
||||
|
||||
// Search uid entry
|
||||
$sr=ldap_search($ds, LDAP_BASE_DN, "uid=".$row->uid);
|
||||
//echo "Search result is " . $sr . "<br />";
|
||||
//echo "Number of entires returned is " . ldap_count_entries($ds, $sr) . "<br />";
|
||||
//echo "Getting entries ...<p>";
|
||||
$info = ldap_get_entries($ds, $sr);
|
||||
//echo "Data for " . $info["count"] . " items returned:<p>";
|
||||
/*for ($i=0; $i<$info["count"]; $i++)
|
||||
{
|
||||
echo "dn is: " . $info[$i]["dn"] . "<br />";
|
||||
echo "first cn entry is: " . $info[$i]["cn"][0] . "<br />";
|
||||
echo "first email entry is: " . $info[$i]["mail"][0] . "<br /><hr />";
|
||||
}*/
|
||||
|
||||
if ($info["count"]==0)
|
||||
{
|
||||
echo "<tr class='liste". ($i%2) ."'>";
|
||||
echo "<td nowrap>".$row->uid."</td>";
|
||||
|
||||
echo "<td nowrap>".$row->titelpre."</td>";
|
||||
echo "<td nowrap>".$row->nachname."</td>";
|
||||
echo "<td nowrap>".$row->vorname."</td>";
|
||||
echo "<td nowrap>".$row->vornamen."</td>";
|
||||
echo "<td nowrap>".$row->titelpost."</td>";
|
||||
echo "<td nowrap><a href='?uid=".$row->uid."&aktiv=".$row->aktiv."'><img src='../../skin/images/".($row->aktiv=='t'?'true':'false').".gif'></a></td>";
|
||||
|
||||
$email=$row->uid.'@technikum-wien.at';
|
||||
echo "<td nowrap><a href='mailto:$email'>$email</a></td>";
|
||||
//echo "<td nowrap class='button'><a href='lektor_edit.php?id=".$row->uid."'>Edit</a></td>";
|
||||
//echo "</td>";
|
||||
//echo "<td nowrap class='button'><a href='lektor_uebersicht.php?del=1&uid=".$row->uid."' onClick='javascript: return confdel();'>Delete</a></td>";
|
||||
echo "</tr>";
|
||||
$i++;
|
||||
flush();
|
||||
}
|
||||
if ($i>19)
|
||||
break;
|
||||
}
|
||||
echo "</table>";
|
||||
echo $i.' Ergebnisse<BR>';
|
||||
}
|
||||
else
|
||||
echo "Fehler beim laden der Mitarbeiter: ".$db->db_last_error();
|
||||
|
||||
echo "Closing connection";
|
||||
ldap_close($ds);
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+23
-40
@@ -21,11 +21,8 @@
|
||||
* Gerald Simane-Sequens < gerald.simane-sequens@technikum-wien.at >
|
||||
*/
|
||||
|
||||
require_once('../../config/vilesci.config.inc.php');
|
||||
require_once('../../include/basis_db.class.php');
|
||||
if (!$db = new basis_db())
|
||||
die('Es konnte keine Verbindung zum Server aufgebaut werden.');
|
||||
|
||||
require_once('../../config/vilesci.config.inc.php');
|
||||
require_once('../../include/basis_db.class.php');
|
||||
require_once('../../include/functions.inc.php');
|
||||
require_once('../../include/studiengang.class.php');
|
||||
require_once('../../include/person.class.php');
|
||||
@@ -33,7 +30,10 @@ require_once('../../include/benutzer.class.php');
|
||||
require_once('../../include/student.class.php');
|
||||
require_once('../../include/prestudent.class.php');
|
||||
require_once('../../include/datum.class.php');
|
||||
require_once('../../include/authentication.class.php');
|
||||
|
||||
if (!$db = new basis_db())
|
||||
die('Es konnte keine Verbindung zum Server aufgebaut werden.');
|
||||
|
||||
if(isset($_GET['searchstr']))
|
||||
$searchstr = $_GET['searchstr'];
|
||||
@@ -62,7 +62,7 @@ foreach ($stg->result as $row)
|
||||
echo '
|
||||
<form accept-charset="UTF-8" name="search" method="GET">
|
||||
Bitte Suchbegriff eingeben:
|
||||
<input type="text" name="searchstr" size="30" value="'.$searchstr.'">
|
||||
<input type="text" name="searchstr" size="30" value="'.$db->convert_html_chars($searchstr).'">
|
||||
<input type="submit" value="Suchen">
|
||||
</form>';
|
||||
|
||||
@@ -70,27 +70,17 @@ if($searchstr!='')
|
||||
{
|
||||
$qry = "SELECT person_id FROM public.tbl_person WHERE person_id in(
|
||||
SELECT distinct person_id FROM public.tbl_person LEFT JOIN public.tbl_benutzer USING(person_id) WHERE
|
||||
nachname ~* '".addslashes($searchstr)."' OR
|
||||
vorname ~* '".addslashes($searchstr)."' OR
|
||||
alias ~* '".addslashes($searchstr)."' OR
|
||||
nachname || ' ' || vorname = '".addslashes($searchstr)."' OR
|
||||
vorname || ' ' || nachname = '".addslashes($searchstr)."' OR
|
||||
uid ~* '".addslashes($searchstr)."'
|
||||
nachname ~* '".$db->db_escape($searchstr)."' OR
|
||||
vorname ~* '".$db->db_escape($searchstr)."' OR
|
||||
alias ~* '".$db->db_escape($searchstr)."' OR
|
||||
COALESCE(nachname,'') || ' ' || COALESCE(vorname,'') = '".$db->db_escape($searchstr)."' OR
|
||||
COALESCE(vorname,'') || ' ' || COALESCE(nachname,'') = '".$db->db_escape($searchstr)."' OR
|
||||
uid ~* '".$db->db_escape($searchstr)."'
|
||||
) ORDER BY nachname, vorname;";
|
||||
|
||||
if($result = $db->db_query($qry))
|
||||
{
|
||||
// LDAP Verbindung
|
||||
$ds=ldap_connect(LDAP_SERVER);
|
||||
|
||||
if ($ds)
|
||||
{
|
||||
if (!$r=ldap_bind($ds)) // this is an "anonymous" bind, typically
|
||||
die("<h4>Unable to connect to LDAP server</h4>");
|
||||
|
||||
}
|
||||
else
|
||||
die("<h4>Unable to connect to LDAP server</h4>");
|
||||
$auth = new authentication();
|
||||
|
||||
echo $db->db_num_rows($result).' Person(en) gefunden<br><br>';
|
||||
echo '<table>';
|
||||
@@ -103,7 +93,6 @@ if($searchstr!='')
|
||||
echo '<tr class="liste" align="center">';
|
||||
echo "<td><b>Nachname</b></td>";
|
||||
echo "<td><b>Vorname</b></td>";
|
||||
//echo "<td><b>SVNR</b></td>";
|
||||
echo "<td><b>Gebdatum</b></td>";
|
||||
echo "<td><b>updateAmUm</b></td>";
|
||||
echo "<td><b>updateVon</b></td>";
|
||||
@@ -131,7 +120,6 @@ if($searchstr!='')
|
||||
echo '<tr class="liste1">';
|
||||
echo "<td><a href='personen_details.php?person_id=$row_person->person_id'>$row_person->nachname</a></td>";
|
||||
echo "<td>$row_person->vorname</td>";
|
||||
//echo "<td>$row_person->svnr</td>";
|
||||
echo "<td>".($row_person->gebdatum!=''?$datum_obj->convertISODate($row_person->gebdatum):'')."</td>";
|
||||
echo "<td>".($row_person->updateamum!=''?date('d.m.Y H:i:s', $datum_obj->mktime_fromtimestamp($row_person->updateamum)):'')."</td>";
|
||||
echo "<td>$row_person->updatevon</td>";
|
||||
@@ -154,7 +142,7 @@ if($searchstr!='')
|
||||
*, tbl_benutzer.updateamum as bnupdateamum, tbl_benutzer.updatevon as bnupdatevon,
|
||||
tbl_mitarbeiter.updateamum as mupdateamum, tbl_mitarbeiter.updatevon as mupdatevon
|
||||
FROM public.tbl_mitarbeiter JOIN public.tbl_benutzer on(uid=mitarbeiter_uid)
|
||||
WHERE person_id='$row->person_id'";
|
||||
WHERE person_id=".$db->db_add_param($row->person_id, FHC_INTEGER);
|
||||
if($result_mitarbeiter = $db->db_query($qry))
|
||||
{
|
||||
if($db->db_num_rows($result_mitarbeiter)>0)
|
||||
@@ -172,13 +160,11 @@ if($searchstr!='')
|
||||
$content.= "<td><a href='personen_details.php?uid=$row_mitarbeiter->uid'>$row_mitarbeiter->uid</a></td>";
|
||||
$content.= "<td>".($row_mitarbeiter->aktiv=='t'?'Ja':'Nein')."</td>";
|
||||
|
||||
$content.= "<td>";
|
||||
$sr=ldap_search($ds, LDAP_BASE_DN, "uid=".$row_mitarbeiter->uid);
|
||||
$info = ldap_get_entries($ds, $sr);
|
||||
if ($info["count"]==0)
|
||||
$content.="Nein";
|
||||
else
|
||||
$content.= "<td>";
|
||||
if($auth->UserExternalExists($row_mitarbeiter->uid))
|
||||
$content.="Ja";
|
||||
else
|
||||
$content.="Nein";
|
||||
$content.= "</td>";
|
||||
//$content.= "<td>".($row_mitarbeiter->bnupdateamum!=''?date('d.m.Y H:i:s', $datum_obj->mktime_fromtimestamp($row_mitarbeiter->bnupdateamum)):'')."</td>";
|
||||
//$content.= "<td>$row_mitarbeiter->bnupdatevon</td>";
|
||||
@@ -197,7 +183,7 @@ if($searchstr!='')
|
||||
$qry = "SELECT *, tbl_benutzer.updateamum as bnupdateamum, tbl_benutzer.updatevon as bnupdatevon,
|
||||
tbl_student.updateamum as supdateamum, tbl_student.updatevon as supdatevon
|
||||
FROM public.tbl_student JOIN public.tbl_benutzer ON(student_uid=uid)
|
||||
WHERE person_id='$row->person_id'";
|
||||
WHERE person_id=".$db->db_add_param($row->person_id, FHC_INTEGER);
|
||||
if($result_student = $db->db_query($qry))
|
||||
{
|
||||
if($db->db_num_rows($result_student))
|
||||
@@ -219,12 +205,10 @@ if($searchstr!='')
|
||||
$content.= "<td>".($row_student->aktiv=='t'?'Ja':'Nein')."</td>";
|
||||
|
||||
$content.= "<td>";
|
||||
$sr=ldap_search($ds, LDAP_BASE_DN, "uid=".$row_student->uid);
|
||||
$info = ldap_get_entries($ds, $sr);
|
||||
if ($info["count"]==0)
|
||||
$content.="Nein";
|
||||
else
|
||||
if($auth->UserExternalExists($row_student->uid))
|
||||
$content.="Ja";
|
||||
else
|
||||
$content.="Nein";
|
||||
$content.= "</td>";
|
||||
//$content.= "<td>".($row_student->bnupdateamum!=''?date('d.m.Y H:i:s', $datum_obj->mktime_fromtimestamp($row_student->bnupdateamum)):'')."</td>";
|
||||
//$content.= "<td>$row_student->bnupdatevon</td>";
|
||||
@@ -247,10 +231,9 @@ if($searchstr!='')
|
||||
}
|
||||
}
|
||||
echo '</table>';
|
||||
ldap_close($ds);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user