Skip to content

Instantly share code, notes, and snippets.

@theredstapler
Created August 6, 2016 16:02
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save theredstapler/9de82a176c331f28e522d39eb237ae95 to your computer and use it in GitHub Desktop.
Save theredstapler/9de82a176c331f28e522d39eb237ae95 to your computer and use it in GitHub Desktop.
<?php
$ldap_dn = "cn=read-only-admin,dc=example,dc=com";
$ldap_password = "password";
$ldap_con = ldap_connect("ldap.forumsys.com");
ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
if(ldap_bind($ldap_con, $ldap_dn, $ldap_password)) {
$filter = "(cn=Albert Einstein)";
$result = ldap_search($ldap_con,"dc=example,dc=com",$filter) or exit("Unable to search");
$entries = ldap_get_entries($ldap_con, $result);
print "<pre>";
print_r ($entries);
print "</pre>";
} else {
echo "Invalid user/pass or other errors!";
}
?>
@salim114
Copy link

Hi, is it possible to filter two user ? $filter = Einstein and Tesla for example ?
Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment