ok I'm getting further in my project but still stumped by this LDAP . now I'm a bit of a n00b in this area so bear with me. Now, 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!!!!! P.S. I know this is no longer a uniform server issue but I just hope somebody here can help me...