PHP LDAP Connect with Bind, Serach, Fetch and Closing connection methord
Below function used to connect ldap through php programe, this working script is useful in checking and authenticating users in ldap for php login forms.
<?php $all_users=array() ; $ds='' ; $ds=ldap_connect('ldap.YourDomain.com','389') or die("Error while connecting to LDAP server") ; # } # end if if($ds) { $bind=ldap_bind($ds) or die("Error while binding with LDAP server"); $search_result=ldap_search($ds,'ou=People,o=YourDomain.com','uid=username@YourDomain.com') or die("Error while searching data in LDAP server") ; $ldap_entries=ldap_get_entries($ds,$search_result) ; $i=0; print_r($ldap_entries); echo "<br>"; echo "$ldap_entries[0][dn]"; echo "<br>"; ldap_close($ds) or die("Error while closing LDAP connection") ; } # end if ?>