<html>
<head>
<title>TGM-Account - LDAP-Ergebnis</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h3>TGM-Account - LDAP-Ergebnis</h3>
<p>
© by Dr. Stefan Hertl <br><br>
<?php
if (isset($_POST['uid']) && $_POST['uid'] != "")
{
$uid=$_POST['uid'];
}
else
{
echo ("Benutzername angeben !");
exit();
}
if (isset($_POST['pwd'])&& $_POST['pwd'] != "")
{
$pwd=$_POST['pwd'];
}
else
{
echo ("Kennwort angeben !");
exit();
}
$ldaphost = "ldap://mail.tgm.ac.at/";
$base_dn = "dc=tgm, dc=ac, dc=at";
$filter = "(uid=$uid)";
echo "Filter: '$filter'<br>";
// Anonymous connect to LDAP
$ldapconn = ldap_connect( $ldaphost )
or die("Could not connect to {$ldaphost}");
echo "Connected to {$ldaphost}.<br>\n";
// bind to server
if (!($bind = ldap_bind( $ldapconn )))
die("Unable to bind to server");
echo "Anonymous ldap_bind() successful.<br>\n";
// Look for an entry with our user name
if (!($searchid = ldap_search( $ldapconn, $base_dn, $filter )))
die("Unable to search LDAP server");
echo "ldap_search() successful.<br>\n";
// get his/her dn
$entry = ldap_first_entry( $ldapconn, $searchid );
$dn = ldap_get_dn( $ldapconn, $entry );
// Using this dn, we can connect to the server
if (!($bind = ldap_bind( $ldapconn, $dn, $pwd )))
die("Unable to bind to server using '" . $uid . "'");
echo "Sie sind jetzt als '$uid' mit dem Server verbunden...<br>\n";
?>
</p>
</body>
</html>