Hello,
I developed a PHP script that allows users via LDAP to connect from my
current intranet intranet that I develop in Drupal. My problem is that
when a user connects from my current intranet, it can not connect from
my intranet in Drupal because it has an error:
Another user already exists in the system with the same login name. You
should contact the system administrator in order to solve this conflict.
In fact I think the module Ldap_authentification should probably add
other data base but I do not know how it works and how to ensure that my
users once they log on from my site can also connect from the website is
under Drupal.
An idea?
Thank you
My script PHP :
<?php
require_once 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
$userName = $_REQUEST["user"];
$password = $_REQUEST["passwd"];
$form_state['values']['name']=$userName;
$form_state['values']['pass']=$password;
ldapauth_authenticate($form_state);
//ldapauth_login_validate(null,$form_state);
global $base_url;
$uQuery="select uid from users where name='$userName'";
$rSet=db_query($uQuery);
$result = db_fetch_object($rSet);
if(empty($result))
{
$iQuery="insert into users (name,status) VALUES('$userName',1)";
db_query($iQuery);
$uQuery="select uid from users where name='$userName'";
$rSet=db_query($uQuery);
$result = db_fetch_object($rSet);
}
if($result && function_exists("user_load"))
{
if ($account = user_load(array('uid'=>$result->uid, 'status'
=> 1)))
{
$user = $account;
watchdog('user', 'Session opened for %name : .%name',
array('%name' => $user->name));
$user->login = time();
db_query("UPDATE {users} SET login = %d WHERE uid = %
d", $user->login, $user->uid);
sess_regenerate();
drupal_goto($base_url.'/intra');
}
}
else
{
echo "<h1>Could not log you in. Please try again later.</h1>";
}
?>