<?php
$ldaphost = "ldap.xxx.yyy";
$ldapport = 389;
$ds = ldap_connect($ldaphost, $ldapport) or die("Could not connect to $ldaphost");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($ds) {
$username = "test";
$upasswd = "password";
$binddn = "cn=admin,dc=xxx,dc=yyy";
$binddnt = "ou=mathematicians,dc=xxx,dc=yyy";
$ldapbind = ldap_bind($ds,$binddn, $upasswd);
//check if ldap was sucessfull
if ($ldapbind) {
$filter = "(uniqueMember=*)";
$result = ldap_search($ds, $binddnt, $filter) or exit("Unable to search LDAP server");
$entries = ldap_get_entries($ds, $result);
var_dump($entries);
} else {
echo "LDAP bind failed...";
}
}
?>
Jan 31, 2018
LDAP Simple bind in PHP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment