login to multiple ldap servers
Yannick Majoros <majoros <at> inma.ucl.ac.be>
2006-04-12 15:34:26 GMT
Hello,
As a new Emilda user, I had to customize it to suit our needs. I had to
adapt small parts of the code, and I think it makes Emilda better, so
here it goes...
The problem was that the login script uses a hardcoded location id to
determine on which ldap server it does the authentication. By this,
Emilda wasn't able to use multiple ldap servers for authentication (we
need 2). Also, it went wrong if there was no location_id=1. I fixed this
by telling Emilda to try the ldap servers of all locations until it
finds a correct one.
Here is the patch to login.php:
99,108c99,118
<
ldap_get_server(ldap_get_location_ldap_id($_REQUEST['location_id']));
< if ($ldap_server) {
< $ldap = (ldap_get_user($_REQUEST['username'],
$_REQUEST['password']));
< $ldap_success = true;
< if($ldap["connect_success"] && $ldap["auth_success"] &&
($ldap['user_ldap_id'] == native_user_ldap_id($_REQUEST['username']))) {
< ldap_sync_user($ldap['result_array']);
< } elseif ($ldap["connect_success"] &&
$ldap["auth_success"] && !native_user_exists($_REQUEST['username']) &&
ldap_template_add_enabled()) {
< ldap_template_user_add($ldap['result_array'],
$ldap['search'], $_REQUEST['location_id']);
< } else {
< $ldap_success = false;
---
> $locations=Array();
> $res=mysql_query('SELECT location_id FROM locations');
> while ($loc=mysql_fetch_row($res))
> $locations[]=$loc[0];
> foreach($locations as $location)
> {
>
//ldap_get_server(ldap_get_location_ldap_id($_REQUEST['location_id']));
> ldap_get_server(ldap_get_location_ldap_id($location));
> if ($ldap_server) {
> $ldap = (ldap_get_user($_REQUEST['username'],
$_REQUEST['password']));
> $ldap_success = true;
> if($ldap["connect_success"] &&
$ldap["auth_success"] && ($ldap['user_ldap_id'] ==
native_user_ldap_id($_REQUEST['username']))) {
> ldap_sync_user($ldap['result_array']);
> } elseif ($ldap["connect_success"] &&
$ldap["auth_success"] && !native_user_exists($_REQUEST['username']) &&
ldap_template_add_enabled()) {
>
ldap_template_user_add($ldap['result_array'], $ldap['search'], $location);
> } else {
> $ldap_success = false;
> }
> if ($ldap_success)
> break;
Regards,
--
----------------------------------------------------------------------
Yannick Majoros http://www.inma.ucl.ac.be/~majoros
Informaticien UCL/INMA-MEMA
4, avenue G. Lemaître
B-1348 Louvain-la-Neuve
Belgium
Tel: +32-10-47.80.10
Fax: +32-10-47.21.80
Si vous avez des problèmes pour afficher ce message (accents qui ne passent pas, signature
électronique, ...) votre système de mail n'est pas conforme aux standards modernes, voir
http://www.inma.ucl.ac.be/~majoros/email.html
#JAPH : http://www.inma.ucl.ac.be/~majoros/japh.txt
----------------------------------------------------------------------
_______________________________________________
Emilda-devel mailing list
Emilda-devel <at> lists.realnode.com
http://lists.realnode.com/mailman/listinfo/emilda-devel