From 8a32d1af5d84936a88e2b91711245776163fbed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 10 Mar 2014 15:25:12 +0000 Subject: [PATCH] =?UTF-8?q?Auhtentifizierung=20gegen=202=20LDAP=20Server?= =?UTF-8?q?=20erm=C3=B6glicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cis/private/profile/change_password.php | 2 +- cis/private/tools/notebook_registration.php | 34 ++--- config/cis.config-default.inc.php | 45 +++++-- config/wawi.config-default.inc.php | 40 ++++-- include/auth_demo.class.php | 10 ++ include/auth_mixed.class.php | 124 ++++++++++------- include/auth_session.class.php | 27 ++++ include/authentication.class.php | 1 + system/ldap_pw_check.php | 76 ----------- vilesci/personen/ldap_check.php | 140 -------------------- vilesci/personen/suche.php | 63 ++++----- 11 files changed, 212 insertions(+), 350 deletions(-) delete mode 100644 system/ldap_pw_check.php delete mode 100644 vilesci/personen/ldap_check.php diff --git a/cis/private/profile/change_password.php b/cis/private/profile/change_password.php index 66ae19e27..c8c8ad7b9 100644 --- a/cis/private/profile/change_password.php +++ b/cis/private/profile/change_password.php @@ -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 diff --git a/cis/private/tools/notebook_registration.php b/cis/private/tools/notebook_registration.php index 9b5056af3..8615bf18c 100644 --- a/cis/private/tools/notebook_registration.php +++ b/cis/private/tools/notebook_registration.php @@ -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 = "") '.$p->t("notebookregister/passwortEingebenWennUIDgeaendert").'.'; else if ($error == 2) echo '

'.$p->t("notebookregister/passwortErneutEingeben").'.

'; else if ($error == 3) echo '

'.$p->t("notebookregister/MACadresseBereitsVerwendet").'.

'; - //echo "result:".$mac_result; + if(isset($mac_result) && $mac_result!='') { if($mac_result == 0) @@ -267,16 +263,6 @@ function ip_increment($ip = "") ?>

t("notebookregister/notebook_absatz2");?>

- diff --git a/config/cis.config-default.inc.php b/config/cis.config-default.inc.php index f47e32a10..a8a3d0b77 100644 --- a/config/cis.config-default.inc.php +++ b/config/cis.config-default.inc.php @@ -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 diff --git a/config/wawi.config-default.inc.php b/config/wawi.config-default.inc.php index 34e686d71..95c7215d0 100644 --- a/config/wawi.config-default.inc.php +++ b/config/wawi.config-default.inc.php @@ -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"); diff --git a/include/auth_demo.class.php b/include/auth_demo.class.php index 67ceff776..536d9e508 100755 --- a/include/auth_demo.class.php +++ b/include/auth_demo.class.php @@ -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() diff --git a/include/auth_mixed.class.php b/include/auth_mixed.class.php index 2e080f3e1..eb0232510 100644 --- a/include/auth_mixed.class.php +++ b/include/auth_mixed.class.php @@ -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 diff --git a/include/auth_session.class.php b/include/auth_session.class.php index 4f31c8f50..c18708372 100644 --- a/include/auth_session.class.php +++ b/include/auth_session.class.php @@ -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']; diff --git a/include/authentication.class.php b/include/authentication.class.php index ec195211e..a241d14b4 100644 --- a/include/authentication.class.php +++ b/include/authentication.class.php @@ -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(); diff --git a/system/ldap_pw_check.php b/system/ldap_pw_check.php deleted file mode 100644 index 35913ad2c..000000000 --- a/system/ldap_pw_check.php +++ /dev/null @@ -1,76 +0,0 @@ -\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
"; - 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]."
"; - //echo ."
"; - } - } - } - - $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
'; - else - echo 'Mail erfolgreich verschickt
'; - - echo nl2br($message); - @ldap_close($connect); -} -else -{ - // no conection to ldap server - echo "no connection to '$ldap_server'
\n"; -} -?> diff --git a/vilesci/personen/ldap_check.php b/vilesci/personen/ldap_check.php deleted file mode 100644 index 4ed764db6..000000000 --- a/vilesci/personen/ldap_check.php +++ /dev/null @@ -1,140 +0,0 @@ - - * 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 . "
"; - if ($ds) - { - //echo "Binding ..."; - if (!$r=ldap_bind($ds)) // this is an "anonymous" bind, typically - die("

