Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1594
  • Last Modified:

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:

$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);
}

Open in new window


I keep getting an operations error. Any ideas?
0
mankowitz
Asked:
mankowitz
1 Solution
 
jausionsCommented:
I'm going to assume the typo on line 3 is just in here and not in your actual code.

To troubleshoot your issue, use ldap_error($ldap) to get the message, it will tell you more of what's happening.
0
 
mankowitzAuthor Commented:
so it turns out that that typo was in my actual code....... D'oh!
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now