LDAP ***RESOLVED***

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Apparently even though our Domain Administrator said anonymous access is
enabled for the server, it still did not like me trying to query AD
anonymously.  I created a username/password with limited priviledges to AD
and now it works like a charm.

Below you will find my finished code:

<?php
 $base_dn="CN=users,DC=domain,DC=us";
 $ldap_host="AD server";
 $ldap_port="389";
 $ldap_user="CN=username, CN=Users, DC=domain, DC=us";
 $ldap_pass="password";
 $filter="(&(objectclass=user)(Description=My Organization)(cn=*))";
$connect = ldap_connect( $ldap_host, $ldap_port)
         or exit(">>Could not connect to LDAP server<<");
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($connect, $ldap_user, $ldap_pass)
      or exit(">>Could not bind to $ldap_host<<");
$read = ldap_search($connect, $base_dn, $filter)
      or exit(">>Unable to search ldap server<<");
$info = ldap_get_entries($connect, $read);
echo $info["count"]." entries returned<p>";
$ii=0;
for ($i=0; $ii<$info[$i]["count"]; $ii++){
    $data = $info[$i][$ii];
    echo $data.":&nbsp;&nbsp;".$info[$i][$data][0]."<br>";
}
ldap_close($connect);
?>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux