Update
UPDATE: Using the free version of LDAP Browser (check out here ) was good because you can just browse the LDAP server, it helps to understand whether it is possible to bind anonymously, etc. Etc. But the biggest advantage was getting the DN (copy and paste). After that, I was able to read the data.
I had the following problems, and here is how I solved it:
Task 1
Problem 1: Unable to bind, although I could connect anonymously through LDAP browser software
Solution: added the following lines before binding, as described above:
ldap_set_option( $ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3 ); ldap_set_option( $ldapconn, LDAP_OPT_REFERRALS, 0 );
After that, I was able to tie ...
Task 2
Problem 2: Cannot find ...
Solution: Open the LDAP browser. Check the connection to make sure you can connect to the LDAP server. View an example recording. Right-click and go to Properties, copy the DN and replace it in the code, and here it is!
The original message is shown below:
I can't seem to do a search and use the free version of LDAP Browser 4.5 to make sure everything works ...
This is my code:
function ldap_anon_connect($ein){ $ldaphost = "ldap://link_to_ldap.com"; //create a connection to ldap server $ldapconn = ldap_connect($ldaphost) or die("Couldn't connect to " .$ldaphost); if ($ldapconn) { ldap_set_option( $ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3 ); ldap_set_option( $ldapconn, LDAP_OPT_REFERRALS, 0 ); $ldapbind = ldap_bind($ldapconn); if ($ldapbind) { // if binds, look some stuff up $info = ldap_annon_get_profile($ein, $ldapconn); return $info; } else{ echo "Invalid EIN. Please Try again"; die(); } } } function ldap_annon_get_profile($ein, $ldapconn){ $filter = "(cn=".$ein.")"; $justthese = array( "cn","sn","givenName","displayName","mail","EmployeeClass","ManagerEIN", "mobile","title","c","PersonalTitle" ); $sr = ldap_search($ldapconn, "o=CO,ou=COplc,ou=people", $filter, $justthese); $info = ldap_get_entries($ldapconn, $sr); return $info; }
I double checked my DN = " o=CO,ou=COplc,ou=people ", this is the correct line, since I can look for things in the LDAP browser ...
Any ideas?