Unable to connect to LDAP server

"); - } - else - die("

Unable to connect to LDAP server

"); - -?> - - - LDAP-Check - - - - - -

LDAP-Check (Benutzer)

-
- Benutzer werden geladen und die UID im LDAP geprueft. -

- Folgende Benutzer sind aktiv und haben keinen LDAP-Eintrag:
- - db_query($qry)) - { - echo $db->db_num_rows($result); - echo ""; - echo ""; - - $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 . "
"; - //echo "Number of entires returned is " . ldap_count_entries($ds, $sr) . "
"; - //echo "Getting entries ...

"; - $info = ldap_get_entries($ds, $sr); - //echo "Data for " . $info["count"] . " items returned:

"; - /*for ($i=0; $i<$info["count"]; $i++) - { - echo "dn is: " . $info[$i]["dn"] . "
"; - echo "first cn entry is: " . $info[$i]["cn"][0] . "
"; - echo "first email entry is: " . $info[$i]["mail"][0] . "


"; - }*/ - - if ($info["count"]==0) - { - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - $email=$row->uid.'@technikum-wien.at'; - echo ""; - //echo ""; - //echo ""; - //echo ""; - echo ""; - $i++; - flush(); - } - if ($i>19) - break; - } - echo "
UIDTitelNachnameVornameVornamenTitelPostAktiveMailAktion
".$row->uid."".$row->titelpre."".$row->nachname."".$row->vorname."".$row->vornamen."".$row->titelpost."$emailEditDelete
"; - echo $i.' Ergebnisse
'; - } - else - echo "Fehler beim laden der Mitarbeiter: ".$db->db_last_error(); - - echo "Closing connection"; - ldap_close($ds); - -?> - - - diff --git a/vilesci/personen/suche.php b/vilesci/personen/suche.php index 50af96d01..38108c24e 100644 --- a/vilesci/personen/suche.php +++ b/vilesci/personen/suche.php @@ -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 '
Bitte Suchbegriff eingeben: - +
'; @@ -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("

Unable to connect to LDAP server

"); - - } - else - die("

Unable to connect to LDAP server

"); + $auth = new authentication(); echo $db->db_num_rows($result).' Person(en) gefunden

'; echo ''; @@ -103,7 +93,6 @@ if($searchstr!='') echo ''; echo ""; echo ""; - //echo ""; echo ""; echo ""; echo ""; @@ -131,7 +120,6 @@ if($searchstr!='') echo ''; echo ""; echo ""; - //echo ""; echo ""; echo ""; echo ""; @@ -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.= ""; $content.= ""; - $content.= ""; //$content.= ""; //$content.= ""; @@ -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.= ""; $content.= ""; //$content.= ""; //$content.= ""; @@ -247,10 +231,9 @@ if($searchstr!='') } } echo '
NachnameVornameSVNRGebdatumupdateAmUmupdateVon
$row_person->nachname$row_person->vorname$row_person->svnr".($row_person->gebdatum!=''?$datum_obj->convertISODate($row_person->gebdatum):'')."".($row_person->updateamum!=''?date('d.m.Y H:i:s', $datum_obj->mktime_fromtimestamp($row_person->updateamum)):'')."$row_person->updatevon$row_mitarbeiter->uid".($row_mitarbeiter->aktiv=='t'?'Ja':'Nein').""; - $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.= ""; + if($auth->UserExternalExists($row_mitarbeiter->uid)) $content.="Ja"; + else + $content.="Nein"; $content.= "".($row_mitarbeiter->bnupdateamum!=''?date('d.m.Y H:i:s', $datum_obj->mktime_fromtimestamp($row_mitarbeiter->bnupdateamum)):'')."$row_mitarbeiter->bnupdatevon".($row_student->aktiv=='t'?'Ja':'Nein').""; - $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.= "".($row_student->bnupdateamum!=''?date('d.m.Y H:i:s', $datum_obj->mktime_fromtimestamp($row_student->bnupdateamum)):'')."$row_student->bnupdatevon
'; - ldap_close($ds); } } ?> - \ No newline at end of file +