Home arrow PHP arrow Page 4 - Create an LDAP Address Book with PHP
PHP

Create an LDAP Address Book with PHP


What is LDAP and how does it relate to PHP? If you're unsure, then Dannie's come to save the day! In this article he explains what LDAP is and shows you how to create an LDAP address book with PHP...

Author Info:
By: Dannie Stanley
Rating: 4 stars4 stars4 stars4 stars4 stars / 46
January 08, 2003
TABLE OF CONTENTS:
  1. · Create an LDAP Address Book with PHP
  2. · Setup Public LDAP Server Information
  3. · Format Output
  4. · Close Connection
  5. · Source Code
  6. · Conclusion

print this article
SEARCH DEVARTICLES

Create an LDAP Address Book with PHP - Close Connection
(Page 4 of 6 )

Now that we have all of our data contained in $result_list, we can safely disconnect from the LDAP connection.

<?php

//Close Connection
ldap_close($connect_id);

?>

Make HTML Form for Search Interface
Finally, we get to the HTML output of the script.

This set of code prints out the form that is used for performing the searches.

<?php

//Make Form
echo "<CENTER><FORM ACTION=\"$PHP_SELF\" METHOD=\"GET\">";
echo "Search in: <SELECT NAME=\"SERVER_ID\">";

//Loop Through and Create SELECT OPTIONs
for($i=0; $i echo "<OPTION VALUE=\"$i\">".$LDAP_NAME[$i]." </OPTION>";

echo "</SELECT><BR>";
echo "Search for: <INPUT TYPE=\"text\" NAME=\"common\">";
echo "<INPUT TYPE=\"submit\" NAME=\"lookup\" VALUE=\"go\"><BR>";
echo "(You can use * for wildcard searches, ex. * Stanley will find all Stanleys) <BR>";
echo "</FORM></CENTER>";

?>


The only portions of this code that is interpreted is $PHP_SELF which is a global constant for the name of the script itself and the loop that creates the SELECT box from our $LDAP_NAME variable.

Echo Results

Now that all of the work has been done, we print out the result set. If no results were returned, a message is given stating the same.

<?php

//Echo Results
if($result_list)
{
echo "<CENTER><TABLE BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"10\" BGCOLOR=\"#FFFFEA\" WIDTH=\"450\"><TR><TD>$result_list</TD></TR> </TABLE></CENTER>";
}
else
echo "No Results";

?>

blog comments powered by Disqus
PHP ARTICLES

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials