6

I've spent the better part of the day so far looking into this problem. For some reason, I cannot for the life of me figure out what's going wrong with the code below. It's a trimmed/modified version of the example given at the PHP Manual.

When I run the following code, I receive the error message:

Warning: ldap_search() [function.ldap-search]: Search: Operations error in C:\wamp\www\ldap.php on line 12

Relevant code:

<?php
$ds=ldap_connect("serverName.first.second.third.fourth");

ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

    $r=ldap_bind($ds);    
    $sr=ldap_search($ds, "OU=InfoSystems,OU=Domain Users,DC=first,DC=second,DC=third,ED=fourth", "sn=MyActualSurName");  
    ldap_close($ds);
?>

I used a VBS script to print the current logged in user's (Me) full DN. From that, I plugged in the appropriate OU and DC fields.

Any help would be greatly appreciated. If more clarification is needed, don't hesitate to ask.

3
  • Have you tried this? us3.php.net/manual/en/function.ldap-search.php#45388 Commented Oct 21, 2011 at 19:51
  • I have. That was the first thing I stumbled across as a solution. I am using that and LDAP_OPT_PROTOCOL_VERSION to force Version 3, which was another solution that most agree upon as being useful. I have tried using one and not the other as well, with no change in the output. Commented Oct 21, 2011 at 19:57
  • Any other suggestions? I spent the last few days working on it some more and nothing has turned up. Commented Oct 25, 2011 at 16:13

1 Answer 1

6

Finally found the problem. Our AD server allows for anonymous bind, but apparently does not allow for searching without credentials. The above code works fine once I call ldap_bind() with credentials.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.