Author Topic: [SOLVERD]trouble with ldap+php  (Read 1123 times)

hanneskeller

  • Zen Apprentice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
[SOLVERD]trouble with ldap+php
« 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
« Last Edit: July 01, 2011, 12:27:46 pm by hanneskeller »

Josep

  • Zen Samurai
  • ****
  • Posts: 255
  • Karma: +6/-0
    • View Profile
Re: trouble with ldap+php
« Reply #1 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.

hanneskeller

  • Zen Apprentice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: [SOLVERD]trouble with ldap+php
« Reply #2 on: July 01, 2011, 12:29:01 pm »