diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php
index 957b8798e9394a7390388778343aa851cf914844..39a00c6444e41a7858ae08f9e6f358c25bc344b4 100644
--- a/htdocs/adherents/ldap.php
+++ b/htdocs/adherents/ldap.php
@@ -34,9 +34,10 @@ $langs->load("members");
 $langs->load("ldap");
 $langs->load("admin");
 
-// Protection quand utilisateur externe
-$rowid = isset($_GET["id"])?$_GET["id"]:'';
+$rowid = GETPOST("id");
+$action = GETPOST('action');
 
+// Protection
 $socid=0;
 if ($user->societe_id > 0)
 {
@@ -52,11 +53,12 @@ if (! $result)
 	exit;
 }
 
+
 /*
  * Actions
  */
 
-if ($_GET["action"] == 'dolibarr2ldap')
+if ($action == 'dolibarr2ldap')
 {
 	$message="";
 
@@ -121,7 +123,7 @@ print '<tr><td>'.$langs->trans("Login").'</td><td class="valeur">'.$adh->login.'
 if ($conf->global->LDAP_MEMBER_FIELD_PASSWORD)
 {
 	print '<tr><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td>';
-	print '<td class="valeur">'.$fuser->pass.'</td>';
+	print '<td class="valeur">'.$adh->pass.'</td>';
 	print "</tr>\n";
 }
 
@@ -129,7 +131,7 @@ if ($conf->global->LDAP_MEMBER_FIELD_PASSWORD)
 if ($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)
 {
 	print '<tr><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td>';
-	print '<td class="valeur">'.$fuser->pass_crypted.'</td>';
+	print '<td class="valeur">'.$adh->pass_crypted.'</td>';
 	print "</tr>\n";
 }
 
@@ -194,26 +196,35 @@ if ($result > 0)
 	$info=$adh->_load_ldap_info();
 	$dn=$adh->_load_ldap_dn($info,1);
 	$search = "(".$adh->_load_ldap_dn($info,2).")";
-	$records=$ldap->getAttribute($dn,$search);
-
-	//print_r($records);
 
-	// Affichage arbre
-	if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0))
-	{
-		if (! is_array($records))
-		{
-			print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
-		}
-		else
-		{
-			$result=show_ldap_content($records,0,$records['count'],true);
-		}
-	}
-	else
+	if (empty($dn))
 	{
-		print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
+	    $langs->load("errors");
+	    print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font></td></tr>';
 	}
+    else
+    {
+    	$records=$ldap->getAttribute($dn,$search);
+
+    	//print_r($records);
+
+    	// Affichage arbre
+    	if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0))
+    	{
+    		if (! is_array($records))
+    		{
+    			print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
+    		}
+    		else
+    		{
+    			$result=show_ldap_content($records,0,$records['count'],true);
+    		}
+    	}
+    	else
+    	{
+    		print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
+    	}
+    }
 
 	$ldap->unbind();
 	$ldap->close();
@@ -227,9 +238,7 @@ else
 print '</table>';
 
 
-
+llxFooter();
 
 $db->close();
-
-llxFooter();
 ?>