I am lost in this. Is it possible to match the results from a query in php/mysql to the results from php/openldap?
My AD has the needed email addresses, while the MySql has the needed survey results.
Both have one common field: "username"
Basically I need to match them up, and of course not everyone will need to be matched, only those people who submitted a survey to the MySql database. And it would be nice to see the results on one webpage.
Any help would be appreciated, as I am stumped on how to match these results.
So, below is the code for both sides: MYSQL & AD
--------------------------- MYSQL --------------------------
<?
include('includes/configure.php');
$sql = mysql_query("SELECT * FROM results"); // Perform MySQL query on only the current page number's results
?>
<html>
<head>
<title>survey</title>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" valign="top"><table width="100%" border="0">
<tr>
<td>INCIDENT</td>
<td>REQUESTOR</td>
<td>REQUESTOR email</td>
<td>SUBJECT</td>
<td>DATE SUBMITTED</td>
<td class="nicetableheader">DATE CLOSED</td>
</tr>
<?
while ($row = mysql_fetch_array($sql)) {
$username= $row['username'];
$subject= $row['subject'];
?>
<tr>
<td class="nicetablerow"><?php echo $username; ?></td>
<td class="nicetablerow"><?php echo $subject; ?></td>
</tr>
<? } ?>
</table>
</td></tr></table>
</body>
</html>
--------------------------------------AD -----------------
<html>
<head>
<title>
User Information Look Up
</title>
</head>
<body>
<h1>User Information Look Up
</h1>
<?
$ldapserver=ldap_connect("myserver");
if(!$ldapserver)
{
print "System Error";
exit(0);
}
$bind = ldap_bind($ldapserver,"cn=XXX,cn=XXX,dc=XXX,dc=com","XXXXXXXX");
if(!bind)
{
print "System Error";
exit(0);
}
$base_dn = "DC=XXX,DC=com";
$filter = "sn=*";
$inforequired = array(
"username",
"description",
"mail",
"givenName",
"sn",
"cn");
$result = ldap_search($ldapserver,$base_dn,$filter,$inforequired);
$info = ldap_get_entries($ldapserver,$result);
if($info["count"] == 0)
{
print "<p>No information available";
}
else
{ ?>
<table border=2>
<tr>
<td>First name</td>
<td>Surname</td>
<td>Full Name</td>
<td>Department</td>
<td>Mail</td>
<td>Login</td>
</tr>
<? for($i=0;$i<$info["count"];$i++)
{
$row[$i] = "<tr>"
. "<td>" . $info[$i]["givenname"][0] . "</td>"
. "<td>" . $info[$i]["sn"][0] . "</td>"
. "<td>" . $info[$i]["cn"][0] . "</td>"
. "<td>" . $info[$i]["description"][0] . "</td>"
. "<td>" . $info[$i]["mail"][0] . "</td>"
. "<td>" . $info[$i]["username"][0];
}
sort($row);
for($i=0;$i<$info["count"];$i++) print $row[$i] . "\n";
print "</table>";
}
print "</body></html>";
?>
My AD has the needed email addresses, while the MySql has the needed survey results.
Both have one common field: "username"
Basically I need to match them up, and of course not everyone will need to be matched, only those people who submitted a survey to the MySql database. And it would be nice to see the results on one webpage.
Any help would be appreciated, as I am stumped on how to match these results.
So, below is the code for both sides: MYSQL & AD
--------------------------- MYSQL --------------------------
<?
include('includes/configure.php');
$sql = mysql_query("SELECT * FROM results"); // Perform MySQL query on only the current page number's results
?>
<html>
<head>
<title>survey</title>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" valign="top"><table width="100%" border="0">
<tr>
<td>INCIDENT</td>
<td>REQUESTOR</td>
<td>REQUESTOR email</td>
<td>SUBJECT</td>
<td>DATE SUBMITTED</td>
<td class="nicetableheader">DATE CLOSED</td>
</tr>
<?
while ($row = mysql_fetch_array($sql)) {
$username= $row['username'];
$subject= $row['subject'];
?>
<tr>
<td class="nicetablerow"><?php echo $username; ?></td>
<td class="nicetablerow"><?php echo $subject; ?></td>
</tr>
<? } ?>
</table>
</td></tr></table>
</body>
</html>
--------------------------------------AD -----------------
<html>
<head>
<title>
User Information Look Up
</title>
</head>
<body>
<h1>User Information Look Up
</h1>
<?
$ldapserver=ldap_connect("myserver");
if(!$ldapserver)
{
print "System Error";
exit(0);
}
$bind = ldap_bind($ldapserver,"cn=XXX,cn=XXX,dc=XXX,dc=com","XXXXXXXX");
if(!bind)
{
print "System Error";
exit(0);
}
$base_dn = "DC=XXX,DC=com";
$filter = "sn=*";
$inforequired = array(
"username",
"description",
"mail",
"givenName",
"sn",
"cn");
$result = ldap_search($ldapserver,$base_dn,$filter,$inforequired);
$info = ldap_get_entries($ldapserver,$result);
if($info["count"] == 0)
{
print "<p>No information available";
}
else
{ ?>
<table border=2>
<tr>
<td>First name</td>
<td>Surname</td>
<td>Full Name</td>
<td>Department</td>
<td>Mail</td>
<td>Login</td>
</tr>
<? for($i=0;$i<$info["count"];$i++)
{
$row[$i] = "<tr>"
. "<td>" . $info[$i]["givenname"][0] . "</td>"
. "<td>" . $info[$i]["sn"][0] . "</td>"
. "<td>" . $info[$i]["cn"][0] . "</td>"
. "<td>" . $info[$i]["description"][0] . "</td>"
. "<td>" . $info[$i]["mail"][0] . "</td>"
. "<td>" . $info[$i]["username"][0];
}
sort($row);
for($i=0;$i<$info["count"];$i++) print $row[$i] . "\n";
print "</table>";
}
print "</body></html>";
?>