ldap error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpblue
Forum Newbie
Posts: 1
Joined: Mon Oct 12, 2009 12:10 pm

ldap error

Post by phpblue »

I'm getting the following error in my error_log file

Code: Select all

PHP Warning:  ldap_bind() [<a href='function.ldap-bind'>function.ldap-bind</a>]: Unable to bind to server: Invalid credentials in xxxx
 on line 242
Here is the code. I've highlighted line 242

Code: Select all

/* LDAP Code begin */
   public function ldapAuthentication($username, $password) {
       $ldap      = array('ldaphost' => 'ldap://ldap.domain.com',
                       'domain'   => 'domain.com',
                       'dn'       => 'ou=Users,dc=domain,dc=com',
                       'binduser' => 'CN=Proxy,ou=Users,dc=domain,dc=com',
                       'bindpass' => 'proxypassword'
       );
 
               // Open LDAP connection to server
               $ldapconn  = ldap_connect($ldap['ldaphost']);
               ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
               ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
 
               // Bind with binduser as proxy to do the search
               [b]$proxyBind         = ldap_bind($ldapconn, $ldap['binduser'], $ldap['bindpass'])[/b]
 
What is wrong with this line? I really don't understand it. I'm not much of a php coder, this bit of code has been taken from a site.

All I want to do is to be able to log into Gallery2 with ldap. I'm starting to pull my hair out over this. Obviously in this example ive taken out my ldap details. I've had them checked and i've definately put in the right details. Can anyone see anything obviously wrong in the code?

The full code is located at http://codex.gallery2.org/LDAP_authentication under LDAP UserLogin for Gallery 2.3.
Post Reply