Solved

php ldap operations error

Posted on 2014-01-14
2
1,292 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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

910 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

22 Experts available now in Live!

Get 1:1 Help Now