mankowitz
asked on
php ldap operations error
I am writing an application in php and trying to authenticate against an active directory server via LDAP. I am able to authenticate users (valid versus invalid), but I want to search the AD to get their full name. Here is my php code:
I keep getting an operations error. Any ideas?
$ldap = ldap_connect("192.128.xxx.xxx") or die("NO LDAP CONNECTION");
$user = "xxxx";
$domiain_user = "domain\\" . $user;
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
if($bind = @ldap_bind($ldap, $domain_user, $_POST['password'])) {
// valid
$dn = "dc=evh,dc=inc";
$filter = "(sAMAccountName=$user)";
$attr = array("givenName", "sn");
$result = ldap_search($ldap, $dn, $filter, $attr) or exit("Unable to search LDAP server");
// THIS IS WHERE I GET THE OPERATIONS ERROR
$entries = ldap_get_entries($ldap, $result);
var_dump($entries);
}
I keep getting an operations error. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER