#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    3
    Rep Power
    0

    Ldap_connect() / ldap_bind() not working


    Code:
    <?php  $ldapcon = ldap_connect("10.5.24.118")     or die("Could not connect to LDAP server.");  if ($ldapcon) {      // binding anonymously     $ldapbind = ldap_bind($ldapcon);      if ($ldapbind) {         echo "LDAP bind anonymous successful...";     } else {         echo "LDAP bind anonymous failed...";     } }  ?>
    I used this code to connect to my OpenLDAP server (up and running without a problem) and I always get a failure. I am able to connect from phpldapadmin (both anonymous and authenticated) without a problem. I am a php-ldap newbie so any help is appreciated.

    Thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    3
    Rep Power
    0
    Can anyone please respond? May be point me on where/what to check?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    3
    Rep Power
    0
    Just solved it! The problem was I am using LDAPv2 code while running LDAPv3. I added the code

    Code:
     ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
    after the connection tag and all was good!

IMN logo majestic logo threadwatch logo seochat tools logo