I am just started with drupal version 5.5, LDAP Integration 5.x-1.3,PHP5.2,MYSQL5 ,Apache2.2 , windows XP ,
and one of my first goals is to get the ldap working as it will be one of the first modules needed by my client , i got my client LDAP server working without any problems with Knowledge Tree (Documentation management System) , but i started in trouble since i decide to integrate my client ldap server with drupal , so i searched through the forms and internet to find a solution , i tired all the available solution ,but unfortantlity it doesn't work any of the solution , beer in mind that i got it working before with Knowledge Tree
My LDAP Configuration is:
Server hostname : ldapexample.company.com
Server port: 389
base dn: o=company ,c=country
no TSL auth required
allow any mouse bind option
so i decided to not give up , so i started to debug PHP code (thanks to Komodo and Xdebug) , to see how Knowledge Tree LDAP module got it , and see why drupal LDAP failed every time.
the solution was very simple :
Knowledge Tree has a function called rebind which at every user auth it call the following:
$ds = ldap_connect('hostname','port');
$r = ldap_bind($ds,'',''); //$r = should return 1
$r = ldap_bind($ds,$dn,$pass); //$r= should retun 1
since $dn is user DN , $pass = userpassword
if i called $r = ldap_bind($ds,$dn,$pass); without frist calling $r = ldap_bind($ds,'',''); then the fucntion return (-1)
but if i called $r = ldap_bind($ds,$dn,$pass); after frist calling $r = ldap_bind($ds,'',''); then the function return (1)
Actually i don't know why my LDAP server doing something like this (as i am system engineer not php developer), but the most important thing that after i modified the LDAP integration module LDAPInterface.php
which locate as per my installation in ->(sites\all\modules\ldap_integration\ldap_integration\LDAPInterface.php)
original code:
function bind($dn, $pass) {
ob_start();
set_error_handler(array('LDAPInterface', 'void_error_handler'));
$ret = ldap_bind($this->connection, $dn, $pass);
restore_error_handler();
ob_end_clean();
return $ret;
}
modifed code:
function bind($dn, $pass) {
ob_start();
set_error_handler(array('LDAPInterface', 'void_error_handler'));
$ret = ldap_bind($this->connection, '', '');
$ret = ldap_bind($this->connection, $dn, $pass);
restore_error_handler();
ob_end_clean();
return $ret;
}
WOW , finally after a 3 days of debugging it works
i don't know if this modification should be included in next version of LDAP integration or not
any way i just wanted to highlight the problem i faced may be the solution be helpful to some one esle
finally i want to thank all people who particpate in this application which is the best CMS i have ever found so far
Comments
Comment #1
xmattus commentedThis is sort of a shot in the dark, but what software is the LDAP server running? I imagine this module is mostly developed and tested with OpenLDAP in mind. If you're using something else it might be a quirk of the interaction between PHP's LDAP functions and what the particular server you're using expects.
Comment #2
johnbarclay commentedClosing 5.x issues to clean out issue queue.