<?
error_reporting(E_ALL);
// include the ldap2ldif class
include("../ldap2ldif.class.php");
// make an instance
$e=new ldap2ldif("$servername","$port");
// init connection
if($username=='')
$e->init(); // anonymous
else
$e->init($username,$password); // non anonymous
// search
$e->search($basedn,$filter);
// store results in a variable
$result=$e->export();
// close the connection
$e->close();
if(isset($tofile)){
// send as file for download
header("Content-type: text/plain");
header("Content-Disposition: attachment;filename=".$servername."_".date('d-m-Y').".ldif");
print $result;
}else{
// display result in browser
echo "<b>Result of export</b><hr>\n";
echo "<pre>";
print $result;
echo "</pre>";
}
?>