LDAP ***RESOLVED***

From: Date: Tue, 21 Aug 2007 18:44:41 +0000
Subject: LDAP ***RESOLVED***
Groups: php.general 
Request: Send a blank email to php-general+get-261091@lists.php.net to get a copy of this message
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); ?>

« previous php.general (#261091) next »