| Current Path : /var/www/html/mmishra/indem/rgiit/rgiit/x/ |
| Current File : /var/www/html/mmishra/indem/rgiit/rgiit/x/index1.php.bak |
<html>
<head>
<title>
User Information
</title>
</head>
<body>
<h1>Search for person</h1>
<h3>Choose any one option</h3>
<p>
</p>
<form action=index1.php method=post>
<table>
<tr> <td><input type=radio name=stype value=1>Surname
<td><input type=text name=surname size=15>
<td><input type=radio name=stype value=2>Username
<td><input type=text name=login size=15>
<tr> <td><input type=radio name=stype value=3>Email address
<td><input type=text name=mail size=15>
<td><input type=radio name=stype value=4>UserId
<td><input type=text name=uid size=15>
<tr>
<td><td><td><td align="right"><input type=submit value="Look up">
</table>
</form></br></br>
<?
$ldapserver=ldap_connect("rgiita.ac.in");
if(!$ldapserver)
{
print "System Error";
exit(0);
}
$bind = ldap_bind($ldapserver,"dc=rgiita,dc=ac,dc=in","sec");
if(!bind)
{
print "System Error";
exit(0);
}
$base_dn = "DC=rgiita,DC=ac,DC=in";
if($_POST['stype'] == 1) /* surname look up */
{
$filter = "sn=" . trim($_POST['surname']);
}
else if($_POST['stype'] == 2)
{
$filter = "cn=" . trim($_POST['login']);
}
else if($_POST['stype'] == 3)
{
$mail = trim($_POST['mail']);
if(!strstr($mail,"@"))
{
$mail .= "@rgiita.ac.in";
}
$filter = "mail=" . $mail;
}
else if($_POST['stype'] == 4)
{
$filter = "uid=" . trim($_POST['uid']);
}
$inforequired = array(
"mailboxs",
"uid",
"mail",
"givenName",
"sn",
"cn");
$result = ldap_search($ldapserver,$base_dn,$filter,$inforequired);
$info = ldap_get_entries($ldapserver,$result);
echo $info[0]["ginenName"][0];
if($info["count"] == 0)
{
print "<p>No information available";
}
else
{
print "<table border=2><tr>"
. "<th>Nickname"
. "<th>UserId"
. "<th>Givenname"
. "<th>Surname"
. "<th>Mail"
. "<th>UserName";
for($i=0;$i<$info["count"];$i++)
{
//$row[$i] = "<tr>"
// . "<td>" . $info[$i]["givenname"][0]
// . "<td>" . $info[$i]["sn"][0]
//. "<td>" . $info[$i]["department"][0]
//. "<td>" . $info[$i]["employeetype"][0]
//. "<td>" . $info[$i]["mail"][0]
//. "<td>" . $info[$i]["cn"][0];
$row[$i] = "<tr>"
. "<td>" . $info[$i]["Nickname"][0]
. "<td>" . $info[$i]["uid"][0]
. "<td>" . $info[$i]["givenName"][0]
. "<td>" . $info[$i]["sn"][0]
. "<td>" . $info[$i]["mail"][0]
. "<td>" . $info[$i]["cn"][0];
}
sort($row);
for($i=0;$i<$info["count"];$i++) print $row[$i] . "\n";
print "</table>";
}
?>
</body>
</html>