Solved

php ldap operations error

Posted on 2014-01-14
2
1,391 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Format Date 7 28
Prestashop modules custimzation 2 30
How to Show Random Image in Meta og:image Tag on every refresh? 13 43
integrated two Separate file . 3 30
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

710 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