Solved

php ldap operations error

Posted on 2014-01-14
2
1,274 Views
Last Modified: 2014-01-15
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
Comment
Question by:mankowitz
2 Comments
 
LVL 11

Accepted Solution

by:
jausions earned 500 total points
ID: 39782231
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
 
LVL 24

Author Closing Comment

by:mankowitz
ID: 39782573
so it turns out that that typo was in my actual code....... D'oh!
0

Join & Write a Comment

Suggested Solutions

Resolve DNS query failed errors for Exchange
This article discusses four methods for overlaying images in a container on a web page
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now