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.
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.