Jump to content


This topic is now archived and is closed to further replies.


Matching results from Mysql & Ldap

Recommended Posts

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 --------------------------

$sql = mysql_query("SELECT * FROM results"); // Perform MySQL query on only the current page number's results 

<table width="100%" border="0" cellpadding="0" cellspacing="0">
        <td width="100%"  valign="top"><table width="100%" border="0">
            <td>REQUESTOR email</td>
            <td>DATE SUBMITTED</td>
<td class="nicetableheader">DATE CLOSED</td>
while ($row = mysql_fetch_array($sql)) {
$username= $row['username'];
$subject= $row['subject'];
<td class="nicetablerow"><?php echo $username; ?></td>
<td class="nicetablerow"><?php echo $subject; ?></td>
<? } ?>  

--------------------------------------AD  -----------------

User Information Look Up
<h1>User Information Look Up
print "System Error";
$bind = ldap_bind($ldapserver,"cn=XXX,cn=XXX,dc=XXX,dc=com","XXXXXXXX");
print "System Error";
$base_dn = "DC=XXX,DC=com";

$filter = "sn=*";

$inforequired = array(

$result = ldap_search($ldapserver,$base_dn,$filter,$inforequired);
$info = ldap_get_entries($ldapserver,$result);

if($info["count"] == 0)
print "<p>No information available";
{  ?>
<table border=2>
<td>First name</td>
<td>Full Name</td>
<? 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];

for($i=0;$i<$info["count"];$i++) print $row[$i] . "\n";
print "</table>";
print "</body></html>";

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.