Jump to content


Matching results from Mysql & Ldap

  • Please log in to reply
No replies to this topic

#1 netfrugal

  • Members
  • PipPip
  • Member
  • 26 posts

Posted 23 October 2006 - 07:25 PM

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users