Hi everyone I'm doing a helpdesk project where I work but still stumped by this LDAP . now I'm a bit of a n00b in this area so bear with me.
I'm using Uniform Server from www.uniformserver.com and I've got the LDAP PHP extension working. I'm trying to find out how to do a basic Active Directory query with PHP, I'll eventually integrate this into my program and it will have Active Directory user authentication as well as a 2d mapping system that uses SVG etc. etc. - I can't wait to see it finished and working, but the LDAP portion of this project has stumped me a bit. The trouble I'm having is as follows:
I have the way my Domain is setup below:

For obvious reasons, I've renamed the domain and removed some of the containers or whatever they're called. Anyway, here's my code
<?php
$dn = "OU=Users,DN=blah,DN=yah,DN=yakety,DN=ie";
$attributes = array("displayname", "l");
$filter = "(cn=*)";
$ad = ldap_connect("ldap://mydomaincontroller")
or die("Couldn't connect to AD!");
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
$bd = ldap_bind($ad,"myusername@blah.yah.yakety.ie","mypassword")
or die("Couldn't bind to AD!");
$result = ldap_search($ad, $dn, $filter, $attributes);
$entries = ldap_get_entries($ad, $result);
for ($i=0; $i<$entries["count"]; $i++)
{
echo $entries[$i]["displayname"]
[0]."(".$entries[$i]["l"][0].")<br />";
}
ldap_unbind($ad);
?>
and all I get is:
Warning: ldap_search() [function.ldap-search]: Search: Operations error in W:\www\ad3.php on line 17
Warning: ldap_get_entries(): supplied argument is not a valid ldap result resource in W:\www\ad3.php on line 19
Can anybody please help me? I just need a basic example to show me how to interface with my AD - I'm nearly there I can almost taste it!
I've also tried
$dn = "OU=Users,DN=blah,DN=yah,DN=yakety,DN=ie";
$dn = "cn=Users,DN=blah,DN=yah,DN=yakety,DN=ie";
$dn = "DN=blah,DN=yah,DN=yakety,DN=ie";
$dn = "OU=Users,DC=blah,DC=yah,DC=yakety,DC=ie";
and none of these seem to work!!! What am I doing wrong? I'm sure that it's connecting to the server because when I tried with the wrong password it said
incorrect credentials or something. PLEASE HELP!!!!!