Zentyal Forum, Linux Small Business Server

Zentyal Server => Installation and Upgrades => Topic started by: hanneskeller on June 30, 2011, 01:24:19 pm

Title: [SOLVERD]trouble with ldap+php
Post by: hanneskeller on June 30, 2011, 01:24:19 pm
Hi,

I'm trying to write an php-application, that authenticates itself against ebox LDAP. For some reasons it doesn't authenticate. The same server's virtual host serves also another website on which Joomla runs. On that Joomla installation  users can authenticate themselves.

As a newbie - I looked also the examples that are available on different sites, but nothing happens.

in the system log I can find only:
Jun 30 14:18:01 fw1 slapd[30928]: connection_read(35): no connection!
Jun 30 14:18:01 fw1 slapd[30928]: connection_read(35): no connection!
Jun 30 14:20:01 fw1 CRON[1299]: (root) CMD (/usr/share/ebox/ebox-cronjob-runner >> /dev/null 2>&1)
Jun 30 14:20:01 fw1 CRON[1300]: (root) CMD (/usr/share/ebox-usersandgroups/slave-sync)
Jun 30 14:20:09 fw1 slapd[30928]: connection_read(37): no connection!

Can anybody tell - is something not configured yet? php5-ldap is installed...

the php-code itself:
function authorize($usr,$pwd) {
$ldap['user'] = $usr;
$ldap['pass'] = $pwd;
$ldap['host'] = '127.0.0.1';
$ldap['port'] = '389';
$ldap['dn'] = 'ou=Users,dc=fw1,dc=nec,dc=eu';
$ldap['base'] = 'dc=fw1,dc=nec,dc=eu';

// connecting to ldap
$ldap['conn'] = ldap_connect( $ldap['host'], $ldap['port'] )
or die( "Could not connect to {$ldap['host']}" );


$ldap['conn'] = ldap_connect( $ldap['host'], $ldap['port'] );
$ldap['bind'] = ldap_bind( $ldap['conn'],"cn=".$ldap['user'].",". $ldap['dn'], $ldap['pass']);

if( !$ldap['bind']){
echo 'did not connect';
return FALSE;
exit;
} else {
echo ' connected';
ldap_unbind($ldap['conn']);
return TRUE;
}

return FALSE;
}

bests

Hannes
Title: Re: trouble with ldap+php
Post by: Josep on July 01, 2011, 11:22:07 am
It appears that you are using the user's username and password to bind to the LDAP server.
I don't think it works that way.
You use your 'ebox' and password user to bind to the LDAP server and then you can query for those username and password under the Users OU.
Title: Re: [SOLVERD]trouble with ldap+php
Post by: hanneskeller on July 01, 2011, 12:29:01 pm
used this example: http://forum.zentyal.org/index.php/topic,1616.msg6990.html#msg6990 and got things working