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”;
?>

2 thoughts on “Quick PHP code to test ldap connection

  1. Its Work Only Windows Active Directory Domain ..
    Openldap authentication Not working
    How to solve This Problem ??????

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>