Quick PHP code to test ldap connection

I needed to test that the ldap module in PHP was working (“apt-get install php5-ldap” in linux) so I just placed this in a .php to check it was logging in correctly

<?php
$ldap = ldap_connect(“domain.com”);
$username=”username@domain.com”;
$password=”password”;

if($bind = ldap_bind($ldap, $username,$password ))
echo “logged in”;
else
echo “fail”;
echo “<br/>done”;
?>