<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.18.3">
</HEAD>
<BODY>
Hello,<BR>
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:<BR>
<BR>
<FONT COLOR="#ff0000">Another user already exists in the system with the same login name. You should contact the system administrator in order to solve this conflict.</FONT><BR>
<BR>
<BR>
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.<BR>
<BR>
An idea?<BR>
Thank you<BR>
<BR>
My script PHP :<BR>
<BR>
<?php<BR>
require_once 'includes/bootstrap.inc';<BR>
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);<BR>
global $user;<BR>
<BR>
$userName = $_REQUEST["user"];<BR>
$password = $_REQUEST["passwd"];<BR>
$form_state['values']['name']=$userName;<BR>
$form_state['values']['pass']=$password;<BR>
ldapauth_authenticate($form_state); <BR>
//ldapauth_login_validate(null,$form_state);<BR>
global $base_url;<BR>
$uQuery="select uid from users where name='$userName'";<BR>
$rSet=db_query($uQuery);<BR>
$result = db_fetch_object($rSet);<BR>
if(empty($result))<BR>
{<BR>
$iQuery="insert into users (name,status) VALUES('$userName',1)";<BR>
db_query($iQuery);<BR>
$uQuery="select uid from users where name='$userName'";<BR>
$rSet=db_query($uQuery);<BR>
$result = db_fetch_object($rSet);<BR>
}<BR>
<BR>
if($result && function_exists("user_load"))<BR>
{<BR>
if ($account = user_load(array('uid'=>$result->uid, 'status' => 1)))<BR>
{<BR>
$user = $account;<BR>
<BR>
watchdog('user', 'Session opened for %name : .%name', array('%name' => $user->name));<BR>
$user->login = time();<BR>
<BR>
db_query("UPDATE {users} SET login = %d WHERE uid = %d", $user->login, $user->uid);<BR>
sess_regenerate();<BR>
drupal_goto($base_url.'/intra');<BR>
}<BR>
}<BR>
else<BR>
{<BR>
echo "<h1>Could not log you in. Please try again later.</h1>";<BR>
}<BR>
?><BR>
<BR>
</BODY>
</HTML>