diff --git a/ecrire/install/etape_3.php b/ecrire/install/etape_3.php
index 90f3ba719be493d341f2d1c549e5612b7f8b9940..07731cd521b8dc1de233578247d7efe99c555bd3 100644
--- a/ecrire/install/etape_3.php
+++ b/ecrire/install/etape_3.php
@@ -14,7 +14,6 @@ if (!defined("_ECRIRE_INC_VERSION")) return;	#securite
 
 include_spip('inc/headers');
 function install_bases(){
-	global $spip_lang_right, $spip_version;
 
 	$adresse_db = defined('_INSTALL_HOST_DB')
 		? _INSTALL_HOST_DB
@@ -58,9 +57,6 @@ function install_bases(){
 
 	$link = mysql_connect($adresse_db, $login_db, $pass_db);
 
-	echo "<"."!-- $link ";
-	echo "(".$GLOBALS['table_prefix'].")";
-
 	if ($choix_db == "new_spip") {
 		$sel_db = _request('table_new');
 		if (preg_match(',^[a-z_0-9-]+$,i', $sel_db))
@@ -69,8 +65,6 @@ function install_bases(){
 	else {
 		$sel_db = $choix_db;
 	}
-	echo "$sel_db ";
-
 	mysql_select_db($sel_db);
 	spip_query("SELECT COUNT(*) FROM spip_meta");
 	$nouvelle = spip_sql_errno();
@@ -87,17 +81,18 @@ function install_bases(){
 	creer_base();
 	include_spip('base/upgrade');
 	maj_base();
-	
+
 	// Tester $mysql_rappel_nom_base
 	$GLOBALS['mysql_rappel_nom_base'] = true;
 	$GLOBALS['spip_mysql_db'] = $sel_db;
 	$ok_rappel_nom = spip_query("INSERT INTO spip_meta (nom,valeur) VALUES ('mysql_rappel_nom_base', 'test')");
 	if ($ok_rappel_nom) {
-		echo " (ok rappel nom base `$sel_db`.spip_meta) ";
+		$res ='';
 		$ligne_rappel = '';
 		spip_query("DELETE FROM spip_meta WHERE nom='mysql_rappel_nom_base'");
 	} else {
-		echo " (erreur rappel nom base `$sel_db`.spip_meta $nouvelle) ";
+		$res = " $link (". $GLOBALS['table_prefix']
+		  . ") $sel_db (erreur rappel nom base `$sel_db`.spip_meta $nouvelle) ";
 		$GLOBALS['mysql_rappel_nom_base'] = false;
 		$ligne_rappel = "\$GLOBALS['mysql_rappel_nom_base'] = false; ".
 		"/* echec du test sur `$sel_db`.spip_meta lors de l'installation. */\n";
@@ -116,25 +111,25 @@ function install_bases(){
 			spip_query("INSERT INTO spip_meta (nom, valeur, impt) VALUES ('charset_sql_connexion', '".$GLOBALS['meta']['charset_sql_connexion']."', 'non')");
 		
 		spip_query("INSERT INTO spip_meta (nom, valeur) VALUES ('nouvelle_install', '1')");
-		$result_ok = !spip_sql_errno();
+		$result_ko = spip_sql_errno();
 	} else {
 	  // en cas de reinstall sur mise a jour mal passee
-	  spip_query("DELETE FROM spip_meta WHERE nom='import_all'");
+		spip_query("DELETE FROM spip_meta WHERE nom='import_all'");
 		$result = spip_query("SELECT COUNT(*) FROM spip_articles");
-		$result_ok = (spip_num_rows($result) > 0);
+		$result_ko = (spip_num_rows($result) == 0);
 	}
-	echo "($result_ok) -->";
 
-	if($chmod) {
-		$conn = "<"."?php\n";
-		$conn .= "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n";
-		$conn .= "@define('_SPIP_CHMOD', ". sprintf('0%3o',$chmod).");\n";
-		$conn .= "?".">";
-		if (!ecrire_fichier(_FILE_CHMOD_INS . _FILE_TMP . '.php',
+	if (!$result_ko) {
+		if($chmod) {
+			$conn = "<"."?php\n";
+			$conn .= "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n";
+			$conn .= "@define('_SPIP_CHMOD', ". sprintf('0%3o',$chmod).");\n";
+			$conn .= "?".">";
+			if (!ecrire_fichier(_FILE_CHMOD_INS . _FILE_TMP . '.php',
 		$conn))
-			redirige_par_entete(generer_url_ecrire('install'));
-	}
-	if ($result_ok) {
+			  redirige_par_entete(generer_url_ecrire('install'));
+		}
+
 		if (preg_match(',(.*):(.*),', $adresse_db, $r))
 			list(,$adresse_db, $port) = $r;
 		else
@@ -152,75 +147,12 @@ function install_bases(){
 		$conn))
 			redirige_par_entete(generer_url_ecrire('install'));
 	}
-	return $result_ok;
+	return $result_ko ? "<!--\n$res\n-->" : '';
 }
 
-
-function install_etape_3_dist()
+function install_propose_ldap()
 {
-	global $email, $ldap_present, $login, $nom, $pass, $spip_lang_right;
-
-	echo install_debut_html();
-	$result_ok = install_bases();
-	if ($result_ok) {
-		echo "<p class='resultat'><b>"._T('info_base_installee')."</b></p>";
-
-	if (@file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php'))
-		include(_FILE_CONNECT_INS . _FILE_TMP . '.php');
-	else
-		redirige_par_entete(generer_url_ecrire('install'));
-
-	if (@file_exists(_FILE_CHMOD_INS . _FILE_TMP . '.php'))
-		include(_FILE_CHMOD_INS . _FILE_TMP . '.php');
-	else
-		redirige_par_entete(generer_url_ecrire('install'));
-
-	echo info_etape(_T('info_informations_personnelles'),
-		"<b>"._T('texte_informations_personnelles_1')."</b>" .
-		aide ("install5") .
-		"</p><p>" .
-		_T('texte_informations_personnelles_2') . " " .
-		_T('info_laisser_champs_vides')
-	);
-
-	echo generer_form_ecrire('install', (
-
-	  "\n<input type='hidden' name='etape' value='4' />"
-
-	. fieldset(_T('info_identification_publique'),
-		array(
-			'nom' => array(
-				'label' => "<b>"._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n",
-				'valeur' => $nom
-			),
-			'email' => array(
-				'label' => "<b>"._T('entree_adresse_email')."</b>\n",
-				'valeur' => $email
-			)
-		)
-	)
-
-	. fieldset(_T('entree_identifiants_connexion'),
-		array(
-			'login' => array(
-				'label' => "<b>"._T('entree_login')."</b><br />\n"._T('info_plus_trois_car')."\n",
-				'valeur' => $login
-			),
-			'pass' => array(
-				'label' => "<b>"._T('entree_mot_passe')."</b><br />\n"._T('info_plus_cinq_car_2')."\n",
-				'valeur' => $pass
-			),
-			'pass_verif' => array(
-				'label' => "<b>"._T('info_confirmer_passe')."</b><br />\n",
-				'valeur' => $pass
-			)
-		)
-	)
-
-	. bouton_suivant()));
-
-	if (function_exists('ldap_connect') AND !$ldap_present) {
-		echo generer_form_ecrire('install', (
+	return generer_form_ecrire('install', (
 			fieldset(_T('info_authentification_externe'),
 				array(
 				'etape' => array(
@@ -230,17 +162,84 @@ function install_etape_3_dist()
 					)),
 				 bouton_suivant(_T('bouton_acces_ldap'))
 				 )));
-	}
-	}
-	else if ($result_ok) {
-		echo _T('alerte_maj_impossible', array('version' => $spip_version));
-	}
-	else {
-		echo "<p class='resultat'><b>"._T('avis_operation_echec')."</b></p>"._T('texte_operation_echec');
-	}
+}
+
+
+function install_premier_auteur($email, $login, $nom, $pass)
+{
+	if (file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php'))
+	  include(_FILE_CONNECT_INS . _FILE_TMP . '.php');
+	else
+	  redirige_par_entete(generer_url_ecrire('install', 'connect=1'));
+	
+	if (file_exists(_FILE_CHMOD_INS . _FILE_TMP . '.php'))
+	  include(_FILE_CHMOD_INS . _FILE_TMP . '.php');
+	else
+	  redirige_par_entete(generer_url_ecrire('install', 'chmod=1'));
+
+	return "<p class='resultat'><b>"
+	. _T('info_base_installee')
+	. "</b></p>"
+	. info_etape(_T('info_informations_personnelles'),
+		     "<b>"._T('texte_informations_personnelles_1')."</b>" .
+			     aide ("install5") .
+			     "</p><p>" .
+			     _T('texte_informations_personnelles_2') . " " .
+			     _T('info_laisser_champs_vides')
+			     )
+	. generer_form_ecrire('install', (
+			  "\n<input type='hidden' name='etape' value='4' />"
+			 . fieldset(_T('info_identification_publique'),
+				    array(
+					  'nom' => array(
+							 'label' => "<b>"._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n",
+							 'valeur' => $nom
+							 ),
+					  'email' => array(
+							   'label' => "<b>"._T('entree_adresse_email')."</b>\n",
+							   'valeur' => $email
+							   )
+					  )
+				    )
+
+			  . fieldset(_T('entree_identifiants_connexion'),
+				   array(
+					 'login' => array(
+							  'label' => "<b>"._T('entree_login')."</b><br />\n"._T('info_plus_trois_car')."\n",
+							  'valeur' => $login
+							  ),
+					 'pass' => array(
+							 'label' => "<b>"._T('entree_mot_passe')."</b><br />\n"._T('info_plus_cinq_car_2')."\n",
+							 'valeur' => $pass
+							 ),
+					 'pass_verif' => array(
+							       'label' => "<b>"._T('info_confirmer_passe')."</b><br />\n",
+							       'valeur' => $pass
+							       )
+					 )
+				     )
+			  . bouton_suivant()));
+}
+
+function install_etape_3_dist()
+{
+	$ldap_present = _request('ldap_present');
+	$res = $ldap_present ? '' : install_bases();
 
+	if (!function_exists('ldap_connect')) $ldap_present = true;
+
+	if ($res)
+		$res .= "<p class='resultat'><b>"._T('avis_operation_echec')."</b></p>"._T('texte_operation_echec');
+	
+	else $res = install_premier_auteur(_request('email'),
+					   _request('login'),
+					   _request('nom'),
+					   _request('pass'))
+	  . ($ldap_present ?  '' : install_propose_ldap());
+
+	echo install_debut_html();
+	echo $res;
 	echo info_progression_etape(3,'etape_','install/');
 	echo install_fin_html();
 }
-
 ?>
diff --git a/ecrire/install/etape_ldap1.php b/ecrire/install/etape_ldap1.php
index cd4d6a5c3d916f3836e7c05c83edfaf02d3edaad..0ffa351a6184eca0b44c4bfa3aac5e09901aff7e 100644
--- a/ecrire/install/etape_ldap1.php
+++ b/ecrire/install/etape_ldap1.php
@@ -13,11 +13,30 @@
 // http://doc.spip.org/@inc_install_ldap1
 function install_etape_ldap1_dist()
 {
-	global $spip_lang_right;
+	$adresse_ldap = defined('_INSTALL_HOST_LDAP')
+		? _INSTALL_HOST_LDAP
+	  : 'localhost';
+
+	$port_ldap = defined('_INSTALL_PORT_LDAP')
+		? _INSTALL_PORT_LDAP
+		: 389;
+
+	$tls_ldap = defined('_INSTALL_TLS_LDAP')
+		? _INSTALL_TLS_LDAP
+		: 'non';
+
+	$protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP')
+		? _INSTALL_PROTOCOLE_LDAP
+		: 3 ; // on essaie 2 en cas d'echec
+
+	$login_ldap = defined('_INSTALL_USER_LDAP')
+		? _INSTALL_USER_LDAP
+		: '';
+
+	$pass_ldap = defined('_INSTALL_PASS_LDAP')
+		? _INSTALL_PASS_LDAP
+		: '';
 
-	$protocole_ldap = 3; // on essaie 2 en cas d'echec
-	$adresse_ldap = 'localhost';
-	$port_ldap = 389;
 
 	// Recuperer les anciennes donnees (si presentes)
 	if (@file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php')) {
@@ -46,7 +65,7 @@ function install_etape_ldap1_dist()
 			),
 			'tls_ldap' => array(
 				'label' => '<b>'._T('tls_ldap').'</b>',
-				'valeur' => 'non',
+				'valeur' => $tls_ldap,
 				'alternatives' => array(
 					'non' => _T('item_non'),
 					'oui' => _T('item_oui')
diff --git a/ecrire/install/etape_ldap2.php b/ecrire/install/etape_ldap2.php
index 6b9877b8695d24868a7eec671dbd12d91d97ab30..69608b39b44450a8ffcc9c80ecc696088a41b831 100644
--- a/ecrire/install/etape_ldap2.php
+++ b/ecrire/install/etape_ldap2.php
@@ -14,10 +14,20 @@
 // http://doc.spip.org/@inc_install_ldap2
 function install_etape_ldap2_dist()
 {
-	global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $spip_lang_right;
-
 	echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
 
+	$adresse_ldap =  _request('adresse_ldap');
+
+	$port_ldap = _request('port_ldap');
+
+	$tls_ldap =  _request('tls_ldap');
+
+	$protocole_ldap =  _request('protocole_ldap');
+
+	$login_ldap =  _request('login_ldap');
+
+	$pass_ldap =  _request('pass_ldap');
+
 	$port_ldap = intval($port_ldap);
 	$ldap_link = @ldap_connect($adresse_ldap, $port_ldap);
 	$erreur = "ldap_connect($adresse_ldap, $port_ldap)";
diff --git a/ecrire/install/etape_ldap3.php b/ecrire/install/etape_ldap3.php
index 85df259c9be825a929b806b63e7a505557a83a36..75858f3c2948b3c41ddcdbe2c70b09300c700dba 100644
--- a/ecrire/install/etape_ldap3.php
+++ b/ecrire/install/etape_ldap3.php
@@ -14,7 +14,12 @@
 // http://doc.spip.org/@inc_install_ldap3
 function install_etape_ldap3_dist()
 {
-	global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $spip_lang_right;
+	global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap;
+
+
+	$base_ldap_text = defined('_INSTALL_BASE_LDAP')
+		? _INSTALL_BASE_LDAP
+		: "ou=users, dc=mon-domaine, dc=com";
 
 	echo install_debut_html();
 
@@ -68,7 +73,7 @@ function install_etape_ldap3_dist()
 	. "\n<input type='hidden' name='tls_ldap' value=\"$tls_ldap\" />"
 
 	. "\n<fieldset>"
-	. "<input type='text' name='base_ldap_text' class='formo' value=\"ou=users, dc=mon-domaine, dc=com\" size='40' />"
+	. "<input type='text' name='base_ldap_text' class='formo' value=\"$base_ldap_text\" size='40' />"
 	. "\n</fieldset>"
 	. bouton_suivant()));
 
diff --git a/ecrire/install/etape_ldap4.php b/ecrire/install/etape_ldap4.php
index b8a5236eb399b2f495fb5ea57379f4339d392be5..775b9c8a23819f2996a46b70cfb51c2621c5516f 100644
--- a/ecrire/install/etape_ldap4.php
+++ b/ecrire/install/etape_ldap4.php
@@ -13,10 +13,14 @@
 // http://doc.spip.org/@inc_install_ldap4
 function install_etape_ldap4_dist()
 {
-	global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $base_ldap, $base_ldap_text, $spip_lang_right;
+	global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $base_ldap, $base_ldap_text;
 
 	echo install_debut_html();
 
+	$statut_ldap = defined('_INSTALL_STATUT_LDAP')
+		? _INSTALL_STATUT_LDAP
+		: '1comite';
+
 	if (!$base_ldap) $base_ldap = $base_ldap_text;
 
 	$ldap_link = @ldap_connect("$adresse_ldap", "$port_ldap");
@@ -61,7 +65,7 @@ function install_etape_ldap4_dist()
 			array(
 				'statut_ldap' => array(
 					'label' => _T('info_statut_utilisateurs_2').'<br />',
-					'valeur' => '1comite',
+					'valeur' => $statut_ldap,
 					'alternatives' => liste_statuts_ldap()
 					)
 				)
diff --git a/ecrire/install/etape_ldap5.php b/ecrire/install/etape_ldap5.php
index aa5b088860ebf4dd3d997d9aa875455de903eca5..159f2a8f24e460ddb75aebd43fa59483f9da3578 100644
--- a/ecrire/install/etape_ldap5.php
+++ b/ecrire/install/etape_ldap5.php
@@ -34,7 +34,8 @@ function install_etape_ldap5_dist()
 	echo info_etape(_T('info_ldap_ok'), _T('info_terminer_installation'));
 
 	echo generer_form_ecrire('install', (
-		"<input type='hidden' name='etape' value='4' />"
+		"<input type='hidden' name='etape' value='3' />" .
+		"<input type='hidden' name='ldap_present' value='true' />" 
 		. bouton_suivant()));
 
 	echo info_progression_etape(5,'etape_ldap','install/');