Jump to content

LDAP Problems with LDAP_Search() and Active Directory -- HELP PLX!


thepip3r

Recommended Posts

Ok, it appears that other people are also having massive problems with this but I hope that someone might be able to offer a little more insight into what might be the problem.  My problem is that, I can establish an LDAP connection to my domain controller and bind, but when I run a search, I get some generic "Operations Error".  It's the most unhelpful generic error possible!!  Here is my simplified code that I've narrowed the problem down to in order to just troubleshoot this issue:

 

<? 
    // Connect to the directory server. 
    $ad = ldap_connect("myserver.my.local.domain") 
          or die("Couldn't connect to AD!"); 
    
    ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3); 
    ldap_set_option($ad, LDAP_OPT_REFERRALS, 0); 

    // Bind to the directory server. 
    $bd = ldap_bind($ad) or 
          die("Couldn't bind to AD!"); 

    echo "SUCCESS!"; 

    // Carry out directory server-specific tasks. 

    $dn = "ou=root ou,DC=my,DC=local,DC=domain"; 

    $filter = "(cn=*)"; 

    $result = ldap_search($ad, $dn, $filter); 
    var_dump($result);
    $entries = ldap_get_entries($ad, $result); 

    for ($i=0; $i<$entries["count"]; $i++) 
       { 
       echo $entries[$i]["displayname"] 
             [0]."(".$entries[$i]["l"][0].")<br />"; 
       } 
                 
    // Close the connection 
    ldap_unbind($ad); 
?> 

 

and the error that gets thrown is:

 

SUCCESS!
Warning: ldap_search() [function.ldap-search]: Search: Operations error in C:\adw\ldap\test2.php on line 21
bool(false) 
Warning: ldap_get_entries(): supplied argument is not a valid ldap result resource in C:\adw\ldap\test2.php on line 23

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.